ZT_CLAIM(3)
π zt_claim β the little struct that holds your hot take before anyone checks it π
okay so bestie, this is a page from the LOCAL manual, and it's all about zt_claim β a structure capturing an unevaluated assertion. yes she's a struct, yes she's serving, let's get into it π
β¨ NAME β¨
zt_claim β structure capturing unevaluated assertion
like... a claim you made but haven't actually verified yet. the receipts are pending, the vibe is immaculate π
πΈ SYNOPSIS πΈ
#include <zt.h>
typedef struct zt_claim { ... } zt_claim;
and here's what's inside her, member by member, no skips:
struct zt_verifier *(*)(void)βmake_verifierβ the verifier factory πzt_value[3]βargsβ the verifier argumentszt_locationβlocationβ where the claim came from, aka the origin story of the claim π
π¦ DESCRIPTION π¦
so zt_claim binds a verifier factory function together with concrete arguments. that's the whole point, bestie β it means the entire claim can be passed around like a lil note in the group chat and evaluated whenever you feel like it, on demand. β³
and if things go wrong (failure, ugh π), the location where the claim was made can be referenced so you can construct error messages that actually tell you where the mess happened.
π IMPLEMENTATION NOTES π
okay this is the lore. the verification system is a whole chain of cooperating elements, and when it works it works. for example, a trivial integer relationship assertion behaves like this:
ZT_CMP_INT(), or another similar macro, invokes zt_cmp_int(), providing source code location as zt_location, and packaging specific types into the common variant type zt_value. the result is a zt_claim which is then passed to zt_assert() or zt_check() for evaluation. β¨
and here's the cast of characters, all the essential types and functions, summarized below:
zt_valuecaptures values expressed in a test casezt_claimtransports up to three values and an opaque verifierzt_check()andzt_assert()validate the claim by instantiatingzt_verifierzt_verifier(private) wraps a verification function, including the arity and expected kind of each argumentzt_arg_info(private) pairs expected argument kind with a customized error message used on kind mismatchzt_verify_claim()(private) ensures verifier function arity and argument kind matches what is encoded in the claim and invokes the verifier function- the specific verifier function inspects the argument and performs the actual verification of the desired property that the test is measuring
zt_test(private) keeps track of test outcome, provides a stream for writing error messages and assists in performing non-local exit
so many little guys doing their part. teamwork makes the dream work π«Ά
π SEE ALSO π
zt_assert(3)zt_check(3)
go read those too, iykyk π
π HISTORY π
zt_claim first appeared in libzt 0.1 β a true OG π
π BUGS π
part of the API is private, which prevents third party verification functions from being written. this is done on purpose (fr fr, on purpose) to allow for some more experimentation before stabilizing the interface. so like, it's not a bug it's a choice, but we're still putting it here under BUGS. π
π AUTHORS π
Zygmunt Krynicki <me@zygoon.pl>
and that's the page!! π this one's from libzt 0.3.1, dated January 12, 2020 β mwah, 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