Assertion macros¶
Warning
All the macros below can only be used inside a ``define_tests` <tests>` declaration.
Note
All the macros below can be prefixed with assert_
by defining
ASSERT_PREFIX
before importing the framework:
#define ASSERT_PREFIX
#include "crash.h"
Basic assertions¶
-
ok
(value)¶ -
Asserts that
value
is true.
-
no
(value)¶ -
Asserts that
value
is false.
Integers¶
-
eq
(expected, value)¶ -
Asserts that
value
is equal toexpected
.
-
ne
(expected, value)¶ -
Asserts that
value
isn’t equal toexpected
.
Floating-point numbers¶
-
eq_flt
(expected, value, prec)¶ -
Asserts that
value
is equal toexpected
for the firstprec
decimal places.
-
ne_flt
(expected, value, prec)¶ -
Asserts that
value
isn’t almost equal toexpected
.
Pointers¶
-
eq_ptr
(expected, value)¶ -
Asserts that
value
andexpected
point to the same address.
-
ne_ptr
(expected, value)¶ -
Asserts that
value
andexpected
doesn’t point to the same address.
-
null_ptr
(value)¶ -
Asserts that
value
isNULL
.
Strings¶
-
same
(expected, value)¶ -
Asserts that
value
andexpected
contain the same characters.
-
diff
(expected, value)¶ -
Asserts that
value
andexpected
doesn’t contain the same characters.
Memory¶
-
mem
(expected, value, size)¶ -
Asserts that the block of memory at address
value
is the same as at addressexpected
.