include/bedrock/unitest.h file

Register and run a list of tests.

TEST_CASE adds a display name, tags, and a function to test_head before main. run_tests runs that list, prints each failure and the pass count, and returns the number of failures.

Classes

struct TestNode
One registered test.

Functions

static auto run_tests(void) -> int
Function to run all registered tests.

Variables

struct TestNode* test_head

Defines

#define PRINT_TEST_PASS(name, tags)
#define PRINT_TEST_FAIL(name, tags)
#define TEST_CASE(name, tags)
Register a test and open its function body.

Function documentation

static int run_tests(void)

Function to run all registered tests.

Returns Returns the number of failures (0 for success)

Define documentation

#define TEST_CASE(name, tags)

Register a test and open its function body.

Parameters
name Identifier used as the display name.
tags String literal of filter tags, for example "[arena]".

The next brace block is the test. name is pasted into the function, so it must be an identifier.