On top of that, the condition can be replaced with a Rich Boolean, that gives an informative analysis of why the condition failed (e.g. to show which bits are different in two integers if you ask for a bitwise comparison, or which elements of two wxArrays are different). See http://sourceforge.net/projects/rich-booleans/ to download the Rich Booleans (needed by ModAssert).
Using it can be as simple as
Code: Select all
There is also MOD_VERIFY, that still evaluates its arguments if assertions are compiled out, and MOD_CHECK, which has a failure action that is exectuted if the condition fails (similar to wxCHECK2).
But you can add suffixes to them and give more arguments, so an assertion can be as advanced as
Code: Select all
MOD_ASSERT_PGO(b<<c, ModAssert::Fatal, return false, "return false", rbEQUAL(a,1));
It is extensible in many ways:
- write your own dialog to display assertions (one for wxWidgets is already provided)
- write your own assertion logger (one for wxWidgets is already provided)
- write your own Rich Booleans (almost 60 already provided, for all common types of checks C++ programmers need)
- add your own infoproviders to have extra information displayed and logged when an assertion fails (e.g. the threadid, which is already provided for wxWidgets).
It allows you to compile out assertions per level, group, file or all at once. Displaying and logging of failed assertions can be controlled at runtime per level, group, file or all at once.
A small demo application that uses wxWidgets is provided. This also demonstrates how you can reroute wxWidgets assertion macros to ModAssert.
A manual in HTML of 126KB (or PDF, 114 KB) is included, that explains every detail (not generated from code).
It is released under the Boost license, so you can use it in closed source applications, even without mentioning that you use it.