aboutsummaryrefslogtreecommitdiffstats
path: root/libqpdf/QPDFJob_json.cc
diff options
context:
space:
mode:
authorJay Berkenbilt <ejb@ql.org>2022-01-31 21:56:05 +0100
committerJay Berkenbilt <ejb@ql.org>2022-01-31 21:57:45 +0100
commit47f33cec2582101485ed93d041d069118a62b5cf (patch)
treea853eb0319a79d1eefef78c38d33c602bcf49ee3 /libqpdf/QPDFJob_json.cc
parente3506253f17137d6d4831b4615d74689446da72c (diff)
downloadqpdf-47f33cec2582101485ed93d041d069118a62b5cf.tar.zst
QPDFJob: add test cases
Diffstat (limited to 'libqpdf/QPDFJob_json.cc')
-rw-r--r--libqpdf/QPDFJob_json.cc8
1 files changed, 8 insertions, 0 deletions
diff --git a/libqpdf/QPDFJob_json.cc b/libqpdf/QPDFJob_json.cc
index da1e19e2..2da427c3 100644
--- a/libqpdf/QPDFJob_json.cc
+++ b/libqpdf/QPDFJob_json.cc
@@ -2,6 +2,7 @@
#include <qpdf/JSONHandler.hh>
#include <qpdf/QPDFUsage.hh>
#include <qpdf/QUtil.hh>
+#include <qpdf/QTC.hh>
#include <memory>
#include <stdexcept>
@@ -108,6 +109,7 @@ Handlers::addBare(bare_handler_t fn)
jh->addBoolHandler([this, fn](std::string const& path, bool v){
if (! v)
{
+ QTC::TC("qpdf", "QPDFJob json bare not true");
usage(path + ": value must be true");
}
else
@@ -140,12 +142,14 @@ Handlers::addChoices(char const** choices,
{
if (strcmp(*i, p) == 0)
{
+ QTC::TC("qpdf", "QPDFJob json choice match");
matches = true;
break;
}
}
if (! matches)
{
+ QTC::TC("qpdf", "QPDFJob json choice mismatch");
std::ostringstream msg;
msg << path + ": unexpected value; expected one of ";
bool first = true;
@@ -307,6 +311,7 @@ Handlers::beginOutputOptionsEncrypt(JSON j)
{
if (key_len != 0)
{
+ QTC::TC("qpdf", "QPDFJob json encrypt duplicate key length");
usage("exactly one of 40bit, 128bit, or 256bit must be given");
}
key_len = QUtil::string_to_int(key.c_str());
@@ -322,12 +327,14 @@ Handlers::beginOutputOptionsEncrypt(JSON j)
});
if (key_len == 0)
{
+ QTC::TC("qpdf", "QPDFJob json encrypt no key length");
usage("exactly one of 40bit, 128bit, or 256bit must be given;"
" an empty dictionary may be supplied for one of them"
" to set the key length without imposing any restrictions");
}
if (! (user_password_seen && owner_password_seen))
{
+ QTC::TC("qpdf", "QPDFJob json encrypt missing password");
usage("the user and owner password are both required; use the empty"
" string for the user password if you don't want a password");
}
@@ -550,6 +557,7 @@ Handlers::beginOptionsPages(JSON j)
});
if (! file_seen)
{
+ QTC::TC("qpdf", "QPDFJob json pages no file");
usage("file is required in page specification");
}
this->c_pages->pageSpec(