Commit 17c0e38c8efa7882f8e6a13c6030edf3e768257c
1 parent
066efb69
Force assert to be defined in test code
Showing
18 changed files
with
97 additions
and
13 deletions
libtests/arg_parser.cc
libtests/buffer.cc
| ... | ... | @@ -5,9 +5,14 @@ |
| 5 | 5 | #include <stdlib.h> |
| 6 | 6 | #include <stdexcept> |
| 7 | 7 | #include <iostream> |
| 8 | -#include <cassert> | |
| 9 | 8 | #include <cstring> |
| 10 | 9 | |
| 10 | +#ifdef NDEBUG | |
| 11 | +// We need assert even in a release build for test code. | |
| 12 | +# undef NDEBUG | |
| 13 | +#endif | |
| 14 | +#include <cassert> | |
| 15 | + | |
| 11 | 16 | static unsigned char* uc(char const* s) |
| 12 | 17 | { |
| 13 | 18 | return QUtil::unsigned_char_pointer(s); | ... | ... |
libtests/concatenate.cc
| ... | ... | @@ -3,7 +3,12 @@ |
| 3 | 3 | #include <qpdf/Pl_Buffer.hh> |
| 4 | 4 | #include <qpdf/QUtil.hh> |
| 5 | 5 | #include <iostream> |
| 6 | -#include <assert.h> | |
| 6 | + | |
| 7 | +#ifdef NDEBUG | |
| 8 | +// We need assert even in a release build for test code. | |
| 9 | +# undef NDEBUG | |
| 10 | +#endif | |
| 11 | +#include <cassert> | |
| 7 | 12 | |
| 8 | 13 | static void pipeStringAndFinish(Pipeline* p, std::string const& str) |
| 9 | 14 | { | ... | ... |
libtests/cxx11.cc
| 1 | 1 | #include <iostream> |
| 2 | -#include <cassert> | |
| 3 | 2 | #include <cstring> |
| 4 | 3 | #include <cstdlib> |
| 5 | 4 | #include <functional> |
| ... | ... | @@ -10,6 +9,12 @@ |
| 10 | 9 | #include <memory> |
| 11 | 10 | #include <regex> |
| 12 | 11 | |
| 12 | +#ifdef NDEBUG | |
| 13 | +// We need assert even in a release build for test code. | |
| 14 | +# undef NDEBUG | |
| 15 | +#endif | |
| 16 | +#include <cassert> | |
| 17 | + | |
| 13 | 18 | // Functional programming |
| 14 | 19 | |
| 15 | 20 | // Function that returns a callable in the form of a lambda | ... | ... |
libtests/json.cc
libtests/json_handler.cc
| ... | ... | @@ -2,6 +2,11 @@ |
| 2 | 2 | #include <qpdf/QUtil.hh> |
| 3 | 3 | #include <qpdf/QPDFUsage.hh> |
| 4 | 4 | #include <iostream> |
| 5 | + | |
| 6 | +#ifdef NDEBUG | |
| 7 | +// We need assert even in a release build for test code. | |
| 8 | +# undef NDEBUG | |
| 9 | +#endif | |
| 5 | 10 | #include <cassert> |
| 6 | 11 | |
| 7 | 12 | static void print_null(std::string const& path) | ... | ... |
libtests/matrix.cc
| 1 | 1 | #include <qpdf/QPDFMatrix.hh> |
| 2 | 2 | #include <qpdf/QUtil.hh> |
| 3 | -#include <assert.h> | |
| 4 | 3 | #include <iostream> |
| 5 | 4 | |
| 5 | +#ifdef NDEBUG | |
| 6 | +// We need assert even in a release build for test code. | |
| 7 | +# undef NDEBUG | |
| 8 | +#endif | |
| 9 | +#include <cassert> | |
| 10 | + | |
| 6 | 11 | static void check(QPDFMatrix const& m, std::string const& exp) |
| 7 | 12 | { |
| 8 | 13 | std::string u = m.unparse(); | ... | ... |
libtests/pdf_version.cc
libtests/predictors.cc
| ... | ... | @@ -6,10 +6,15 @@ |
| 6 | 6 | |
| 7 | 7 | #include <iostream> |
| 8 | 8 | #include <errno.h> |
| 9 | -#include <assert.h> | |
| 10 | 9 | #include <string.h> |
| 11 | 10 | #include <stdlib.h> |
| 12 | 11 | |
| 12 | +#ifdef NDEBUG | |
| 13 | +// We need assert even in a release build for test code. | |
| 14 | +# undef NDEBUG | |
| 15 | +#endif | |
| 16 | +#include <cassert> | |
| 17 | + | |
| 13 | 18 | void run(char const* filename, char const* filter, |
| 14 | 19 | bool encode, unsigned int columns, |
| 15 | 20 | unsigned int bits_per_sample, unsigned int samples_per_pixel) | ... | ... |
libtests/qintc.cc
libtests/qutil.cc
| ... | ... | @@ -9,7 +9,6 @@ |
| 9 | 9 | #include <qpdf/Pl_Buffer.hh> |
| 10 | 10 | #include <string.h> |
| 11 | 11 | #include <limits.h> |
| 12 | -#include <assert.h> | |
| 13 | 12 | #include <fstream> |
| 14 | 13 | #include <locale> |
| 15 | 14 | |
| ... | ... | @@ -19,6 +18,12 @@ |
| 19 | 18 | # include <unistd.h> |
| 20 | 19 | #endif |
| 21 | 20 | |
| 21 | +#ifdef NDEBUG | |
| 22 | +// We need assert even in a release build for test code. | |
| 23 | +# undef NDEBUG | |
| 24 | +#endif | |
| 25 | +#include <cassert> | |
| 26 | + | |
| 22 | 27 | template <class int_T> |
| 23 | 28 | void test_to_number(char const* str, int_T wanted, bool error, |
| 24 | 29 | int_T (*fn)(char const*)) | ... | ... |
libtests/rc4.cc
libtests/sparse_array.cc
qpdf/pdf_from_scratch.cc
qpdf/qpdf-ctest.c
| 1 | 1 | #include <qpdf/qpdf-c.h> |
| 2 | 2 | #include <stdio.h> |
| 3 | -#include <assert.h> | |
| 4 | 3 | #include <stdlib.h> |
| 5 | 4 | #include <string.h> |
| 6 | 5 | #include <errno.h> |
| 7 | 6 | |
| 8 | 7 | #include <qpdf/qpdf-config.h> // for LL_FMT -- special case in build |
| 9 | 8 | |
| 9 | +#ifdef NDEBUG | |
| 10 | +/* We need assert even in a release build for test code. */ | |
| 11 | +# undef NDEBUG | |
| 12 | +#endif | |
| 13 | +#include <assert.h> | |
| 14 | + | |
| 10 | 15 | static char* whoami = 0; |
| 11 | 16 | static qpdf_data qpdf = 0; |
| 12 | 17 | ... | ... |
qpdf/qpdfjob-ctest.c
| 1 | 1 | #include <qpdf/qpdfjob-c.h> |
| 2 | 2 | #include <stdio.h> |
| 3 | -#include <assert.h> | |
| 4 | 3 | #include <stdlib.h> |
| 5 | 4 | #include <string.h> |
| 6 | 5 | |
| 6 | +#ifdef NDEBUG | |
| 7 | +/* We need assert even in a release build for test code. */ | |
| 8 | +# undef NDEBUG | |
| 9 | +#endif | |
| 10 | +#include <assert.h> | |
| 11 | + | |
| 7 | 12 | #ifndef QPDF_NO_WCHAR_T |
| 8 | 13 | static void wide_test() |
| 9 | 14 | { | ... | ... |
qpdf/test_driver.cc
| ... | ... | @@ -28,10 +28,15 @@ |
| 28 | 28 | #include <stdio.h> |
| 29 | 29 | #include <string.h> |
| 30 | 30 | #include <stdlib.h> |
| 31 | -#include <assert.h> | |
| 32 | 31 | #include <limits.h> |
| 33 | 32 | #include <map> |
| 34 | 33 | |
| 34 | +#ifdef NDEBUG | |
| 35 | +// We need assert even in a release build for test code. | |
| 36 | +# undef NDEBUG | |
| 37 | +#endif | |
| 38 | +#include <cassert> | |
| 39 | + | |
| 35 | 40 | static char const* whoami = 0; |
| 36 | 41 | |
| 37 | 42 | void usage() | ... | ... |
qpdf/test_large_file.cc
| ... | ... | @@ -13,7 +13,12 @@ |
| 13 | 13 | #include <iostream> |
| 14 | 14 | #include <string.h> |
| 15 | 15 | #include <stdlib.h> |
| 16 | -#include <assert.h> | |
| 16 | + | |
| 17 | +#ifdef NDEBUG | |
| 18 | +// We need assert even in a release build for test code. | |
| 19 | +# undef NDEBUG | |
| 20 | +#endif | |
| 21 | +#include <cassert> | |
| 17 | 22 | |
| 18 | 23 | // Run "test_large_file write small a.pdf" to get a PDF file that you |
| 19 | 24 | // can look at in a reader. | ... | ... |