zt_claim3
Structure capturing unevaluated assertion
Usage
#include <zt.h>
typedef struct zt_claim { ... } zt_claim;
| Type | Member | Description |
| struct zt_verifier *(*)(void) | make_verifier | Verifier factory |
| zt_value[3] | args | verifier arguments |
| zt_location | location | origin of the claim |
Overview
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.
Implementation notes
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_valuecaptures values expressed in a test case -
zt_claimtransports up to three values and an opaque verifier -
zt_check() andzt_assert() validate the claim by instantiatingzt_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.
Releases
Unchanged in 3 releases since Debian 11 (Bullseye).