extatic.org :: exotic

Exotic - test Infrastructure for C/C++

Exotic is a minimalistic tool for unit testing C or C++ code. Exotic consists of two parts, a tool generating wrapper code for the tests, and a C library.

Exotic can also generate standalone code which does not require the C library, which is ideal for source code distributions.

Download

Download the latest source code here.

Directives

EXO_TEST(test_name, { /* test block */ });

Notes

C Example

Create a test file to test the function "magic()", the test is considered success if the return value is non-zero (true):

#include "magic.h"

EXO_TEST(test_function_magic_1, {
	int n = magic();
	return n == 42;
});

EXO_TEST(test_function_magic_2, {
	int n = magic();
	return n != 42;
});

Place this test in a file, such as test_magic.tcc

Now, all you need to do is run the exotic tool to create the source code for a runnable executable:

exotic test_magic.tcc > autotest.c

Exotic have now created a C file which can be compiled to a runnable binary. The generated file will also ensure that all found test cases are registered and run when. In this case test_function_magic_1 and test_function_magic_2 will be run.

This can be compiled as:

cc -o autotest autotest.c -lexotic

The tests can be performed by running autotest, use autotest -h for help.

Notes

Copyright © 2001-2008 Jan Vidar Krey
Valid HTML 4.01 Strict Valid CSS!