This file is available as simple.c, and can be built by typing "make" in the extracted directory. More information about how to use the framework is available in HowToUse, and a list of assertion macros is available in MacroReference.
// Start the overall test suite
// A new group of tests, with an identifier
// We then write the tests we want to check
ASSERT(1 == 1);
// These tests will fail, and we will get output.
ASSERT(1 == 0);
// Lets give a description of the test, before it
// fails - this will be printed out instead.
TEST("we expect this test to fail. (3==2)");
ASSERT(3 == 2);
// End the overall test suite
Once you've got this test written, save it as "simple.c", compile and link it, and run it. You can also do this by going typing in make. It will execute all the tests and display the output to the console:
[FAIL?] simple.c:21 : (fail) : 1 == 0 fails
[FAIL?] simple.c:22 : (fail) : 1 is supposed to equal (float) 0
(0.000000 != 1.000000)
[FAIL?] simple.c:26 : (fail) : we expect this test to fail. (3==2)
--- Results ---
Tests run: 2
A full list of all the macros available are in the MacroReference section.