Commit 17c0e38c8efa7882f8e6a13c6030edf3e768257c

Authored by Jay Berkenbilt
1 parent 066efb69

Force assert to be defined in test code

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