From 60965d5f4d608bdccc2ffd4e8753e12cbbbd71d2 Mon Sep 17 00:00:00 2001 From: Jay Berkenbilt Date: Sun, 21 May 2023 13:35:09 -0400 Subject: Rerun clang-format --- libtests/aes.cc | 3 +-- libtests/arg_parser.cc | 34 ++++++++--------------- libtests/bits.cc | 22 +++++---------- libtests/concatenate.cc | 3 +-- libtests/cxx11.cc | 3 +-- libtests/input_source.cc | 41 ++++++++-------------------- libtests/json.cc | 20 ++++---------- libtests/json_handler.cc | 4 +-- libtests/json_parse.cc | 3 +-- libtests/logger.cc | 3 +-- libtests/logger_c.c | 23 +++++----------- libtests/lzw.cc | 3 +-- libtests/matrix.cc | 32 ++++++---------------- libtests/md5.cc | 16 ++++------- libtests/nntree.cc | 33 +++++++---------------- libtests/pointer_holder.cc | 3 +-- libtests/qintc.cc | 20 +++++--------- libtests/qutil.cc | 67 +++++++++++++++++----------------------------- libtests/runlength.cc | 8 ++---- libtests/sha2.cc | 7 +---- 20 files changed, 104 insertions(+), 244 deletions(-) (limited to 'libtests') diff --git a/libtests/aes.cc b/libtests/aes.cc index 7368b44e..370cd65e 100644 --- a/libtests/aes.cc +++ b/libtests/aes.cc @@ -17,8 +17,7 @@ usage() << " -encrypt -- encrypt" << std::endl << " -decrypt -- decrypt CBC mode" << std::endl << " -zero-iv -- use zero initialization vector" << std::endl - << " -static-iv -- use static initialization vector" - << std::endl + << " -static-iv -- use static initialization vector" << std::endl << " -no-padding -- disable padding" << std::endl << "Options must precede key and file names." << std::endl; exit(2); diff --git a/libtests/arg_parser.cc b/libtests/arg_parser.cc index c9474d55..fde00520 100644 --- a/libtests/arg_parser.cc +++ b/libtests/arg_parser.cc @@ -41,9 +41,7 @@ ArgParser::ArgParser(int argc, char* argv[]) : void ArgParser::initOptions() { - auto b = [this](void (ArgParser::*f)()) { - return QPDFArgParser::bindBare(f, this); - }; + auto b = [this](void (ArgParser::*f)()) { return QPDFArgParser::bindBare(f, this); }; auto p = [this](void (ArgParser::*f)(std::string const&)) { return QPDFArgParser::bindParam(f, this); }; @@ -71,9 +69,7 @@ ArgParser::initOptions() ap.addHelpFooter("For more help, read the manual.\n"); ap.addHelpTopic( - "quack", - "Quack Options", - "Just put stuff after quack to get a count at the end.\n"); + "quack", "Quack Options", "Just put stuff after quack to get a count at the end.\n"); ap.addHelpTopic( "baaa", "Baaa Options", @@ -139,8 +135,7 @@ ArgParser::getQuack(std::string const& p) { ++this->quacks; if (this->ap.isCompleting() && (this->ap.argsLeft() == 0)) { - this->ap.insertCompletion( - std::string("thing-") + std::to_string(this->quacks)); + this->ap.insertCompletion(std::string("thing-") + std::to_string(this->quacks)); return; } output(std::string("got quack: ") + p); @@ -178,24 +173,17 @@ ArgParser::test_exceptions() ap.selectOptionTable("baaa"); ap.addBare("ram", []() {}); }); - err("duplicate table", - [this]() { ap.registerOptionTable("baaa", nullptr); }); + err("duplicate table", [this]() { ap.registerOptionTable("baaa", nullptr); }); err("unknown table", [this]() { ap.selectOptionTable("aardvark"); }); - err("add existing help topic", - [this]() { ap.addHelpTopic("baaa", "potato", "salad"); }); - err("add reserved help topic", - [this]() { ap.addHelpTopic("all", "potato", "salad"); }); - err("add to unknown topic", - [this]() { ap.addOptionHelp("--new", "oops", "potato", "salad"); }); - err("bad option for help", - [this]() { ap.addOptionHelp("nodash", "baaa", "potato", "salad"); }); - err("bad topic for help", - [this]() { ap.addHelpTopic("--dashes", "potato", "salad"); }); + err("add existing help topic", [this]() { ap.addHelpTopic("baaa", "potato", "salad"); }); + err("add reserved help topic", [this]() { ap.addHelpTopic("all", "potato", "salad"); }); + err("add to unknown topic", [this]() { ap.addOptionHelp("--new", "oops", "potato", "salad"); }); + err("bad option for help", [this]() { ap.addOptionHelp("nodash", "baaa", "potato", "salad"); }); + err("bad topic for help", [this]() { ap.addHelpTopic("--dashes", "potato", "salad"); }); err("duplicate option help", [this]() { ap.addOptionHelp("--ewe", "baaa", "potato", "salad"); }); - err("invalid choice handler to unknown", [this]() { - ap.addInvalidChoiceHandler("elephant", [](std::string const&) {}); - }); + err("invalid choice handler to unknown", + [this]() { ap.addInvalidChoiceHandler("elephant", [](std::string const&) {}); }); } int diff --git a/libtests/bits.cc b/libtests/bits.cc index e8c8a5c1..96c9ff02 100644 --- a/libtests/bits.cc +++ b/libtests/bits.cc @@ -28,25 +28,19 @@ test_read_bits( size_t& bits_available, size_t bits_wanted) { - unsigned long result = - QIntC::to_ulong(read_bits(p, bit_offset, bits_available, bits_wanted)); + unsigned long result = QIntC::to_ulong(read_bits(p, bit_offset, bits_available, bits_wanted)); - std::cout << "bits read: " << bits_wanted << ", result = " << result - << std::endl; + std::cout << "bits read: " << bits_wanted << ", result = " << result << std::endl; print_values(p - buf, bit_offset, bits_available); } static void test_write_bits( - unsigned char& ch, - size_t& bit_offset, - unsigned long val, - size_t bits, - Pl_Buffer* bp) + unsigned char& ch, size_t& bit_offset, unsigned long val, size_t bits, Pl_Buffer* bp) { write_bits(ch, bit_offset, val, bits, bp); - std::cout << "ch = " << QUtil::uint_to_string_base(ch, 16, 2) - << ", bit_offset = " << bit_offset << std::endl; + std::cout << "ch = " << QUtil::uint_to_string_base(ch, 16, 2) << ", bit_offset = " << bit_offset + << std::endl; } static void @@ -57,8 +51,7 @@ print_buffer(Pl_Buffer* bp) unsigned char const* p = b->getBuffer(); size_t l = b->getSize(); for (unsigned long i = 0; i < l; ++i) { - std::cout << QUtil::uint_to_string_base(p[i], 16, 2) - << ((i == l - 1) ? "\n" : " "); + std::cout << QUtil::uint_to_string_base(p[i], 16, 2) << ((i == l - 1) ? "\n" : " "); } std::cout << std::endl; delete b; @@ -72,8 +65,7 @@ test() // Read tests - static unsigned char const buf[] = { - 0xF5, 0x15, 0x65, 0x79, 0x12, 0x89, 0x75, 0x4B}; + static unsigned char const buf[] = {0xF5, 0x15, 0x65, 0x79, 0x12, 0x89, 0x75, 0x4B}; unsigned char const* p = buf; size_t bit_offset = 7; diff --git a/libtests/concatenate.cc b/libtests/concatenate.cc index 9bc0fd04..380d8cd3 100644 --- a/libtests/concatenate.cc +++ b/libtests/concatenate.cc @@ -29,8 +29,7 @@ main(int argc, char* argv[]) inflate.write(b1_buf->getBuffer(), b1_buf->getSize()); inflate.finish(); auto b2_buf = b2.getBufferSharedPointer(); - std::string result( - reinterpret_cast(b2_buf->getBuffer()), b2_buf->getSize()); + std::string result(reinterpret_cast(b2_buf->getBuffer()), b2_buf->getSize()); if (result == "-one--two-") { std::cout << "concatenate test passed" << std::endl; } else { diff --git a/libtests/cxx11.cc b/libtests/cxx11.cc index 5f0dcc9a..59c74fa8 100644 --- a/libtests/cxx11.cc +++ b/libtests/cxx11.cc @@ -33,8 +33,7 @@ do_functional() x = 7; // change not seen by lambda assert(by_value(1) == 6); // Also >> at end of template - assert((std::is_convertible>:: - value)); + assert((std::is_convertible>::value)); // Capture by reference auto by_reference = [&x](int a) { return a + x; }; diff --git a/libtests/input_source.cc b/libtests/input_source.cc index 9ab41b5d..4111fd65 100644 --- a/libtests/input_source.cc +++ b/libtests/input_source.cc @@ -47,8 +47,7 @@ Finder::check() void check(char const* description, bool expected, bool actual) { - std::cout << description << ": " << ((actual == expected) ? "PASS" : "FAIL") - << std::endl; + std::cout << description << ": " << ((actual == expected) ? "PASS" : "FAIL") << std::endl; } int @@ -61,28 +60,15 @@ main() // Overlap so that the first check() would advance past the start // of the next match memcpy(b + 2037, "potato potato salad ", 20); - auto is = std::shared_ptr( - new BufferInputSource("test buffer input source", b1.get())); + auto is = + std::shared_ptr(new BufferInputSource("test buffer input source", b1.get())); Finder f1(is, "salad"); check("find potato salad", true, is->findFirst("potato", 0, 0, f1)); - check( - "barely find potato salad", - true, - is->findFirst("potato", 1100, 945, f1)); - check( - "barely find potato salad", - true, - is->findFirst("potato", 2000, 45, f1)); - check( - "potato salad is too late", - false, - is->findFirst("potato", 1100, 944, f1)); - check( - "potato salad is too late", - false, - is->findFirst("potato", 2000, 44, f1)); - check( - "potato salad not found", false, is->findFirst("potato", 2045, 0, f1)); + check("barely find potato salad", true, is->findFirst("potato", 1100, 945, f1)); + check("barely find potato salad", true, is->findFirst("potato", 2000, 45, f1)); + check("potato salad is too late", false, is->findFirst("potato", 1100, 944, f1)); + check("potato salad is too late", false, is->findFirst("potato", 2000, 44, f1)); + check("potato salad not found", false, is->findFirst("potato", 2045, 0, f1)); check("potato salad not found", false, is->findFirst("potato", 0, 1, f1)); // Put one more right at EOF @@ -91,18 +77,13 @@ main() is->findFirst("potato", 0, 0, f1); check("findFirst found first", true, is->tell() == 2056); - check( - "findLast found potato salad", true, is->findLast("potato", 0, 0, f1)); + check("findLast found potato salad", true, is->findLast("potato", 0, 0, f1)); check("findLast found at EOF", true, is->tell() == 3172); // Make check() bump into EOF memcpy(b + b1->getSize() - 6, "potato", 6); - check( - "potato but not salad salad at EOF", - false, - is->findFirst("potato", 3000, 0, f1)); - check( - "findLast found potato salad", true, is->findLast("potato", 0, 0, f1)); + check("potato but not salad salad at EOF", false, is->findFirst("potato", 3000, 0, f1)); + check("findLast found potato salad", true, is->findLast("potato", 0, 0, f1)); check("findLast found first one", true, is->tell() == 2056); return 0; diff --git a/libtests/json.cc b/libtests/json.cc index ef9188c5..98e332e7 100644 --- a/libtests/json.cc +++ b/libtests/json.cc @@ -17,8 +17,7 @@ check(JSON const& j, std::string const& exp) static void test_main() { - JSON jstr = JSON::makeString( - "<1>\xcf\x80<2>\xf0\x9f\xa5\x94\\\"<3>\x03\t\b\r\n<4>"); + JSON jstr = JSON::makeString("<1>\xcf\x80<2>\xf0\x9f\xa5\x94\\\"<3>\x03\t\b\r\n<4>"); check( jstr, "\"<1>\xcf\x80<2>\xf0\x9f\xa5\x94\\\\\\\"<3>" @@ -60,8 +59,7 @@ test_main() " 2.1e5\n" "]"); std::vector avalue; - assert(jarr.forEachArrayItem( - [&avalue](JSON j) { avalue.push_back(j.unparse()); })); + assert(jarr.forEachArrayItem([&avalue](JSON j) { avalue.push_back(j.unparse()); })); std::vector xavalue = { "\"a\\tb\"", "null", @@ -79,8 +77,7 @@ test_main() jmap.addDictionaryMember("no", JSON::makeBool(true)); jmap.addDictionaryMember("empty_dict", JSON::makeDictionary()); jmap.addDictionaryMember("empty_list", JSON::makeArray()); - jmap.addDictionaryMember("single", JSON::makeArray()) - .addArrayElement(JSON::makeInt(12)); + jmap.addDictionaryMember("single", JSON::makeArray()).addArrayElement(JSON::makeInt(12)); check( jmap, "{\n" @@ -117,9 +114,7 @@ test_main() {"c", "[\n true\n]"}, }; assert(dvalue == xdvalue); - auto blob_data = [](Pipeline* p) { - *p << "\x01\x02\x03\x04\x05\xff\xfe\xfd\xfc\xfb"; - }; + auto blob_data = [](Pipeline* p) { *p << "\x01\x02\x03\x04\x05\xff\xfe\xfd\xfc\xfb"; }; JSON jblob = JSON::makeDictionary(); jblob.addDictionaryMember("normal", JSON::parse(R"("string")")); jblob.addDictionaryMember("blob", JSON::makeBlob(blob_data)); @@ -133,12 +128,7 @@ test_main() } static void -check_schema( - JSON& obj, - JSON& schema, - unsigned long flags, - bool exp, - std::string const& description) +check_schema(JSON& obj, JSON& schema, unsigned long flags, bool exp, std::string const& description) { std::list errors; std::cout << "--- " << description << std::endl; diff --git a/libtests/json_handler.cc b/libtests/json_handler.cc index 4e610b08..57185c98 100644 --- a/libtests/json_handler.cc +++ b/libtests/json_handler.cc @@ -38,9 +38,7 @@ print_json(std::string const& path, JSON value) static JSONHandler::void_handler_t make_print_message(std::string msg) { - return [msg](std::string const& path) { - std::cout << path << ": json: " << msg << std::endl; - }; + return [msg](std::string const& path) { std::cout << path << ": json: " << msg << std::endl; }; } static void diff --git a/libtests/json_parse.cc b/libtests/json_parse.cc index bd2d49d1..35abb68f 100644 --- a/libtests/json_parse.cc +++ b/libtests/json_parse.cc @@ -74,8 +74,7 @@ Reactor::arrayItem(JSON const& value) void Reactor::printItem(JSON const& j) { - std::cout << "[" << j.getStart() << ", " << j.getEnd() - << "): " << j.unparse() << std::endl; + std::cout << "[" << j.getStart() << ", " << j.getEnd() << "): " << j.unparse() << std::endl; } static void diff --git a/libtests/logger.cc b/libtests/logger.cc index 987e15d3..e17d450d 100644 --- a/libtests/logger.cc +++ b/libtests/logger.cc @@ -25,8 +25,7 @@ test1() logger->saveToStandardOutput(true); assert(false); } catch (std::logic_error& e) { - *(logger->getInfo()) - << "saveToStandardOutput exception: " << e.what() << "\n"; + *(logger->getInfo()) << "saveToStandardOutput exception: " << e.what() << "\n"; } logger->setWarn(logger->discard()); logger->warn("warning not seen\n"); diff --git a/libtests/logger_c.c b/libtests/logger_c.c index c3fa0d8c..4e9883a7 100644 --- a/libtests/logger_c.c +++ b/libtests/logger_c.c @@ -54,15 +54,9 @@ main() qpdflogger_set_error(l, qpdf_log_dest_custom, fn, (void*)error); qpdflogger_set_save(l, qpdf_log_dest_custom, fn, (void*)save, 0); - do_run( - "{\"inputFile\": \"normal.pdf\", \"showNpages\": \"\"}", - qpdf_exit_success); - do_run( - "{\"inputFile\": \"warning.pdf\", \"showNpages\": \"\"}", - qpdf_exit_warning); - do_run( - "{\"inputFile\": \"missing.pdf\", \"showNpages\": \"\"}", - qpdf_exit_error); + do_run("{\"inputFile\": \"normal.pdf\", \"showNpages\": \"\"}", qpdf_exit_success); + do_run("{\"inputFile\": \"warning.pdf\", \"showNpages\": \"\"}", qpdf_exit_warning); + do_run("{\"inputFile\": \"missing.pdf\", \"showNpages\": \"\"}", qpdf_exit_error); do_run( "{\"inputFile\": \"normal.pdf\"," " \"staticId\": \"\"," @@ -79,16 +73,11 @@ main() qpdflogger_set_error(l, qpdf_log_dest_default, NULL, NULL); qpdflogger_set_save(l, qpdf_log_dest_custom, fn, (void*)save2, 0); - do_run( - "{\"inputFile\": \"2pages.pdf\", \"showNpages\": \"\"}", - qpdf_exit_success); - do_run( - "{\"inputFile\": \"warning.pdf\", \"showNpages\": \"\"}", - qpdf_exit_warning); + do_run("{\"inputFile\": \"2pages.pdf\", \"showNpages\": \"\"}", qpdf_exit_success); + do_run("{\"inputFile\": \"warning.pdf\", \"showNpages\": \"\"}", qpdf_exit_warning); do_run( - "{\"inputFile\": \"missing.pdf\", \"showNpages\": \"\"}", - qpdf_exit_error); + "{\"inputFile\": \"missing.pdf\", \"showNpages\": \"\"}", qpdf_exit_error); do_run( "{\"inputFile\": \"attach.pdf\"," " \"showAttachment\": \"a\"}", diff --git a/libtests/lzw.cc b/libtests/lzw.cc index 3a7d003c..3d255b24 100644 --- a/libtests/lzw.cc +++ b/libtests/lzw.cc @@ -15,8 +15,7 @@ main(int argc, char* argv[]) } if (argc < 3) { - std::cerr << "Usage: lzw infile outfile [ --no-early-code-change ]" - << std::endl; + std::cerr << "Usage: lzw infile outfile [ --no-early-code-change ]" << std::endl; exit(2); } diff --git a/libtests/matrix.cc b/libtests/matrix.cc index f69d270c..70380f0e 100644 --- a/libtests/matrix.cc +++ b/libtests/matrix.cc @@ -16,31 +16,21 @@ check(QPDFMatrix const& m, std::string const& exp) static void check_xy(double x, double y, std::string const& exp) { - std::string u = - (QUtil::double_to_string(x, 2) + " " + QUtil::double_to_string(y, 2)); + std::string u = (QUtil::double_to_string(x, 2) + " " + QUtil::double_to_string(y, 2)); if (u != exp) { std::cout << "got " << u << ", wanted " << exp << std::endl; } } static void -check_rect( - QPDFObjectHandle::Rectangle const& r, - double llx, - double lly, - double urx, - double ury) +check_rect(QPDFObjectHandle::Rectangle const& r, double llx, double lly, double urx, double ury) { std::string actual = - (QUtil::double_to_string(r.llx, 2) + " " + - QUtil::double_to_string(r.lly, 2) + " " + - QUtil::double_to_string(r.urx, 2) + " " + - QUtil::double_to_string(r.ury, 2)); + (QUtil::double_to_string(r.llx, 2) + " " + QUtil::double_to_string(r.lly, 2) + " " + + QUtil::double_to_string(r.urx, 2) + " " + QUtil::double_to_string(r.ury, 2)); std::string wanted = - (QUtil::double_to_string(llx, 2) + " " + - QUtil::double_to_string(lly, 2) + " " + - QUtil::double_to_string(urx, 2) + " " + - QUtil::double_to_string(ury, 2)); + (QUtil::double_to_string(llx, 2) + " " + QUtil::double_to_string(lly, 2) + " " + + QUtil::double_to_string(urx, 2) + " " + QUtil::double_to_string(ury, 2)); if (actual != wanted) { std::cout << "got " << actual << ", wanted " << wanted << std::endl; } @@ -80,19 +70,13 @@ main() check_xy(xp, yp, "2582.5 4912"); check( - QPDFMatrix( - QPDFObjectHandle::parse("[3 1 4 1 5 9.26535]").getArrayAsMatrix()), + QPDFMatrix(QPDFObjectHandle::parse("[3 1 4 1 5 9.26535]").getArrayAsMatrix()), "3 1 4 1 5 9.26535"); m = QPDFMatrix(); m.rotatex90(90); m.translate(200, -100); - check_rect( - m.transformRectangle(QPDFObjectHandle::Rectangle(10, 20, 30, 50)), - 50, - 210, - 80, - 230); + check_rect(m.transformRectangle(QPDFObjectHandle::Rectangle(10, 20, 30, 50)), 50, 210, 80, 230); std::cout << "matrix tests done" << std::endl; return 0; diff --git a/libtests/md5.cc b/libtests/md5.cc index 9aed832d..baa59a41 100644 --- a/libtests/md5.cc +++ b/libtests/md5.cc @@ -32,17 +32,11 @@ main(int, char*[]) b.encodeFile("md5.in", 100); std::cout << b.unparse() << std::endl; - std::cout - << MD5::checkDataChecksum("900150983cd24fb0d6963f7d28e17f72", "abc", 3) - << std::endl - << MD5::checkFileChecksum("5f4b4321873433daae578f85c72f9e74", "md5.in") - << std::endl - << MD5::checkFileChecksum("6f4b4321873433daae578f85c72f9e74", "md5.in") - << std::endl - << MD5::checkDataChecksum("000150983cd24fb0d6963f7d28e17f72", "abc", 3) - << std::endl - << MD5::checkFileChecksum("6f4b4321873433daae578f85c72f9e74", "glerbl") - << std::endl; + std::cout << MD5::checkDataChecksum("900150983cd24fb0d6963f7d28e17f72", "abc", 3) << std::endl + << MD5::checkFileChecksum("5f4b4321873433daae578f85c72f9e74", "md5.in") << std::endl + << MD5::checkFileChecksum("6f4b4321873433daae578f85c72f9e74", "md5.in") << std::endl + << MD5::checkDataChecksum("000150983cd24fb0d6963f7d28e17f72", "abc", 3) << std::endl + << MD5::checkFileChecksum("6f4b4321873433daae578f85c72f9e74", "glerbl") << std::endl; Pl_Discard d; Pl_MD5 p("MD5", &d); diff --git a/libtests/nntree.cc b/libtests/nntree.cc index 335da857..c2b35dc0 100644 --- a/libtests/nntree.cc +++ b/libtests/nntree.cc @@ -20,15 +20,12 @@ report(QPDF& q, QPDFObjectHandle oh, long long item, long long exp_item) auto show = [&failed, &oh, &item]() { if (!failed) { failed = true; - std::cout << "key = " << item << ", oh = " << oh.unparseResolved() - << std::endl; + std::cout << "key = " << item << ", oh = " << oh.unparseResolved() << std::endl; } }; auto mk_wanted = [](long long i) { - return ( - (i == -1) ? "end" - : (std::to_string(i) + "/(-" + std::to_string(i) + "-)")); + return ((i == -1) ? "end" : (std::to_string(i) + "/(-" + std::to_string(i) + "-)")); }; std::string i1_wanted = mk_wanted(exp_item); std::string i2_wanted = mk_wanted(item == exp_item ? item : -1); @@ -40,13 +37,11 @@ report(QPDF& q, QPDFObjectHandle oh, long long item, long long exp_item) if (i1_wanted != i1_actual) { show(); - std::cout << "i1: wanted " << i1_wanted << ", got " << i1_actual - << std::endl; + std::cout << "i1: wanted " << i1_wanted << ", got " << i1_actual << std::endl; } if (i2_wanted != i2_actual) { show(); - std::cout << "i2: wanted " << i2_wanted << ", got " << i2_actual - << std::endl; + std::cout << "i2: wanted " << i2_wanted << ", got " << i2_actual << std::endl; } return failed; @@ -62,8 +57,7 @@ test_bsearch() auto nums = QPDFObjectHandle::newArray(); for (auto i: v) { nums.appendItem(QPDFObjectHandle::newInteger(i)); - nums.appendItem( - QPDFObjectHandle::newString("-" + std::to_string(i) + "-")); + nums.appendItem(QPDFObjectHandle::newString("-" + std::to_string(i) + "-")); } auto limits = QPDFObjectHandle::newArray(); limits.appendItem(QPDFObjectHandle::newInteger(v.at(0))); @@ -125,10 +119,7 @@ new_node(QPDF& q, std::string const& key) } static void -check_find( - QPDFNameTreeObjectHelper& nh, - std::string const& key, - bool prev_if_not_found) +check_find(QPDFNameTreeObjectHelper& nh, std::string const& key, bool prev_if_not_found) { auto i = nh.find(key, prev_if_not_found); std::cout << "find " << key << " (" << prev_if_not_found << "): "; @@ -165,8 +156,7 @@ test_depth() std::string first; std::string last; for (int i4 = 0; i4 < NITEMS; ++i4) { - int val = - (((((i1 * NITEMS) + i2) * NITEMS) + i3) * NITEMS) + i4; + int val = (((((i1 * NITEMS) + i2) * NITEMS) + i3) * NITEMS) + i4; std::string str = QUtil::int_to_string(10 * val, 6); items.appendItem(QPDFObjectHandle::newString(str)); items.appendItem(QPDFObjectHandle::newString("val " + str)); @@ -183,16 +173,13 @@ test_depth() } auto limits = QPDFObjectHandle::newArray(); n2.replaceKey("/Limits", limits); - limits.appendItem( - k2.getArrayItem(0).getKey("/Limits").getArrayItem(0)); - limits.appendItem( - k2.getArrayItem(NITEMS - 1).getKey("/Limits").getArrayItem(1)); + limits.appendItem(k2.getArrayItem(0).getKey("/Limits").getArrayItem(0)); + limits.appendItem(k2.getArrayItem(NITEMS - 1).getKey("/Limits").getArrayItem(1)); } auto limits = QPDFObjectHandle::newArray(); n1.replaceKey("/Limits", limits); limits.appendItem(k1.getArrayItem(0).getKey("/Limits").getArrayItem(0)); - limits.appendItem( - k1.getArrayItem(NITEMS - 1).getKey("/Limits").getArrayItem(1)); + limits.appendItem(k1.getArrayItem(NITEMS - 1).getKey("/Limits").getArrayItem(1)); } QPDFNameTreeObjectHelper nh(n0, q); diff --git a/libtests/pointer_holder.cc b/libtests/pointer_holder.cc index 4b9d43cb..641cd0bb 100644 --- a/libtests/pointer_holder.cc +++ b/libtests/pointer_holder.cc @@ -185,8 +185,7 @@ ph_sp_compat() PointerHolder arr1_ph; { std::cout << "initialize ph array from shared_ptr" << std::endl; - std::shared_ptr arr1( - new Object[2], std::default_delete()); + std::shared_ptr arr1(new Object[2], std::default_delete()); arr1_ph = arr1; } std::cout << "delete ph array" << std::endl; diff --git a/libtests/qintc.cc b/libtests/qintc.cc index 52a1e91e..d360dd45 100644 --- a/libtests/qintc.cc +++ b/libtests/qintc.cc @@ -3,16 +3,11 @@ #include #include -#define try_convert(exp_pass, fn, i) \ - try_convert_real(#fn "(" #i ")", exp_pass, fn, i) +#define try_convert(exp_pass, fn, i) try_convert_real(#fn "(" #i ")", exp_pass, fn, i) template static void -try_convert_real( - char const* description, - bool exp_pass, - To (*fn)(From const&), - From const& i) +try_convert_real(char const* description, bool exp_pass, To (*fn)(From const&), From const& i) { bool passed = false; try { @@ -26,13 +21,11 @@ try_convert_real( std::cout << ((passed == exp_pass) ? " PASSED" : " FAILED") << std::endl; } -#define try_range_check(exp_pass, a, b) \ - try_range_check_real(#a " + " #b, exp_pass, a, b) +#define try_range_check(exp_pass, a, b) try_range_check_real(#a " + " #b, exp_pass, a, b) template static void -try_range_check_real( - char const* description, bool exp_pass, T const& a, T const& b) +try_range_check_real(char const* description, bool exp_pass, T const& a, T const& b) { bool passed = false; try { @@ -51,8 +44,7 @@ try_range_check_real( template static void -try_range_check_subtract_real( - char const* description, bool exp_pass, T const& a, T const& b) +try_range_check_subtract_real(char const* description, bool exp_pass, T const& a, T const& b) { bool passed = false; try { @@ -75,7 +67,7 @@ main() uint64_t ul2 = 12345; // Fits into 32-bit int32_t i2 = 81; // Fits in char and uchar auto c1 = static_cast('\xf7'); // Signed value when char - char c2 = 'W'; // char; may be signed or unsigned + char c2 = 'W'; // char; may be signed or unsigned // Verify i1 and u1 have same bit pattern assert(static_cast(i1) == u1); diff --git a/libtests/qutil.cc b/libtests/qutil.cc index a1bbb905..e882a33a 100644 --- a/libtests/qutil.cc +++ b/libtests/qutil.cc @@ -17,8 +17,7 @@ template void -test_to_number( - char const* str, int_T wanted, bool error, int_T (*fn)(char const*)) +test_to_number(char const* str, int_T wanted, bool error, int_T (*fn)(char const*)) { bool threw = false; bool worked = false; @@ -33,11 +32,9 @@ test_to_number( } if (threw) { if (error) { - std::cout << str << " to int threw (" << msg << "): PASSED" - << std::endl; + std::cout << str << " to int threw (" << msg << "): PASSED" << std::endl; } else { - std::cout << str << " to int threw but wanted " << wanted - << std::endl; + std::cout << str << " to int threw but wanted " << wanted << std::endl; } } else { if (worked) { @@ -203,11 +200,10 @@ void getenv_test() { std::string val; - std::cout << "IN_TESTSUITE: " << QUtil::get_env("IN_TESTSUITE", &val) - << ": " << val << std::endl; - // Hopefully this environment variable is not defined. - std::cout << "HAGOOGAMAGOOGLE: " << QUtil::get_env("HAGOOGAMAGOOGLE") + std::cout << "IN_TESTSUITE: " << QUtil::get_env("IN_TESTSUITE", &val) << ": " << val << std::endl; + // Hopefully this environment variable is not defined. + std::cout << "HAGOOGAMAGOOGLE: " << QUtil::get_env("HAGOOGAMAGOOGLE") << std::endl; } static void @@ -224,9 +220,7 @@ print_utf8(unsigned long val) for (auto const& ch: result) { std::cout << " " << QUtil::int_to_string_base( - static_cast(static_cast(ch)), - 16, - 2); + static_cast(static_cast(ch)), 16, 2); } } std::cout << std::endl; @@ -282,9 +276,7 @@ print_utf16(unsigned long val) for (auto const& ch: result) { std::cout << " " << QUtil::int_to_string_base( - static_cast(static_cast(ch)), - 16, - 2); + static_cast(static_cast(ch)), 16, 2); } std::cout << std::endl; } @@ -303,8 +295,7 @@ to_utf16_test() std::string s(QUtil::utf8_to_utf16("\xcf\x80")); std::cout << QUtil::utf16_to_utf8(s) << std::endl; std::cout << QUtil::utf16_to_utf8(s + ".") << std::endl; - std::cout << "LE: " << QUtil::utf16_to_utf8("\xff\xfe\xc0\x03") - << std::endl; + std::cout << "LE: " << QUtil::utf16_to_utf8("\xff\xfe\xc0\x03") << std::endl; } void @@ -316,13 +307,10 @@ utf8_to_ascii_test() << QUtil::utf8_to_ascii(input, '*') << std::endl; std::string a = QUtil::utf8_to_win_ansi(input, '*'); std::string b = QUtil::utf8_to_mac_roman(input, '*'); - std::cout - << "<" - << QUtil::int_to_string_base(static_cast(a.at(0)), 16, 2) - << ">" << a.substr(1) << std::endl - << "<" - << QUtil::int_to_string_base(static_cast(b.at(0)), 16, 2) - << ">" << b.substr(1) << std::endl; + std::cout << "<" << QUtil::int_to_string_base(static_cast(a.at(0)), 16, 2) << ">" + << a.substr(1) << std::endl + << "<" << QUtil::int_to_string_base(static_cast(b.at(0)), 16, 2) << ">" + << b.substr(1) << std::endl; } void @@ -342,8 +330,8 @@ transcoding_test( std::string wanted = (out == "\xef\xbf\xbd") ? unknown : in; back = (*from_utf8)(out, '?'); if (back != wanted) { - std::cout << i << ": " << in << " -> " << out << " -> " << back - << " (wanted " << wanted << ")" << std::endl; + std::cout << i << ": " << in << " -> " << out << " -> " << back << " (wanted " << wanted + << ")" << std::endl; } } } @@ -355,8 +343,7 @@ check_analyze(std::string const& str, bool has8bit, bool utf8, bool utf16) bool is_valid_utf8 = false; bool is_utf16 = false; QUtil::analyze_encoding(str, has_8bit_chars, is_valid_utf8, is_utf16); - if (!((has_8bit_chars == has8bit) && (is_valid_utf8 == utf8) && - (is_utf16 == utf16))) { + if (!((has_8bit_chars == has8bit) && (is_valid_utf8 == utf8) && (is_utf16 == utf16))) { std::cout << "analysis failed: " << str << std::endl; } } @@ -374,17 +361,13 @@ print_alternatives(std::string const& str) void transcoding_test() { - transcoding_test( - &QUtil::pdf_doc_to_utf8, &QUtil::utf8_to_pdf_doc, 127, 160, "\x9f"); + transcoding_test(&QUtil::pdf_doc_to_utf8, &QUtil::utf8_to_pdf_doc, 127, 160, "\x9f"); std::cout << "bidirectional pdf doc done" << std::endl; - transcoding_test( - &QUtil::pdf_doc_to_utf8, &QUtil::utf8_to_pdf_doc, 24, 31, "?"); + transcoding_test(&QUtil::pdf_doc_to_utf8, &QUtil::utf8_to_pdf_doc, 24, 31, "?"); std::cout << "bidirectional pdf doc low done" << std::endl; - transcoding_test( - &QUtil::win_ansi_to_utf8, &QUtil::utf8_to_win_ansi, 128, 160, "?"); + transcoding_test(&QUtil::win_ansi_to_utf8, &QUtil::utf8_to_win_ansi, 128, 160, "?"); std::cout << "bidirectional win ansi done" << std::endl; - transcoding_test( - &QUtil::mac_roman_to_utf8, &QUtil::utf8_to_mac_roman, 128, 255, "?"); + transcoding_test(&QUtil::mac_roman_to_utf8, &QUtil::utf8_to_mac_roman, 128, 255, "?"); std::cout << "bidirectional mac roman done" << std::endl; check_analyze("pi = \317\200", true, true, false); check_analyze("pi != \317", true, false, false); @@ -426,8 +409,7 @@ transcoding_test() // cSpell: ignore xadw std::string other_doc = other + "\x9fw\xadw"; std::cout << QUtil::pdf_doc_to_utf8(other_doc) << std::endl; - std::string other_utf8 = - other + QUtil::toUTF8(0x9f) + "w" + QUtil::toUTF8(0xad) + "w"; + std::string other_utf8 = other + QUtil::toUTF8(0x9f) + "w" + QUtil::toUTF8(0xad) + "w"; std::string other_to_utf8; assert(!QUtil::utf8_to_pdf_doc(other_utf8, other_to_utf8)); std::cout << other_to_utf8 << std::endl; @@ -533,8 +515,7 @@ read_from_file_test() } // Test with EOL preservation - std::list lines2 = - QUtil::read_lines_from_file("other-file", true); + std::list lines2 = QUtil::read_lines_from_file("other-file", true); auto line = lines2.begin(); assert(37 == (*line).length()); assert('.' == (*line).at(35)); @@ -693,8 +674,8 @@ timestamp_test() // Round trip on the current time without actually printing it. // Manual testing was done to ensure that we are actually getting // back the current time in various time zones. - assert(QUtil::pdf_time_to_qpdf_time( - QUtil::qpdf_time_to_pdf_time(QUtil::get_current_qpdf_time()))); + assert( + QUtil::pdf_time_to_qpdf_time(QUtil::qpdf_time_to_pdf_time(QUtil::get_current_qpdf_time()))); } void diff --git a/libtests/runlength.cc b/libtests/runlength.cc index e034deda..293aee2e 100644 --- a/libtests/runlength.cc +++ b/libtests/runlength.cc @@ -11,8 +11,7 @@ int main(int argc, char* argv[]) { if (argc != 4) { - std::cerr << "Usage: runlength {-encode|-decode} infile outfile" - << std::endl; + std::cerr << "Usage: runlength {-encode|-decode} infile outfile" << std::endl; exit(2); } @@ -25,10 +24,7 @@ main(int argc, char* argv[]) Pl_StdioFile out("stdout", outfile); unsigned char buf[100]; bool done = false; - Pl_RunLength rl( - "runlength", - &out, - (encode ? Pl_RunLength::a_encode : Pl_RunLength::a_decode)); + Pl_RunLength rl("runlength", &out, (encode ? Pl_RunLength::a_encode : Pl_RunLength::a_decode)); while (!done) { size_t len = fread(buf, 1, sizeof(buf), infile); if (len <= 0) { diff --git a/libtests/sha2.cc b/libtests/sha2.cc index 22303da2..3d8675a9 100644 --- a/libtests/sha2.cc +++ b/libtests/sha2.cc @@ -4,12 +4,7 @@ #include static void -test( - Pl_SHA2& sha2, - char const* description, - int bits, - char const* input, - std::string const& output) +test(Pl_SHA2& sha2, char const* description, int bits, char const* input, std::string const& output) { sha2.resetBits(bits); sha2.write(QUtil::unsigned_char_pointer(input), strlen(input)); -- cgit v1.2.3-70-g09d2