ZT_VISIT_TEST_CASE(3)
π zt_visit_test_case β bestie's guide to finding your tests π
okay so. this is the manual page for zt_visit_test_case(3) (yes that's the manual name, it lives in the LOCAL section, don't @ me). it's all about discovering test cases and their structure. let's get into it π¦
β¨ NAME β¨
zt_visit_test_case, ZT_VISIT_TEST_CASE, zt_visit_test_suite, ZT_VISIT_TEST_SUITE β the way you discover test cases and their whole little structure πΈ
β¨ SYNOPSIS β¨
#include <zt.h>
void
zt_visit_test_case(zt_visitor v, zt_test_case_func func,
const char *name);
#define ZT_VISIT_TEST_CASE(v, tcase) zt_visit_test_case(v, tcase,
#tcase)
void
zt_visit_test_case(zt_visitor v, zt_test_suite_func func,
const char *name);
#define ZT_VISIT_TEST_SUITE(v, tsuite) zt_visit_test_suite(v, tsuite,
#tsuite)
β¨ DESCRIPTION β¨
so zt_visit_test_case() and zt_visit_test_suite() β or, like, usually their macro glow-ups ZT_VISIT_TEST_CASE() and ZT_VISIT_TEST_SUITE() β are literally the whole discovery mechanism for test suites and test cases. that's their job. their entire personality π
here's the tea: test suites are just functions that go visit other test suites and test cases. test cases are functions that actually run the real test code. it's giving recursive tree energy, fr fr π
and the macros? they exist purely as a convenience so you don't have to sit there inventing names like a Victorian poet. iconic behavior honestly π
usually the main test suite gets passed as an argument to zt_main(), which then handles all the rest of the discovery and, if it needs to, the execution. main character energy π
β¨ RETURN VALUES β¨
visit functions do not return any value. nothing. nada. they're void, they said "not my problem" π
β¨ EXAMPLES β¨
okay here's a whole example showing how to build a test suite with two test cases. and heads up bestie β a suite can contain any number of nested suites and test cases, go wild π¦
#include <zt.h>
static void test_foo(zt_t t) {
printf("foo invoked\n");
}
static void suite_inner(zt_visitor v) {
ZT_VISIT_TEST_CASE(v, test_foo);
}
static void test_bar(zt_t t) {
printf("bar invoked\n");
}
static void main_suite(zt_visitor v) {
ZT_VISIT_TEST_SUITE(v, suite_inner);
ZT_VISIT_TEST_CASE(v, test_bar);
}
int main(int argc, char** argv, char** envp) {
return zt_main(argc, argv, envp, main_suite);
}
look at that nesting. a suite inside a suite. it's giving matryoshka doll π ate, no crumbs β¨
β¨ SEE ALSO β¨
(yeah the original list ends in a comma, i'm not touching it, that's just how it is π)
β¨ HISTORY β¨
zt_visit_test_case() and zt_visit_test_suite() β plus their corresponding macros β first appeared in libzt 0.1. a humble origin story. we love a glow-up arc π±β‘οΈπ
β¨ AUTHORS β¨
Zygmunt Krynicki <me@zygoon.pl> β thank you for your service, king π«Ά
and that's the whole page bestie!! this was libzt 0.3.1, dated January 12, 2020, and it's the ZT_VISIT_TEST_CASE(3) page π go forth and discover ur tests, ily, periodt β¨πΈπ
π¦ 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