Available C++ Libraries FAQ
Tools for C++ Programmers
ModAssert - A library of ASSERT-like macros that can use rich booleansIn C and C++ the traditional assert function is used to tell the user that something unexpected happened, that might cause the program to fail. Macros were written to extend this mechanism, like ASSERT_EQUAL(a,b) to give a short explanation "lefthand is <9>, righthand is <10>". However, such a macros functionality can't be reused in any way if we want to have a similar VERIFY_EQUAL (which still evaluates its arguments in non-debug mode), or an ASSERT_EQUAL_MSG (to add a message).
The Modular Assert macros use Rich Booleans, to have a modular assertion framework where any type of ASSERT can be combined with any Rich Boolean or a simple boolean expression. This package has 16 different types of assertion macros (ASSERT, VERIFY, ASSERT_P, ...), which can be combined with any rich boolean to provide extra information (or a simple boolean expression). So one could write ASSERT(rbEQUAL(a,b)), VERIFY(rbLESS(foo(), 10)), etc. Furthermore, the macros allow an arbitray number of expressions to be evaluated and shown when an assertion fails. A level can be assigned to each assertion (Info, Debug, Error or Fatal). Assertions can be ignored per case, level or file.
They are released under the Boost License, which allows free use in any code. It was tested with Visual C++ and Gnu C++, but contains no platform or compiler specific code (except for the demo code), so it should be portable.
Added : 2005-02-11 Amended: 2005-02-11 Licensing : Non commercial
Copyright (c) 2017 Nikki Locke, Trumphurst Ltd.
Permission is granted to distribute over the Internet without charge. The author's permission is required (and usually given) to distribute in any other way, including on CD.