From 17c0e38c8efa7882f8e6a13c6030edf3e768257c Mon Sep 17 00:00:00 2001 From: Jay Berkenbilt Date: Mon, 7 Mar 2022 08:46:53 -0500 Subject: Force assert to be defined in test code --- libtests/arg_parser.cc | 5 +++++ libtests/buffer.cc | 7 ++++++- libtests/concatenate.cc | 7 ++++++- libtests/cxx11.cc | 7 ++++++- libtests/json.cc | 5 +++++ libtests/json_handler.cc | 5 +++++ libtests/matrix.cc | 7 ++++++- libtests/pdf_version.cc | 7 ++++++- libtests/predictors.cc | 7 ++++++- libtests/qintc.cc | 5 +++++ libtests/qutil.cc | 7 ++++++- libtests/rc4.cc | 5 +++++ libtests/sparse_array.cc | 7 ++++++- 13 files changed, 73 insertions(+), 8 deletions(-) (limited to 'libtests') 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 #include #include + +#ifdef NDEBUG +// We need assert even in a release build for test code. +# undef NDEBUG +#endif #include 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 #include #include -#include #include +#ifdef NDEBUG +// We need assert even in a release build for test code. +# undef NDEBUG +#endif +#include + 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 #include #include -#include + +#ifdef NDEBUG +// We need assert even in a release build for test code. +# undef NDEBUG +#endif +#include 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 -#include #include #include #include @@ -10,6 +9,12 @@ #include #include +#ifdef NDEBUG +// We need assert even in a release build for test code. +# undef NDEBUG +#endif +#include + // 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 #include #include + +#ifdef NDEBUG +// We need assert even in a release build for test code. +# undef NDEBUG +#endif #include 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 #include #include + +#ifdef NDEBUG +// We need assert even in a release build for test code. +# undef NDEBUG +#endif #include 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 #include -#include #include +#ifdef NDEBUG +// We need assert even in a release build for test code. +# undef NDEBUG +#endif +#include + 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 -#include #include +#ifdef NDEBUG +// We need assert even in a release build for test code. +# undef NDEBUG +#endif +#include + 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 #include -#include #include #include +#ifdef NDEBUG +// We need assert even in a release build for test code. +# undef NDEBUG +#endif +#include + 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 #include + +#ifdef NDEBUG +// We need assert even in a release build for test code. +# undef NDEBUG +#endif #include #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 #include #include -#include #include #include @@ -19,6 +18,12 @@ # include #endif +#ifdef NDEBUG +// We need assert even in a release build for test code. +# undef NDEBUG +#endif +#include + template 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 #include #include + +#ifdef NDEBUG +// We need assert even in a release build for test code. +# undef NDEBUG +#endif #include 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 -#include #include +#ifdef NDEBUG +// We need assert even in a release build for test code. +# undef NDEBUG +#endif +#include + int main() { SparseOHArray a; -- cgit v1.2.3-70-g09d2