libzt3
Library for unit testing c
Usage
#include <zt.h>
Library
Library for unit testing C (-lzt)
Overview
The libzt library offers routines for writing C unit tests. It is focusing on simplicity, robustness and correctness, offering facilities for:
-
Defining test suites and test cases.
-
Asserting relations between booleans, integers, strings and characters. Asserting properties of booleans and pointers.
-
Creating command line interface that allows enumerating and invoking tests. The output of test programs integrates well with make.
The library code is portable between a wide range of C compilers and operating systems. All library code is covered by a self-test test suite. The library never allocates memory or uses the file system which makes it suitable for working on embedded targets.
Examples
The following fragment demonstrates a simple test program, comprised of a single test suite with a single test case checking the relations between two integers.
#include <zt.h>
static void test_math(zt_t t)
{
zt_check(t, ZT_CMP_INT(2 + 2, ==, 4));
}
static void test_suite(zt_visitor v)
{
ZT_VISIT_TEST_CASE(v, test_math);
}
int main(int argc, char** argv, char** envp)
{
return zt_main(argc, argv, envp, test_suite);
}
Releases
Unchanged in 3 releases since Debian 11 (Bullseye).