logog
logger optimized for games
Unit test framework

A unit test framework is included with logog. This framework was intended specifically to exercise logog functionality, but it may also be used as a general purpose test framework.

A typical test program will look like this:

int main( int argc, char *argv[] )
{
int nResult;
nResult = RunAllTests();
return nResult;
}

To define a unit test, create a function of the following form:

UNITTEST( AdditionTest )
{
int nResult = 0;
if ( 2 + 2 == 4 )
{
LOGOG_COUT << _LG("Sane.") << endl;
}
else
{
LOGOG_COUT << _LG("Insane!") << endl;
nResult = 1;
}
return nResult;
};

The UNITTEST() macro defines a unique UnitTest object that encompasses your function. Your function should take no parameters and return an integer value. It should return zero if the test was successful, and non-zero if the test was unsuccesful. If any of your tests fail, the stub main() program will propagate that error to the operating system, which in turn can be used to halt an automated build system.

The unit testing framework is known to leak memory. However, the underlying logog macros are not known to leak memory (let us know if you find any leaks).