diff options
author | Jay Berkenbilt <ejb@ql.org> | 2022-04-02 23:14:10 +0200 |
---|---|---|
committer | Jay Berkenbilt <ejb@ql.org> | 2022-04-04 14:10:40 +0200 |
commit | 12f1eb15ca3fed6310402847559a7c99d3c77847 (patch) | |
tree | 8935675b623c6f3b4914b8b44f7fa5f2816a9241 /libtests/input_source.cc | |
parent | f20fa61eb4c323eb1642c69c236b3d9a1f8b2cdb (diff) | |
download | qpdf-12f1eb15ca3fed6310402847559a7c99d3c77847.tar.zst |
Programmatically apply new formatting to code
Run this:
for i in **/*.cc **/*.c **/*.h **/*.hh; do
clang-format < $i >| $i.new && mv $i.new $i
done
Diffstat (limited to 'libtests/input_source.cc')
-rw-r--r-- | libtests/input_source.cc | 79 |
1 files changed, 41 insertions, 38 deletions
diff --git a/libtests/input_source.cc b/libtests/input_source.cc index 9e72bbf6..cb62daea 100644 --- a/libtests/input_source.cc +++ b/libtests/input_source.cc @@ -1,9 +1,9 @@ +#include <qpdf/Buffer.hh> #include <qpdf/BufferInputSource.hh> #include <qpdf/PointerHolder.hh> -#include <qpdf/Buffer.hh> #include <qpdf/QPDFTokenizer.hh> -#include <iostream> #include <cstring> +#include <iostream> static PointerHolder<Buffer> get_buffer() @@ -11,8 +11,7 @@ get_buffer() size_t size = 3172; PointerHolder<Buffer> b(new Buffer(size)); unsigned char* p = b->getBuffer(); - for (size_t i = 0; i < size; ++i) - { + for (size_t i = 0; i < size; ++i) { p[i] = static_cast<unsigned char>(i & 0xff); } return b; @@ -41,22 +40,22 @@ Finder::check() { QPDFTokenizer tokenizer; QPDFTokenizer::Token t = tokenizer.readToken(is, "finder", true); - if (t == QPDFTokenizer::Token(QPDFTokenizer::tt_word, "potato")) - { + if (t == QPDFTokenizer::Token(QPDFTokenizer::tt_word, "potato")) { t = tokenizer.readToken(is, "finder", true); return (t == QPDFTokenizer::Token(QPDFTokenizer::tt_word, after)); } return false; } -void check(char const* description, bool expected, bool actual) +void +check(char const* description, bool expected, bool actual) { - std::cout << description << ": " - << ((actual == expected) ? "PASS" : "FAIL") + std::cout << description << ": " << ((actual == expected) ? "PASS" : "FAIL") << std::endl; } -int main() +int +main() { PointerHolder<Buffer> b1 = get_buffer(); unsigned char* b = b1->getBuffer(); @@ -68,42 +67,46 @@ int main() auto is = PointerHolder<InputSource>( 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("potato salad not found", false, - is->findFirst("potato", 0, 1, f1)); + 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("potato salad not found", false, is->findFirst("potato", 0, 1, f1)); // Put one more right at EOF memcpy(b + b1->getSize() - 12, "potato salad", 12); - check("potato salad at EOF", true, - is->findFirst("potato", 3000, 0, f1)); + check("potato salad at EOF", true, is->findFirst("potato", 3000, 0, f1)); 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 at EOF", true, - is->tell() == 3172); + check("findFirst found first", true, is->tell() == 2056); + 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("findLast found first one", true, - is->tell() == 2056); + 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; } |