include/bedrock/unitest_common.h file

Assertions, tolerances, token pasting, and startup registration.

REQUIRE and FAIL print a failure and leave the current test. INITIALIZER runs a function before main. CONCAT pastes two tokens. UNITEST_EPS_32, UNITEST_EPS_64, EPSILON, and EPSILON64 are the comparison tolerances.

Variables

jmp_buf _except_buf
Jump buffer a failed test check uses to leave the test.
const float EPSILON
const double EPSILON64

Defines

#define TRY
Open the test runner's check region.
#define CATCH
Run when a check in the matching TRY fails.
#define END_TRY
Close a TRY and CATCH pair.
#define THROW
Leave the current test check.
#define UNITEST_EPS_32
#define UNITEST_EPS_64
#define CONCAT_(x, y)
#define CONCAT(x, y)
#define INITIALIZER(f)
#define REQUIRE(cond)
Fail the current test when cond is false.
#define FAIL(fmt, ...)
Fail the current test with a printf message and leave the test.

Variable documentation

jmp_buf _except_buf

Jump buffer a failed test check uses to leave the test.

The test program defines this once, in global scope. One buffer, one active check.

Define documentation

#define REQUIRE(cond)

Fail the current test when cond is false.

Parameters
cond Expression to test.

Prints the condition and source location, then leaves the test.