22 #ifndef ASSERT_CONTRACT_H 23 #define ASSERT_CONTRACT_H 25 #ifndef SHEAF_DLL_SPEC_H 26 #include "SheafSystem/sheaf_dll_spec.h" 37 SHEAF_DLL_SPEC
void check_contract(
bool xcond,
const char* xmsg,
const char* xfunction_name,
const char* xfile,
int xline);
50 const char* xcond_msg,
73 const char* xcond_msg,
76 const char* xfunction_name,
99 const char* xfunction_name,
106 SHEAF_DLL_SPEC
void post_unimplemented(
const char* xcond_msg,
const char* xfunction_name,
const char* xfile,
int xline);
120 #define dbc_assert(x) sheaf::check_contract((x), #x, __FUNCTION__, __FILE__, __LINE__) 124 #define dbc_assert_for_i(x, xi) sheaf::check_contract((x), #x, (xi), #xi, __FUNCTION__, __FILE__, __LINE__) 129 #define dbc_assert_for_all(xi, xi_min, xi_ub, xcondition) \ 130 { for(int xi = (xi_min); xi < (xi_ub); ++xi) dbc_assert_for_i((xcondition), xi); } 136 #define dbc_assert_for_range(xinit, xtest, xincrement, xcondition) \ 137 { xinit; while(xtest) { dbc_assert(xcondition); xincrement; } } 143 #define dbc_assert_for_iterator(xinit, xtest, xincrement, xcondition, xfinalize) \ 144 { xinit; while(xtest) { dbc_assert(xcondition); xincrement; } xfinalize; } 150 #define dbc_assert_there_exists(xi, xi_min, xi_ub, xcondition) \ 152 for(int xi = (xi_min); xi < (xi_ub) && !(xcondition); ++xi) \ 154 if(xi == ((xi_ub)-1)) \ 156 sheaf::post_there_exists_failed(#xcondition, xi, #xi, (xi_min), (xi_ub), __FUNCTION__, __FILE__, __LINE__); \ 163 #define assertion(x) dbc_assert(x) 167 #define define_old_variable(x) x 171 #define if_contract(x) x 175 #define require(x) dbc_assert(x) 176 #define require_for_all(i, i_min, i_ub, condition) dbc_assert_for_all(i, i_min, i_ub, condition) 177 #define require_for_range(init, test, increment, condition) dbc_assert_for_range(init, test, increment, condition) 178 #define require_for_iterator(init, test, increment, condition, finalize) dbc_assert_for_iterator(init, test, increment, condition, finalize); 179 #define require_there_exists(i, i_min, i_ub, condition) dbc_assert_there_exists(i, i_min, i_ub, condition) 183 #define ensure(x) dbc_assert(x) 184 #define ensure_for_all(i, i_min, i_ub, condition) dbc_assert_for_all(i, i_min, i_ub, condition) 185 #define ensure_for_range(init, test, increment, condition) dbc_assert_for_range(init, test, increment, condition) 186 #define ensure_for_iterator(init, test, increment, condition, finalize) dbc_assert_for_iterator(init, test, increment, condition, finalize); 187 #define ensure_there_exists(i, i_min, i_ub, condition) dbc_assert_there_exists(i, i_min, i_ub, condition) 191 #define invariance(x) dbc_assert(x) 192 #define invariance_for_all(i, i_min, i_ub, condition) dbc_assert_for_all(i, i_min, i_ub, condition) 193 #define invariance_for_range(init, test, increment, condition) dbc_assert_for_range(init, test, increment, condition) 194 #define invariance_for_iterator(init, test, increment, condition, finalize) dbc_assert_for_iterator(init, test, increment, condition, finalize); 195 #define invariance_there_exists(i, i_min, i_ub, condition) dbc_assert_there_exists(i, i_min, i_ub, condition) 206 #define define_old_variable(x) 207 #define if_contract(x) 209 #define require_for_all(i, i_min, i_ub, condition) 210 #define require_for_range(init, test, increment, condition) 211 #define require_for_iterator(init, test, increment, condition, finalize) 212 #define require_there_exists(i, i_min, i_ub, condition) 214 #define ensure_for_all(i, i_min, i_ub, condition) 215 #define ensure_for_range(init, test, increment, condition) 216 #define ensure_for_iterator(init, test, increment, condition, finalize) 217 #define ensure_there_exists(i, i_min, i_ub, condition) 218 #define invariance(x) 219 #define invariance_for_all(i, i_min, i_ub, condition) 220 #define invariance_for_range(init, test, increment, condition) 221 #define invariance_for_iterator(init, test, increment, condition, finalize) 222 #define invariance_there_exists(i, i_min, i_ub, condition) 234 #define is_abstract() sheaf::post_unimplemented("is abstract", __FUNCTION__, __FILE__, __LINE__) 238 #define not_implemented() sheaf::post_unimplemented("not implemented", __FUNCTION__, __FILE__, __LINE__) 247 #define unexecutable(x) true 248 #define precondition_of(x) true 249 #define postcondition_of(x) true 263 #define is_basic_query true 264 #define is_derived_query true 267 #endif // ifndef ASSERT_CONTRACT_H SHEAF_DLL_SPEC void post_there_exists_failed(const char *xcond_msg, int xi, const char *xi_msg, int xmin, int xub, const char *xfunction_name, const char *xfile, int xline)
Throws exception for existential quantification failure.
Namespace for the sheaves component of the sheaf system.
SHEAF_DLL_SPEC void check_contract(bool xcond, const char *xmsg, const char *xfunction_name, const char *xfile, int xline)
Tests condition xcond and throws exception if false; exception message includes xmsg, file name xfile, and line number xline.
SHEAF_DLL_SPEC void post_unimplemented(const char *xcond_msg, const char *xfunction_name, const char *xfile, int xline)
Throws exception for attempt to invoke is_abstract or not implemented.