aboutsummaryrefslogtreecommitdiffstats
path: root/libtests/buffer.cc
diff options
context:
space:
mode:
Diffstat (limited to 'libtests/buffer.cc')
-rw-r--r--libtests/buffer.cc37
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);
}