Page 1 of 1

ModAssert, an advanced assertion package

Posted: Fri Jul 15, 2005 10:48 am
by markvp
If you like using assertions, or don't like them because you think they are not powerful enough, have a look at my open source ModAssert package on Sourceforge: http://sourceforge.net/projects/modassert/. It has 24 assertion macros. They allow you to add expressions to show if the assertions fails. You can also add levels and groups, and an optional action.

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

MOD_ASSERT(a==1);
or as advanced as

Code: Select all

MOD_ASSERT_PTO(b<<c, ModAssert::Error, 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 (over 70 already provided)
- extend the context displayed, to show more than just the file and linenumber (e.g. threadid, backtrace, ...)

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.
[/url]

ModAssert - addendum

Posted: Fri Jul 15, 2005 12:59 pm
by markvp
I should add that it is still a beta, but well tested. The API has changed a lot since version 0.1, but will most likely remain backward compatible from now on.

I post it now, because I'd like to get feedback (both ModAssert and Rich Booleans) from users before releasing the version 1.0.

Posted: Thu Aug 04, 2005 12:15 am
by daddydave
Thanks for this.