Go to the documentation of this file.
32 #ifndef QUESO_ASSERTS_H
33 #define QUESO_ASSERTS_H
36 #include "queso/config_queso.h"
42 #define queso_here() do { std::cerr << __FILE__ << ", line " << __LINE__ << ", compiled " << __DATE__ << " at " << __TIME__ << std::endl; } while (0)
47 #define queso_error_msg(msg) do { queso_here(); std::cerr << msg << std::endl; QUESO_THROW(QUESO::LogicError()); } while(0)
49 #define queso_not_implemented_msg(msg) do { queso_here(); std::cerr << msg << std::endl; QUESO_THROW(QUESO::NotImplemented()); } while(0)
51 #define queso_file_error_msg(filename, msg) do { queso_here(); std::cerr << msg << std::endl; QUESO_THROW(QUESO::FileError(filename)); } while(0)
53 #define queso_error() \
56 #define queso_not_implemented() \
57 queso_not_implemented_msg("")
59 #define queso_file_error(filename) \
60 queso_file_error_msg(filename, "")
69 #define queso_require_msg(asserted, msg) do { if (!(asserted)) { std::cerr << "Assertion `" #asserted "' failed.\n" << msg << std::endl; queso_error(); } } while(0)
74 #ifdef QUESO_HAVE_CXX11
75 #define queso_require_equal_to_msg(expr1,expr2,msg) do { typedef decltype(expr1) type1; typedef decltype(expr2) type2; if (!((expr1 == static_cast<type1>(expr2)) && static_cast<type2>(expr1) == expr2)) { std::cerr << "Assertion `" #expr1 " == " #expr2 "' failed.\n" #expr1 " = " << (expr1) << "\n" #expr2 " = " << (expr2) << '\n' << msg << std::endl; queso_error(); } } while(0)
76 #define queso_require_not_equal_to_msg(expr1,expr2,msg) do { typedef decltype(expr1) type1; typedef decltype(expr2) type2; if (!((expr1 != static_cast<type1>(expr2)) && (static_cast<type2>(expr1) != expr2))) { std::cerr << "Assertion `" #expr1 " != " #expr2 "' failed.\n" #expr1 " = " << (expr1) << "\n" #expr2 " = " << (expr2) << '\n' << msg << std::endl; queso_error(); } } while(0)
77 #define queso_require_less_msg(expr1,expr2,msg) do { typedef decltype(expr1) type1; typedef decltype(expr2) type2; if (!((static_cast<type2>(expr1) < expr2) && (expr1 < static_cast<type1>(expr2)))) { std::cerr << "Assertion `" #expr1 " < " #expr2 "' failed.\n" #expr1 " = " << (expr1) << "\n" #expr2 " = " << (expr2) << '\n' << msg << std::endl; queso_error(); } } while(0)
78 #define queso_require_greater_msg(expr1,expr2,msg) do { typedef decltype(expr1) type1; typedef decltype(expr2) type2; if (!((static_cast<type2>(expr1) > expr2) && (expr1 > static_cast<type1>(expr2)))) { std::cerr << "Assertion `" #expr1 " > " #expr2 "' failed.\n" #expr1 " = " << (expr1) << "\n" #expr2 " = " << (expr2) << '\n' << msg << std::endl; queso_error(); } } while(0)
79 #define queso_require_less_equal_msg(expr1,expr2,msg) do { typedef decltype(expr1) type1; typedef decltype(expr2) type2; if (!((static_cast<type2>(expr1) <= expr2) && (expr1 <= static_cast<type1>(expr2)))) { std::cerr << "Assertion `" #expr1 " <= " #expr2 "' failed.\n" #expr1 " = " << (expr1) << "\n" #expr2 " = " << (expr2) << '\n' << msg << std::endl; queso_error(); } } while(0)
80 #define queso_require_greater_equal_msg(expr1,expr2,msg) do { typedef decltype(expr1) type1; typedef decltype(expr2) type2; if (!((static_cast<type2>(expr1) >= expr2) && (expr1 >= static_cast<type1>(expr2)))) { std::cerr << "Assertion `" #expr1 " >= " #expr2 "' failed.\n" #expr1 " = " << (expr1) << "\n" #expr2 " = " << (expr2) << '\n' << msg << std::endl; queso_error(); } } while(0)
85 #define queso_require_equal_to_msg(expr1,expr2,msg) do { if (!(expr1 == expr2)) { std::cerr << "Assertion `" #expr1 " == " #expr2 "' failed.\n" #expr1 " = " << (expr1) << "\n" #expr2 " = " << (expr2) << '\n' << msg << std::endl; queso_error(); } } while(0)
86 #define queso_require_not_equal_to_msg(expr1,expr2,msg) do { if (!(expr1 != expr2)) { std::cerr << "Assertion `" #expr1 " != " #expr2 "' failed.\n" #expr1 " = " << (expr1) << "\n" #expr2 " = " << (expr2) << '\n' << msg << std::endl; queso_error(); } } while(0)
87 #define queso_require_less_msg(expr1,expr2,msg) do { if (!(expr1 < expr2)) { std::cerr << "Assertion `" #expr1 " < " #expr2 "' failed.\n" #expr1 " = " << (expr1) << "\n" #expr2 " = " << (expr2) << '\n' << msg << std::endl; queso_error(); } } while(0)
88 #define queso_require_greater_msg(expr1,expr2,msg) do { if (!(expr1 > expr2)) { std::cerr << "Assertion `" #expr1 " > " #expr2 "' failed.\n" #expr1 " = " << (expr1) << "\n" #expr2 " = " << (expr2) << '\n' << msg << std::endl; queso_error(); } } while(0)
89 #define queso_require_less_equal_msg(expr1,expr2,msg) do { if (!(expr1 <= expr2)) { std::cerr << "Assertion `" #expr1 " <= " #expr2 "' failed.\n" #expr1 " = " << (expr1) << "\n" #expr2 " = " << (expr2) << '\n' << msg << std::endl; queso_error(); } } while(0)
90 #define queso_require_greater_equal_msg(expr1,expr2,msg) do { if (!(expr1 >= expr2)) { std::cerr << "Assertion `" #expr1 " >= " #expr2 "' failed.\n" #expr1 " = " << (expr1) << "\n" #expr2 " = " << (expr2) << '\n' << msg << std::endl; queso_error(); } } while(0)
97 #define queso_assert_msg(asserted,msg) ((void) 0)
98 #define queso_assert_equal_to_msg(expr1,expr2,msg) ((void) 0)
99 #define queso_assert_not_equal_to_msg(expr1,expr2,msg) ((void) 0)
100 #define queso_assert_less_msg(expr1,expr2,msg) ((void) 0)
101 #define queso_assert_greater_msg(expr1,expr2,msg) ((void) 0)
102 #define queso_assert_less_equal_msg(expr1,expr2,msg) ((void) 0)
103 #define queso_assert_greater_equal_msg(expr1,expr2,msg) ((void) 0)
107 #define queso_assert_msg(asserted,msg) \
108 queso_require_msg(asserted,msg)
109 #define queso_assert_equal_to_msg(expr1,expr2,msg) \
110 queso_require_equal_to_msg(expr1,expr2,msg)
111 #define queso_assert_not_equal_to_msg(expr1,expr2,msg) \
112 queso_require_not_equal_to_msg(expr1,expr2,msg)
113 #define queso_assert_less_msg(expr1,expr2,msg) \
114 queso_require_less_msg(expr1,expr2,msg)
115 #define queso_assert_greater_msg(expr1,expr2,msg) \
116 queso_require_greater_msg(expr1,expr2,msg)
117 #define queso_assert_less_equal_msg(expr1,expr2,msg) \
118 queso_require_less_equal_msg(expr1,expr2,msg)
119 #define queso_assert_greater_equal_msg(expr1,expr2,msg) \
120 queso_require_greater_equal_msg(expr1,expr2,msg)
124 #define queso_require(asserted) \
125 queso_require_msg(asserted, "")
127 #define queso_require_equal_to(expr1,expr2) \
128 queso_require_equal_to_msg(expr1,expr2,"")
130 #define queso_require_not_equal_to(expr1,expr2) \
131 queso_require_not_equal_to_msg(expr1,expr2,"") \
133 #define queso_require_less(expr1,expr2) \
134 queso_require_less_msg(expr1,expr2,"")
136 #define queso_require_greater(expr1,expr2) \
137 queso_require_greater_msg(expr1,expr2,"")
139 #define queso_require_less_equal(expr1,expr2) \
140 queso_require_less_equal_msg(expr1,expr2,"")
142 #define queso_require_greater_equal(expr1,expr2) \
143 queso_require_greater_equal_msg(expr1,expr2,"")
146 #define queso_assert(asserted) \
147 queso_assert_msg(asserted, "")
149 #define queso_assert_equal_to(expr1,expr2) \
150 queso_assert_equal_to_msg(expr1,expr2,"")
152 #define queso_assert_not_equal_to(expr1,expr2) \
153 queso_assert_not_equal_to_msg(expr1,expr2,"") \
155 #define queso_assert_less(expr1,expr2) \
156 queso_assert_less_msg(expr1,expr2,"")
158 #define queso_assert_greater(expr1,expr2) \
159 queso_assert_greater_msg(expr1,expr2,"")
161 #define queso_assert_less_equal(expr1,expr2) \
162 queso_assert_less_equal_msg(expr1,expr2,"")
164 #define queso_assert_greater_equal(expr1,expr2) \
165 queso_assert_greater_equal_msg(expr1,expr2,"")
169 #endif // QUESO_ASSERTS_H
Generated on Thu Jun 11 2015 13:52:31 for queso-0.53.0
by
doxygen
1.8.5