logo
Free, unlimited AI code reviews that run on commit
git-lrc git-lrc GitHub Install Now We'd appreciate a star git-lrc - Free, unlimited AI code reviews that run on commit | Product Hunt git-lrc - Free, unlimited AI code reviews that run on commit | Product Hunt

zt_claim — structure capturing unevaluated assertion

Authors

       Zygmunt Krynicki <me@zygoon.pl>

libzt 0.3.1                                     January 12, 2020                                     zt_claim(3)

Bugs

       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.

Description

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.

History

zt_claim first appeared in libzt 0.1

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_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.

Name

       zt_claim — structure capturing unevaluated assertion

See Also

zt_assert(3), zt_check(3)

Synopsis

#include<zt.h>typedefstructzt_claim{...}zt_claim;TypeMemberDescriptionstructzt_verifier*(*)(void)     make_verifier     Verifier factory
       zt_value[3]                       args              verifier arguments
       zt_location                       location          origin of the claim

See Also