Tests
-
bool utest_leak_start(void)
Start detection of memory leaks.
- Returns:
True if detection started successfully, false otherwise.
-
bool utest_leak_end(void)
Ends detection of memory leaks and prints detected leaks to the console.
- Returns:
True if no leaks were detected, false otherwise.
-
utest_main(CODE)
Defines the main test function.
- Parameters:
CODE – Code to execute, generally a sequence of utest_run statements.
-
utest_run(NAME, ...)
Runs a test batch.
- Parameters:
NAME –
string literal
Name of the test batch.... – Comma separated list of
(void) -> bool
test functions.
-
utest_assert(EXP)
Assert that the specified expression must be true.
- Parameters:
EXP – Boolean expression.
-
utest_assert_false(EXP)
Assert that the specified expression must be false.
- Parameters:
EXP – Boolean expression.
-
utest_assert_not_null(EXP)
Assert that the specified expression must not be NULL.
- Parameters:
EXP – Expression returning any pointer.
-
utest_assert_int(A, OP, B)
Assert that
A OP B
must be true, whereA
andB
are integers.- Parameters:
A –
long long
First integer.OP – Comparison operator.
B –
long long
Second integer.
-
utest_assert_uint(A, OP, B)
Assert that
A OP B
must be true, whereA
andB
are unsigned integers.- Parameters:
A –
unsigned long long
First integer.OP – Comparison operator.
B –
unsigned long long
Second integer.
-
utest_assert_float(A, OP, B)
Assert that
A OP B
must be true, whereA
andB
are floating point numbers.- Parameters:
A –
double
First float.OP – Comparison operator.
B –
double
Second float.
-
utest_assert_ptr(A, OP, B)
Assert that
A OP B
must be true, whereA
andB
are pointers.- Parameters:
A –
void *
First pointer.OP – Comparison operator.
B –
void *
Second pointer.
-
utest_assert_string(A, OP, B)
Assert that
strcmp(A, B) OP 0
must be true.- Parameters:
A –
char const *
First string.OP – Comparison operator.
B –
char const *
Second string.
-
utest_assert_buf(A, OP, B, SIZE)
Assert that
memcmp(A, B, SIZE) OP 0
must be true.- Parameters:
A –
void *
First buffer.OP – Comparison operator.
B –
void *
Second buffer.SIZE –
size_t
Buffer size.
-
utest_assert_ustring(A, OP, B)
Assert that
ustring_compare(A, B) OP 0
must be true.
-
utest_assert_critical(EXP)
Assert that the specified expression must be true.
Abort the tests if it is false.
- Parameters:
EXP – Boolean expression.
-
utest_assert_wrap(EXP, CODE, ...)
Utility macro for test assertions.
- Parameters:
EXP – Expression.
CODE – Any custom code to run after printing the failure reason.
... – Failure reason as printf arguments.