diff options
author | Jay Berkenbilt <ejb@ql.org> | 2022-05-03 14:21:01 +0200 |
---|---|---|
committer | Jay Berkenbilt <ejb@ql.org> | 2022-05-04 00:31:22 +0200 |
commit | 62bf296a9c0f5be492f0677ed111b3fa217f4c11 (patch) | |
tree | f49564b3d70a12ee4e16e84c4e4e33a2adce1133 /libqpdf/QPDF_optimization.cc | |
parent | 92b692466f7a4dbf4e51e6a77713c029a3e18ab1 (diff) | |
download | qpdf-62bf296a9c0f5be492f0677ed111b3fa217f4c11.tar.zst |
Make assert handling less error-prone
Prevent my future self or other contributors from using assert in
tests and then having that assert not do anything because of the
NDEBUG macro.
Diffstat (limited to 'libqpdf/QPDF_optimization.cc')
-rw-r--r-- | libqpdf/QPDF_optimization.cc | 9 |
1 files changed, 5 insertions, 4 deletions
diff --git a/libqpdf/QPDF_optimization.cc b/libqpdf/QPDF_optimization.cc index ac1bbfe6..4204a20d 100644 --- a/libqpdf/QPDF_optimization.cc +++ b/libqpdf/QPDF_optimization.cc @@ -1,12 +1,13 @@ // See the "Optimization" section of the manual. +#include <qpdf/assert_debug.h> + #include <qpdf/QPDF.hh> #include <qpdf/QPDFExc.hh> #include <qpdf/QPDF_Array.hh> #include <qpdf/QPDF_Dictionary.hh> #include <qpdf/QTC.hh> -#include <cassert> QPDF::ObjUser::ObjUser() : ou_type(ou_bad), @@ -18,14 +19,14 @@ QPDF::ObjUser::ObjUser(user_e type) : ou_type(type), pageno(0) { - assert(type == ou_root); + qpdf_assert_debug(type == ou_root); } QPDF::ObjUser::ObjUser(user_e type, int pageno) : ou_type(type), pageno(pageno) { - assert((type == ou_page) || (type == ou_thumb)); + qpdf_assert_debug((type == ou_page) || (type == ou_thumb)); } QPDF::ObjUser::ObjUser(user_e type, std::string const& key) : @@ -33,7 +34,7 @@ QPDF::ObjUser::ObjUser(user_e type, std::string const& key) : pageno(0), key(key) { - assert((type == ou_trailer_key) || (type == ou_root_key)); + qpdf_assert_debug((type == ou_trailer_key) || (type == ou_root_key)); } bool |