Added common usage assume
macro functions for theories
This commit is contained in:
parent
89d8b4dbcf
commit
c03a149507
2 changed files with 84 additions and 0 deletions
|
@ -51,6 +51,56 @@ Theory invariants are enforced through the ``cr_assume(Condition)`` macro functi
|
|||
if ``Condition`` is false, then the current theory iteration aborts without
|
||||
making the test fail.
|
||||
|
||||
On top of those, more ``assume`` macro functions are available for common operations:
|
||||
|
||||
======================================================= ====================================================
|
||||
Macro Description
|
||||
======================================================= ====================================================
|
||||
``cr_assume_not(Condition)`` Assumes Condition is false.
|
||||
------------------------------------------------------- ----------------------------------------------------
|
||||
``cr_assume_null(Ptr)`` Assumes Ptr is NULL.
|
||||
------------------------------------------------------- ----------------------------------------------------
|
||||
``cr_assume_not_null(Ptr)`` Assumes Ptr is not NULL.
|
||||
------------------------------------------------------- ----------------------------------------------------
|
||||
``cr_assume_eq(Actual, Expected)`` Assumes Actual == Expected.
|
||||
------------------------------------------------------- ----------------------------------------------------
|
||||
``cr_assume_neq(Actual, Unexpected)`` Assumes Actual != Expected.
|
||||
------------------------------------------------------- ----------------------------------------------------
|
||||
``cr_assume_lt(Actual, Expected)`` Assumes Actual < Expected.
|
||||
------------------------------------------------------- ----------------------------------------------------
|
||||
``cr_assume_leq(Actual, Expected)`` Assumes Actual <= Expected.
|
||||
------------------------------------------------------- ----------------------------------------------------
|
||||
``cr_assume_gt(Actual, Expected)`` Assumes Actual > Expected.
|
||||
------------------------------------------------------- ----------------------------------------------------
|
||||
``cr_assume_geq(Actual, Expected)`` Assumes Actual >= Expected.
|
||||
------------------------------------------------------- ----------------------------------------------------
|
||||
``cr_assume_float_eq(Actual, Expected, Epsilon)`` Assumes Actual == Expected with an error of Epsilon.
|
||||
------------------------------------------------------- ----------------------------------------------------
|
||||
``cr_assume_float_neq(Actual, Unexpected, Epsilon)`` Assumes Actual != Expected with an error of Epsilon.
|
||||
------------------------------------------------------- ----------------------------------------------------
|
||||
``cr_assume_strings_eq(Actual, Expected)`` Assumes Actual and Expected are the same string.
|
||||
------------------------------------------------------- ----------------------------------------------------
|
||||
``cr_assume_strings_neq(Actual, Unexpected)`` Assumes Actual and Expected are not the same string.
|
||||
------------------------------------------------------- ----------------------------------------------------
|
||||
``cr_assume_strings_lt(Actual, Expected)`` Assumes Actual is less than Expected
|
||||
lexicographically.
|
||||
------------------------------------------------------- ----------------------------------------------------
|
||||
``cr_assume_strings_leq(Actual, Expected)`` Assumes Actual is less or equal to Expected
|
||||
lexicographically.
|
||||
------------------------------------------------------- ----------------------------------------------------
|
||||
``cr_assume_strings_gt(Actual, Expected)`` Assumes Actual is greater than Expected
|
||||
lexicographically.
|
||||
------------------------------------------------------- ----------------------------------------------------
|
||||
``cr_assume_strings_geq(Actual, Expected)`` Assumes Actual is greater or equal to Expected
|
||||
lexicographically.
|
||||
------------------------------------------------------- ----------------------------------------------------
|
||||
``cr_assume_arrays_eq(Actual, Expected, Size)`` Assumes all elements of Actual (from 0 to Size - 1)
|
||||
are equals to those of Expected.
|
||||
------------------------------------------------------- ----------------------------------------------------
|
||||
``cr_assume_arrays_neq(Actual, Unexpected, Size)`` Assumes one or more elements of Actual (from 0 to
|
||||
Size - 1) differs from their counterpart in Expected.
|
||||
======================================================= ====================================================
|
||||
|
||||
Configuring theories
|
||||
--------------------
|
||||
|
||||
|
|
|
@ -64,6 +64,40 @@ struct criterion_datapoints {
|
|||
cr_theory_abort(); \
|
||||
} while (0);
|
||||
|
||||
# define cr_assume_not(Condition) cr_assume(!(Condition))
|
||||
|
||||
# define cr_assume_op_(Op, Actual, Expected) cr_assume((Actual) Op (Expected))
|
||||
# define cr_assume_eq(Actual, Expected) cr_assume_op_(==, Actual, Expected)
|
||||
# define cr_assume_neq(Actual, Expected) cr_assume_op_(!=, Actual, Expected)
|
||||
# define cr_assume_gt(Actual, Expected) cr_assume_op_(>, Actual, Expected)
|
||||
# define cr_assume_geq(Actual, Expected) cr_assume_op_(>=, Actual, Expected)
|
||||
# define cr_assume_lt(Actual, Expected) cr_assume_op_(<, Actual, Expected)
|
||||
# define cr_assume_leq(Actual, Expected) cr_assume_op_(<=, Actual, Expected)
|
||||
|
||||
# define cr_assume_null(Value) cr_assume_eq(Value, NULL)
|
||||
# define cr_assume_not_null(Value) cr_assume_neq(Value, NULL)
|
||||
|
||||
# define cr_assume_float_eq(Actual, Expected, Epsilon) \
|
||||
cr_assume((Expected) - (Actual) <= (Epsilon) \
|
||||
&& (Actual) - (Expected) <= (Epsilon))
|
||||
|
||||
# define cr_assume_float_neq(Actual, Expected, Epsilon) \
|
||||
cr_assume((Expected) - (Actual) > (Epsilon) \
|
||||
|| (Actual) - (Expected) > (Epsilon))
|
||||
|
||||
# define cr_assume_strings_op_(Op, Actual, Expected) \
|
||||
cr_assume(strcmp((Actual), (Expected)) Op 0)
|
||||
|
||||
# define cr_assume_strings_eq(Actual, Expected) cr_assume_strings_op_(==, Actual, Expected)
|
||||
# define cr_assume_strings_neq(Actual, Expected) cr_assume_strings_op_(!=, Actual, Expected)
|
||||
# define cr_assume_strings_lt(Actual, Expected) cr_assume_strings_op_(<, Actual, Expected)
|
||||
# define cr_assume_strings_leq(Actual, Expected) cr_assume_strings_op_(<=, Actual, Expected)
|
||||
# define cr_assume_strings_gt(Actual, Expected) cr_assume_strings_op_(>, Actual, Expected)
|
||||
# define cr_assume_strings_geq(Actual, Expected) cr_assume_strings_op_(>=, Actual, Expected)
|
||||
|
||||
# define cr_assume_arrays_eq(Actual, Expected, Size) cr_assume(!memcmp((A), (B), (Size)))
|
||||
# define cr_assume_arrays_neq(Actual, Expected, Size) cr_assume(memcmp((A), (B), (Size)))
|
||||
|
||||
CR_API void cr_theory_main(struct criterion_datapoints *dps, size_t datapoints, void (*fnptr)(void));
|
||||
|
||||
# define CR_VAARG_ID(Suffix, Category, Name, ...) \
|
||||
|
|
Loading…
Add table
Reference in a new issue