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:
  • NAMEstring 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, where A and B are integers.

Parameters:
  • Along long First integer.

  • OP – Comparison operator.

  • Blong long Second integer.

utest_assert_uint(A, OP, B)

Assert that A OP B must be true, where A and B are unsigned integers.

Parameters:
  • Aunsigned long long First integer.

  • OP – Comparison operator.

  • Bunsigned long long Second integer.

utest_assert_float(A, OP, B)

Assert that A OP B must be true, where A and B are floating point numbers.

Parameters:
  • Adouble First float.

  • OP – Comparison operator.

  • Bdouble Second float.

utest_assert_ptr(A, OP, B)

Assert that A OP B must be true, where A and B are pointers.

Parameters:
  • Avoid * First pointer.

  • OP – Comparison operator.

  • Bvoid * Second pointer.

utest_assert_string(A, OP, B)

Assert that strcmp(A, B) OP 0 must be true.

Parameters:
  • Achar const * First string.

  • OP – Comparison operator.

  • Bchar const * Second string.

utest_assert_buf(A, OP, B, SIZE)

Assert that memcmp(A, B, SIZE) OP 0 must be true.

Parameters:
  • Avoid * First buffer.

  • OP – Comparison operator.

  • Bvoid * Second buffer.

  • SIZEsize_t Buffer size.

utest_assert_ustring(A, OP, B)

Assert that ustring_compare(A, B) OP 0 must be true.

Parameters:
  • AUString First string.

  • OP – Comparison operator.

  • BUString Second string.

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.