// assertN.h // // Graded assert macros // // There is no code gaurd in this file, since assert.h files can be // included multiple times. // // Usage: // assert1 (condition) will behave like assert(condition) but is // disabled by either NDEBUG or NDEBUG1. // assert2 (condition) is disabled by those and by NDEBUG2. // assert3 (condition) is disabled by those and by NDEBUG2 or NDEBUG3. // // sanityCheck(condition) will behave much like assert(condition) but // is disabled by NOSANCHECK rather than NDEBUG. #include "ZMutility/iostream" #include #ifndef NDEBUG3 #define assert3(condition) assert2(condition) #else #define assert3(condition) ((void)0) #endif #ifndef NDEBUG2 #define assert2(condition) assert1(condition) #else #define assert2(condition) ((void)0) #endif #ifndef NDEBUG1 #define assert1(condition) assert(condition) #else #define assert1(condition) ((void)0) #endif #ifndef NOSANCHECK #define sanityCheck(condition) \ ((condition)?((void)(0)):((void)(std::cerr<<"Failed sanityCheck: " \ <<# condition<<"\n in "<<__FILE__<<"\n at line "<<__LINE__<<"\n",\ (void)(abort()) ))) #else #define sanityCheck(condition) ((void)0) #endif