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:

c
#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 to expected.

ne(expected, value)

Asserts that value isn’t equal to expected.

Floating-point numbers

eq_flt(expected, value, prec)

Asserts that value is equal to expected for the first prec decimal places.

ne_flt(expected, value, prec)

Asserts that value isn’t almost equal to expected.

Pointers

eq_ptr(expected, value)

Asserts that value and expected point to the same address.

ne_ptr(expected, value)

Asserts that value and expected doesn’t point to the same address.

null_ptr(value)

Asserts that value is NULL.

Strings

same(expected, value)

Asserts that value and expected contain the same characters.

diff(expected, value)

Asserts that value and expected 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 address expected.