diff options
author | Jay Berkenbilt <ejb@ql.org> | 2022-03-07 14:46:53 +0100 |
---|---|---|
committer | Jay Berkenbilt <ejb@ql.org> | 2022-03-07 16:07:27 +0100 |
commit | 17c0e38c8efa7882f8e6a13c6030edf3e768257c (patch) | |
tree | 12e4a483fa885fdf55998d4ead5200da293a4829 /libtests | |
parent | 066efb69aec4aa1a62ecf56902a5f4f3d2c73bd5 (diff) | |
download | qpdf-17c0e38c8efa7882f8e6a13c6030edf3e768257c.tar.zst |
Force assert to be defined in test code
Diffstat (limited to 'libtests')
-rw-r--r-- | libtests/arg_parser.cc | 5 | ||||
-rw-r--r-- | libtests/buffer.cc | 7 | ||||
-rw-r--r-- | libtests/concatenate.cc | 7 | ||||
-rw-r--r-- | libtests/cxx11.cc | 7 | ||||
-rw-r--r-- | libtests/json.cc | 5 | ||||
-rw-r--r-- | libtests/json_handler.cc | 5 | ||||
-rw-r--r-- | libtests/matrix.cc | 7 | ||||
-rw-r--r-- | libtests/pdf_version.cc | 7 | ||||
-rw-r--r-- | libtests/predictors.cc | 7 | ||||
-rw-r--r-- | libtests/qintc.cc | 5 | ||||
-rw-r--r-- | libtests/qutil.cc | 7 | ||||
-rw-r--r-- | libtests/rc4.cc | 5 | ||||
-rw-r--r-- | libtests/sparse_array.cc | 7 |
13 files changed, 73 insertions, 8 deletions
diff --git a/libtests/arg_parser.cc b/libtests/arg_parser.cc index 0c7e6787..4b10709e 100644 --- a/libtests/arg_parser.cc +++ b/libtests/arg_parser.cc @@ -3,6 +3,11 @@ #include <qpdf/QPDFUsage.hh> #include <iostream> #include <cstring> + +#ifdef NDEBUG +// We need assert even in a release build for test code. +# undef NDEBUG +#endif #include <cassert> class ArgParser diff --git a/libtests/buffer.cc b/libtests/buffer.cc index ea36a807..5dfe55f8 100644 --- a/libtests/buffer.cc +++ b/libtests/buffer.cc @@ -5,9 +5,14 @@ #include <stdlib.h> #include <stdexcept> #include <iostream> -#include <cassert> #include <cstring> +#ifdef NDEBUG +// We need assert even in a release build for test code. +# undef NDEBUG +#endif +#include <cassert> + static unsigned char* uc(char const* s) { return QUtil::unsigned_char_pointer(s); diff --git a/libtests/concatenate.cc b/libtests/concatenate.cc index 16850d03..84fee2bb 100644 --- a/libtests/concatenate.cc +++ b/libtests/concatenate.cc @@ -3,7 +3,12 @@ #include <qpdf/Pl_Buffer.hh> #include <qpdf/QUtil.hh> #include <iostream> -#include <assert.h> + +#ifdef NDEBUG +// We need assert even in a release build for test code. +# undef NDEBUG +#endif +#include <cassert> static void pipeStringAndFinish(Pipeline* p, std::string const& str) { diff --git a/libtests/cxx11.cc b/libtests/cxx11.cc index bc14b5c0..5ad3e6ed 100644 --- a/libtests/cxx11.cc +++ b/libtests/cxx11.cc @@ -1,5 +1,4 @@ #include <iostream> -#include <cassert> #include <cstring> #include <cstdlib> #include <functional> @@ -10,6 +9,12 @@ #include <memory> #include <regex> +#ifdef NDEBUG +// We need assert even in a release build for test code. +# undef NDEBUG +#endif +#include <cassert> + // Functional programming // Function that returns a callable in the form of a lambda diff --git a/libtests/json.cc b/libtests/json.cc index c37af0e8..a8c72a3b 100644 --- a/libtests/json.cc +++ b/libtests/json.cc @@ -1,6 +1,11 @@ #include <qpdf/JSON.hh> #include <qpdf/QPDFObjectHandle.hh> #include <iostream> + +#ifdef NDEBUG +// We need assert even in a release build for test code. +# undef NDEBUG +#endif #include <cassert> static void check(JSON const& j, std::string const& exp) diff --git a/libtests/json_handler.cc b/libtests/json_handler.cc index 568677a8..6e894e11 100644 --- a/libtests/json_handler.cc +++ b/libtests/json_handler.cc @@ -2,6 +2,11 @@ #include <qpdf/QUtil.hh> #include <qpdf/QPDFUsage.hh> #include <iostream> + +#ifdef NDEBUG +// We need assert even in a release build for test code. +# undef NDEBUG +#endif #include <cassert> static void print_null(std::string const& path) diff --git a/libtests/matrix.cc b/libtests/matrix.cc index ecaa02a0..210c022f 100644 --- a/libtests/matrix.cc +++ b/libtests/matrix.cc @@ -1,8 +1,13 @@ #include <qpdf/QPDFMatrix.hh> #include <qpdf/QUtil.hh> -#include <assert.h> #include <iostream> +#ifdef NDEBUG +// We need assert even in a release build for test code. +# undef NDEBUG +#endif +#include <cassert> + static void check(QPDFMatrix const& m, std::string const& exp) { std::string u = m.unparse(); diff --git a/libtests/pdf_version.cc b/libtests/pdf_version.cc index c8a568ed..2471cb0b 100644 --- a/libtests/pdf_version.cc +++ b/libtests/pdf_version.cc @@ -1,8 +1,13 @@ #include <qpdf/PDFVersion.hh> -#include <cassert> #include <iostream> +#ifdef NDEBUG +// We need assert even in a release build for test code. +# undef NDEBUG +#endif +#include <cassert> + int main() { PDFVersion v1; diff --git a/libtests/predictors.cc b/libtests/predictors.cc index d2c4863e..f9fa759e 100644 --- a/libtests/predictors.cc +++ b/libtests/predictors.cc @@ -6,10 +6,15 @@ #include <iostream> #include <errno.h> -#include <assert.h> #include <string.h> #include <stdlib.h> +#ifdef NDEBUG +// We need assert even in a release build for test code. +# undef NDEBUG +#endif +#include <cassert> + void run(char const* filename, char const* filter, bool encode, unsigned int columns, unsigned int bits_per_sample, unsigned int samples_per_pixel) diff --git a/libtests/qintc.cc b/libtests/qintc.cc index f9ca9558..85806d1a 100644 --- a/libtests/qintc.cc +++ b/libtests/qintc.cc @@ -1,5 +1,10 @@ #include <qpdf/QIntC.hh> #include <stdint.h> + +#ifdef NDEBUG +// We need assert even in a release build for test code. +# undef NDEBUG +#endif #include <cassert> #define try_convert(exp_pass, fn, i) \ diff --git a/libtests/qutil.cc b/libtests/qutil.cc index b9b7c674..c3a9b163 100644 --- a/libtests/qutil.cc +++ b/libtests/qutil.cc @@ -9,7 +9,6 @@ #include <qpdf/Pl_Buffer.hh> #include <string.h> #include <limits.h> -#include <assert.h> #include <fstream> #include <locale> @@ -19,6 +18,12 @@ # include <unistd.h> #endif +#ifdef NDEBUG +// We need assert even in a release build for test code. +# undef NDEBUG +#endif +#include <cassert> + template <class int_T> void test_to_number(char const* str, int_T wanted, bool error, int_T (*fn)(char const*)) diff --git a/libtests/rc4.cc b/libtests/rc4.cc index eab3a759..b7aecd4b 100644 --- a/libtests/rc4.cc +++ b/libtests/rc4.cc @@ -7,6 +7,11 @@ #include <string.h> #include <iostream> #include <stdlib.h> + +#ifdef NDEBUG +// We need assert even in a release build for test code. +# undef NDEBUG +#endif #include <cassert> static void other_tests() diff --git a/libtests/sparse_array.cc b/libtests/sparse_array.cc index 9c3e00b4..5636abd1 100644 --- a/libtests/sparse_array.cc +++ b/libtests/sparse_array.cc @@ -1,7 +1,12 @@ #include <qpdf/SparseOHArray.hh> -#include <assert.h> #include <iostream> +#ifdef NDEBUG +// We need assert even in a release build for test code. +# undef NDEBUG +#endif +#include <cassert> + int main() { SparseOHArray a; |