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 πŸ‘€

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 πŸ’…βœ¨