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/buffer.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/buffer.cc')
-rw-r--r-- | libtests/buffer.cc | 37 |
1 files changed, 14 insertions, 23 deletions
diff --git a/libtests/buffer.cc b/libtests/buffer.cc index 5dfe55f8..a24c0f99 100644 --- a/libtests/buffer.cc +++ b/libtests/buffer.cc @@ -2,10 +2,10 @@ #include <qpdf/Pl_Count.hh> #include <qpdf/Pl_Discard.hh> #include <qpdf/QUtil.hh> -#include <stdlib.h> -#include <stdexcept> -#include <iostream> #include <cstring> +#include <iostream> +#include <stdexcept> +#include <stdlib.h> #ifdef NDEBUG // We need assert even in a release build for test code. @@ -13,12 +13,14 @@ #endif #include <cassert> -static unsigned char* uc(char const* s) +static unsigned char* +uc(char const* s) { return QUtil::unsigned_char_pointer(s); } -int main() +int +main() { { // Test that buffers can be copied by value. @@ -39,8 +41,7 @@ int main() assert(bc2p[1] == 'W'); } - try - { + try { Pl_Discard discard; Pl_Count count("count", &discard); Pl_Buffer bp1("bp1", &count); @@ -68,12 +69,9 @@ int main() Pl_Buffer bp2("bp2"); bp2.write(uc("moo"), 3); bp2.write(uc("quack"), 6); - try - { + try { delete bp2.getBuffer(); - } - catch (std::exception& e) - { + } catch (std::exception& e) { std::cout << e.what() << std::endl; } bp2.finish(); @@ -84,9 +82,7 @@ int main() unsigned char lbuf[10]; Buffer b1(lbuf, 10); - if (! ((b1.getBuffer() == lbuf) && - (b1.getSize() == 10))) - { + if (!((b1.getBuffer() == lbuf) && (b1.getSize() == 10))) { throw std::logic_error("hand-created buffer is not as expected"); } @@ -110,13 +106,10 @@ int main() bp4.write(uc("asdf"), 4); unsigned char* mbuf; size_t len; - try - { + try { bp4.getMallocBuffer(&mbuf, &len); assert(false); - } - catch (std::logic_error& e) - { + } catch (std::logic_error& e) { std::cout << "malloc buffer logic error: " << e.what() << std::endl; } bp4.finish(); @@ -129,9 +122,7 @@ int main() bp4.getMallocBuffer(&mbuf, &len); assert(mbuf == nullptr); assert(len == 0); - } - catch (std::exception& e) - { + } catch (std::exception& e) { std::cout << "unexpected exception: " << e.what() << std::endl; exit(2); } |