LIBZT(3)
π libzt β Library for unit testing C π
okay bestie, gather round, because we're talking about libzt, a whole library for unit testing C and she is so good at her job π
π LIBRARY
she lives in the library called Library for unit testing C, and you link her with -lzt π
β¨ SYNOPSIS β¨
#include <zt.h>
that's it. that's the whole entry point. slay.
π¦ DESCRIPTION π¦
so the libzt library offers routines for writing C unit tests. her whole personality? simplicity, robustness and correctness. she's not doing the most, she's doing it right. and she's got facilities for, like:
- Defining test suites and test cases π
- Asserting relations between booleans, integers, strings and characters. Also asserting properties of booleans and pointers π―
- Creating a command line interface that lets you enumerate and invoke tests. and the way that the output of test programs integrates well with
make?? obsessed. truly built for the build system girlies π₯
and ngl the library code is portable between a wide range of C compilers and operating systems π. every last bit of library code is covered by a self-test test suite β she tests herself, iconic. and get this: the library never allocates memory or uses the file system, which is exactly why she's suitable for working on embedded targets π§π
πΈ EXAMPLES πΈ
okay here's the moment. 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);
}
look at her. 2 + 2 == 4 and the test knows it. main character energy fr fr πβ¨
π SEE ALSO π
zt_main(3)ZT_VISIT_TEST_CASE(3)ZT_VISIT_TEST_SUITE(3)zt_check(3)ZT_CMP_INT(3)
go read them, iykyk π
π°οΈ HISTORY π°οΈ
libzt version 0.1 was first released in 2020 β
π AUTHORS π
Zygmunt Krynicki <me@zygoon.pl> β thank you for your service king π«‘π
ok that's the whole page bestie, no notes π
and that's a wrap!! this was libzt 0.3.1, dated January 12, 2020 πΈπ go write some tests, you're gonna eat π β¨
π¦ where this page comes from
- debian bookworm: libzt-doc 0.3.1-4 Β· LGPL-3.0-only
- debian trixie: libzt-doc 0.3.1-4 Β· LGPL-3.0-only
- ubuntu jammy: libzt-doc 0.3.1-4 Β· LGPL-3.0-only
- ubuntu noble: libzt-doc 0.3.1-4build1 Β· LGPL-3.0-only
- ubuntu questing: libzt-doc 0.3.1-4build1
- ubuntu resolute: libzt-doc 0.3.1-4build2 Β· LGPL-3.0-only
- ubuntu stonking: libzt-doc 0.3.1-4build2 Β· LGPL-3.0-only
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms