DOKK / manpages / debian 11 / libzt-doc / zt_claim.3.en
zt_claim(3) Library Functions Manual (prm) zt_claim(3)

zt_claimstructure capturing unevaluated assertion

#include <zt.h>

typedef struct zt_claim { ... } zt_claim;

struct zt_verifier *(*)(void) make_verifier Verifier factory
zt_value[3] args verifier arguments
zt_location location origin of the claim

zt_claim binds a verifier factory function with concrete arguments. This allows the entire claim to be passed around and evaluated on demand. In case of failure the location where the claim was made can be referenced for construction of error messages.

The verification system is comprised of the following chain of cooperating elements. For example a trivial integer relationship assertion behaves as follows. ZT_CMP_INT(), or another similar macro, invokes zt_cmp_int(), providing source code location as zt_location, and packaging specific types into common variant type zt_value. The result is a zt_claim which is then passed to zt_assert() or zt_check() for evaluation.

The roles of all the essential types and functions is summarized below.

  • zt_value captures values expressed in a test case
  • zt_claim transports up to three values and an opaque verifier
  • zt_check() and zt_assert() validate the claim by instantiating zt_verifier.
  • zt_verifier (private) wraps a verification function, including the arity and expected kind of each argument.
  • zt_arg_info (private) pairs expected argument kind with a customized error message used on kind mismatch.
  • zt_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.

zt_assert(3), zt_check(3)

zt_claim first appeared in libzt 0.1

Part of the API is private which prevents third party verification functions from being written. This is done on purpose to to allow for some more experimentation before stabilizing the interface.

Zygmunt Krynicki <me@zygoon.pl>

January 12, 2020 libzt 0.3.1