CUT is a simple and convenient unit testing framework for C.
-
Include
cut.hin Your Test FilesIn each of your test files, include the
cut.hheader to define your test cases.test_file1.c
#include "cut.h" CUT_TEST(pass) { CUT_TEST_PASS; } CUT_TEST(fail) { CUT_TEST_FAIL("This test will fail"); }
test_file2.c
#include "cut.h" CUT_TEST(assert) { CUT_ASSERT(1); CUT_TEST_PASS; }
-
Compile Test Files with
cut.cTo compile and run the tests, you need to link your test files with
cut.c.gcc -o tests test_file1.c test_file2.c cut.c ./tests
You can find additional examples in the tests directory