CTEST. A lightweight test for C and C++
0.0.1
|
#include <stdint.h>
Go to the source code of this file.
Macros | |
#define | C_TEST_TRUE (int)(1==1) |
#define | C_TEST_FALSE (int)(1!=1) |
#define | C_TEST_BEGIN_IGNORE _c_test_ignore(); |
#define | C_TEST_END_IGNORE _c_test_ignore_end(); |
#define | TITLE_MSG(msg) write_title(msg, INITIAL_TITLE); |
#define | ERROR_MSG(msg) write_title(msg, ERROR_CODE); |
#define | SUCCESS_MSG(msg) write_title(msg, SUCCESS_CODE); |
#define | WARN_MSG(msg) write_title(msg, WARNING_CODE); |
#define | INFO_MSG(msg) write_title(msg, INFO_CODE); |
#define | TITLE_MSG_FMT(...) write_title_fmt(INITIAL_TITLE, __VA_ARGS__); |
#define | ERROR_MSG_FMT(...) write_title_fmt(ERROR_CODE, __VA_ARGS__); |
#define | WARN_MSG_FMT(...) write_title_fmt(WARNING_CODE, __VA_ARGS__); |
#define | INFO_MSG_FMT(...) write_title_fmt(INFO_CODE, __VA_ARGS__); |
#define | SUCCESS_MSG_FMT(...) write_title_fmt(SUCCESS_CODE, __VA_ARGS__); |
#define | CTEST_SETTER(...) vargs_setter(-1, __VA_ARGS__, NULL, VA_END_SIGNATURE) |
#define | CTEST_TITLE(...) set_varg(C_TEST_VARGS_TITLE, __VA_ARGS__) |
#define | CTEST_INFO(...) set_varg(C_TEST_VARGS_INFO, __VA_ARGS__) |
#define | CTEST_WARN(...) set_varg(C_TEST_VARGS_WARNING, __VA_ARGS__) |
#define | CTEST_ON_ERROR(...) set_varg(C_TEST_VARGS_ERROR, __VA_ARGS__) |
#define | CTEST_ON_SUCCESS(...) set_varg(C_TEST_VARGS_SUCCESS, __VA_ARGS__) |
#define | CTEST_ON_SUCCESS_CB(...) set_varg_callback(C_TEST_VARGS_ON_SUCCESS_CALLBACK, __VA_ARGS__, NULL, VAS_END_SIGNATURE) |
#define | CTEST_ON_ERROR_CB(...) set_varg_callback(C_TEST_VARGS_ON_ERROR_CALLBACK, __VA_ARGS__, NULL, VAS_END_SIGNATURE) |
#define | C_ASSERT_FALSE(...) assert_false(__VA_ARGS__, VAS_END_SIGNATURE); |
#define | C_ASSERT_TRUE(...) assert_true(__VA_ARGS__, VAS_END_SIGNATURE); |
#define | C_ASSERT_EQUAL_INT(expected, ...) assert_equal_int(expected, __VA_ARGS__, VAS_END_SIGNATURE); |
#define | C_ASSERT_NOT_EQUAL_INT(unexpected, ...) assert_not_equal_int(unexpected, __VA_ARGS__, VAS_END_SIGNATURE); |
#define | C_ASSERT_EQUAL_LONG_INT(expected, ...) assert_equal_longint(expected, __VA_ARGS__, VAS_END_SIGNATURE); |
#define | C_ASSERT_NOT_EQUAL_LONG_INT(expected, ...) assert_not_equal_longint(expected, __VA_ARGS__, VAS_END_SIGNATURE); |
#define | C_ASSERT_EQUAL_UNSIGNED_LONG_INT(expected, ...) assert_equal_unsigned_longint(expected, __VA_ARGS__, VAS_END_SIGNATURE); |
#define | C_ASSERT_NOT_EQUAL_UNSIGNED_LONG_INT(expected, ...) assert_not_equal_unsigned_longint(expected, __VA_ARGS__, VAS_END_SIGNATURE); |
#define | C_ASSERT_EQUAL_DOUBLE(expected, result, ...) assert_equal_double(expected, result, __VA_ARGS__, VAS_END_SIGNATURE); |
#define | C_ASSERT_NOT_EQUAL_DOUBLE(expected, result, ...) assert_not_equal_double(expected, result, __VA_ARGS__, VAS_END_SIGNATURE); |
#define | C_ASSERT_EQUAL_BYTE(expected, result, ...) assert_equal_byte(expected, result, __VA_ARGS__, VAS_END_SIGNATURE); |
#define | C_ASSERT_NOT_EQUAL_BYTE(unexpected, result, ...) assert_not_equal_byte(unexpected, result, __VA_ARGS__, VAS_END_SIGNATURE); |
#define | C_ASSERT_NULL(...) assert_null(__VA_ARGS__, VAS_END_SIGNATURE); |
#define | C_ASSERT_NOT_NULL(...) assert_not_null(__VA_ARGS__, VAS_END_SIGNATURE); |
#define | C_ASSERT_EQUAL_STRING(expected, ...) assert_equal_string(expected, __VA_ARGS__, VAS_END_SIGNATURE); |
#define | C_ASSERT_NOT_EQUAL_STRING(expected, ...) assert_not_equal_string(expected, __VA_ARGS__, VAS_END_SIGNATURE); |
#define | C_ASSERT_EQUAL_STRING_IGNORE_CASE(expected, ...) assert_equal_string_ignore_case(expected, __VA_ARGS__, VAS_END_SIGNATURE); |
#define | C_ASSERT_NOT_EQUAL_STRING_IGNORE_CASE(expected, ...) assert_not_equal_string_ignore_case(expected, __VA_ARGS__, VAS_END_SIGNATURE); |
#define | C_ASSERT_EQUAL_U8(expected, ...) assert_equal_u8(expected, __VA_ARGS__, VAS_END_SIGNATURE); |
#define | C_ASSERT_NOT_EQUAL_U8(expected, ...) assert_not_equal_u8(expected, __VA_ARGS__, VAS_END_SIGNATURE); |
#define | C_ASSERT_EQUAL_S8(expected, ...) assert_equal_s8(expected, __VA_ARGS__, VAS_END_SIGNATURE); |
#define | C_ASSERT_NOT_EQUAL_S8(expected, ...) assert_not_equal_s8(expected, __VA_ARGS__, VAS_END_SIGNATURE); |
#define | C_ASSERT_EQUAL_U16(expected, ...) assert_equal_u16(expected, __VA_ARGS__, VAS_END_SIGNATURE); |
#define | C_ASSERT_NOT_EQUAL_U16(expected, ...) assert_not_equal_u16(expected, __VA_ARGS__, VAS_END_SIGNATURE); |
#define | C_ASSERT_EQUAL_S16(expected, ...) assert_equal_s16(expected, __VA_ARGS__, VAS_END_SIGNATURE); |
#define | C_ASSERT_NOT_EQUAL_S16(expected, ...) assert_not_equal_s16(expected, __VA_ARGS__, VAS_END_SIGNATURE); |
#define | C_ASSERT_EQUAL_U32(expected, ...) assert_equal_u32(expected, __VA_ARGS__, VAS_END_SIGNATURE); |
#define | C_ASSERT_NOT_EQUAL_U32(expected, ...) assert_not_equal_u32(expected, __VA_ARGS__, VAS_END_SIGNATURE); |
#define | C_ASSERT_EQUAL_S32(expected, ...) assert_equal_s32(expected, __VA_ARGS__, VAS_END_SIGNATURE); |
#define | C_ASSERT_NOT_EQUAL_S32(expected, ...) assert_not_equal_s32(expected, __VA_ARGS__, VAS_END_SIGNATURE); |
#define | C_ASSERT_EQUAL_U64(expected, ...) assert_equal_u64(expected, __VA_ARGS__, VAS_END_SIGNATURE); |
#define | C_ASSERT_NOT_EQUAL_U64(expected, ...) assert_not_equal_u64(expected, __VA_ARGS__, VAS_END_SIGNATURE); |
#define | C_ASSERT_EQUAL_S64(expected, ...) assert_equal_s64(expected, __VA_ARGS__, VAS_END_SIGNATURE); |
#define | C_ASSERT_NOT_EQUAL_S64(expected, ...) assert_not_equal_s64(expected, __VA_ARGS__, VAS_END_SIGNATURE); |
#define | C_ASSERT_FAIL(...) assert_fail(__VA_ARGS__, VAS_END_SIGNATURE); |
Functions | |
void | on_add_test (header_on_cb) |
void | rm_on_add_test () |
void | on_begin_test (header_on_cb) |
void | rm_begin_test () |
void | on_test (header_on_cb) |
void | rm_on_test () |
void | on_end_test (header_on_cb) |
void | rm_on_end_test () |
void | on_abort (header_on_cb) |
void | rm_on_abort () |
void | end_tests () |
A simplest lightweight compatible C test suite for low level C and C++ applications.
Definition in file asserts.h.
#define C_ASSERT_EQUAL_BYTE | ( | expected, | |
result, | |||
... | |||
) | assert_equal_byte(expected, result, __VA_ARGS__, VAS_END_SIGNATURE); |
Checks two memory pointers with same size are equals.
expected | Expected value |
result | Result value |
size | Size of expected and result pointers |
... | Optional. See CTEST_SETTER() for details |
#define C_ASSERT_EQUAL_DOUBLE | ( | expected, | |
result, | |||
... | |||
) | assert_equal_double(expected, result, __VA_ARGS__, VAS_END_SIGNATURE); |
Checks if expected and result value are equal.
expected | Unexpected value |
result | Result value |
delta | Delta double value |
... | Optional. See CTEST_SETTER() for details |
#define C_ASSERT_EQUAL_INT | ( | expected, | |
... | |||
) | assert_equal_int(expected, __VA_ARGS__, VAS_END_SIGNATURE); |
Checks if expected and result value are equal.
expected | Expected value |
result | Result value |
... | Optional. See CTEST_SETTER() for details |
#define C_ASSERT_EQUAL_LONG_INT | ( | expected, | |
... | |||
) | assert_equal_longint(expected, __VA_ARGS__, VAS_END_SIGNATURE); |
Checks if expected and result value are equal.
expected | Expected value |
result | Result value |
... | Optional. See CTEST_SETTER() for details |
#define C_ASSERT_EQUAL_S16 | ( | expected, | |
... | |||
) | assert_equal_s16(expected, __VA_ARGS__, VAS_END_SIGNATURE); |
Checks if expected and result value are equal.
expected | Expected value |
result | Result value |
... | Optional. See CTEST_SETTER() for details |
#define C_ASSERT_EQUAL_S32 | ( | expected, | |
... | |||
) | assert_equal_s32(expected, __VA_ARGS__, VAS_END_SIGNATURE); |
Checks if expected and result value are equal.
expected | Expected value |
result | Result value |
... | Optional. See CTEST_SETTER() for details |
#define C_ASSERT_EQUAL_S64 | ( | expected, | |
... | |||
) | assert_equal_s64(expected, __VA_ARGS__, VAS_END_SIGNATURE); |
Checks if expected and result value are equal.
expected | Expected value |
result | Result value |
... | Optional. See CTEST_SETTER() for details |
#define C_ASSERT_EQUAL_S8 | ( | expected, | |
... | |||
) | assert_equal_s8(expected, __VA_ARGS__, VAS_END_SIGNATURE); |
Checks if expected and result value are equal.
expected | Expected value |
result | Result value |
... | Optional. See CTEST_SETTER() for details |
#define C_ASSERT_EQUAL_STRING | ( | expected, | |
... | |||
) | assert_equal_string(expected, __VA_ARGS__, VAS_END_SIGNATURE); |
Checks if two strings are equal.
expected | Expected value |
result | Result value |
... | Optional. See CTEST_SETTER() for details |
#define C_ASSERT_EQUAL_STRING_IGNORE_CASE | ( | expected, | |
... | |||
) | assert_equal_string_ignore_case(expected, __VA_ARGS__, VAS_END_SIGNATURE); |
Checks if two strings are equal ignoring case.
Expected | Expected value |
result | Result value |
... | Optional. See CTEST_SETTER() for details |
#define C_ASSERT_EQUAL_U16 | ( | expected, | |
... | |||
) | assert_equal_u16(expected, __VA_ARGS__, VAS_END_SIGNATURE); |
Checks if expected and result value are equal.
expected | Expected value |
result | Result value |
... | Optional. See CTEST_SETTER() for details |
#define C_ASSERT_EQUAL_U32 | ( | expected, | |
... | |||
) | assert_equal_u32(expected, __VA_ARGS__, VAS_END_SIGNATURE); |
Checks if expected and result value are equal.
expected | Expected value |
result | Result value |
... | Optional. See CTEST_SETTER() for details |
#define C_ASSERT_EQUAL_U64 | ( | expected, | |
... | |||
) | assert_equal_u64(expected, __VA_ARGS__, VAS_END_SIGNATURE); |
Checks if expected and result value are equal.
expected | Expected value |
result | Result value |
... | Optional. See CTEST_SETTER() for details |
#define C_ASSERT_EQUAL_U8 | ( | expected, | |
... | |||
) | assert_equal_u8(expected, __VA_ARGS__, VAS_END_SIGNATURE); |
Checks if expected and result value are equal.
expected | Expected value |
result | Result value |
... | Optional. See CTEST_SETTER() for details |
#define C_ASSERT_EQUAL_UNSIGNED_LONG_INT | ( | expected, | |
... | |||
) | assert_equal_unsigned_longint(expected, __VA_ARGS__, VAS_END_SIGNATURE); |
Checks if expected and result value are equal.
expected | Expected value |
result | Result value |
... | Optional. See CTEST_SETTER() for details |
#define C_ASSERT_FAIL | ( | ... | ) | assert_fail(__VA_ARGS__, VAS_END_SIGNATURE); |
Fails on execution.
... | Optional. See CTEST_SETTER() for details |
#define C_ASSERT_FALSE | ( | ... | ) | assert_false(__VA_ARGS__, VAS_END_SIGNATURE); |
Checks if result is FALSE
result | Result value |
... | Optional. See CTEST_SETTER() for details |
#define C_ASSERT_NOT_EQUAL_BYTE | ( | unexpected, | |
result, | |||
... | |||
) | assert_not_equal_byte(unexpected, result, __VA_ARGS__, VAS_END_SIGNATURE); |
Checks two memory pointers with same size are not equals.
unexpected | Unexpected value |
result | Result value |
size | Size of unexpected and result pointers |
... | Optional. See CTEST_SETTER() for details |
#define C_ASSERT_NOT_EQUAL_DOUBLE | ( | expected, | |
result, | |||
... | |||
) | assert_not_equal_double(expected, result, __VA_ARGS__, VAS_END_SIGNATURE); |
Checks if expected and result value are NOT equal.
unexpected | Expected value |
result | Result value |
delta | Delta double value |
... | Optional. See CTEST_SETTER() for details |
#define C_ASSERT_NOT_EQUAL_INT | ( | unexpected, | |
... | |||
) | assert_not_equal_int(unexpected, __VA_ARGS__, VAS_END_SIGNATURE); |
Checks if expected and result value are NOT equal.
unexpected | Unexpected value |
result | Result value |
... | Optional. See CTEST_SETTER() for details |
#define C_ASSERT_NOT_EQUAL_LONG_INT | ( | expected, | |
... | |||
) | assert_not_equal_longint(expected, __VA_ARGS__, VAS_END_SIGNATURE); |
Checks if expected and result value are NOT equal.
unexpected | Unexpected value |
result | Result value |
... | Optional. See CTEST_SETTER() for details |
#define C_ASSERT_NOT_EQUAL_S16 | ( | expected, | |
... | |||
) | assert_not_equal_s16(expected, __VA_ARGS__, VAS_END_SIGNATURE); |
Checks if expected and result value are NOT equal.
unexpected | Unexpected value |
result | Result value |
... | Optional. See CTEST_SETTER() for details |
#define C_ASSERT_NOT_EQUAL_S32 | ( | expected, | |
... | |||
) | assert_not_equal_s32(expected, __VA_ARGS__, VAS_END_SIGNATURE); |
Checks if expected and result value are NOT equal.
unexpected | Unexpected value |
result | Result value |
... | Optional. See CTEST_SETTER() for details |
#define C_ASSERT_NOT_EQUAL_S64 | ( | expected, | |
... | |||
) | assert_not_equal_s64(expected, __VA_ARGS__, VAS_END_SIGNATURE); |
Checks if expected and result value are NOT equal.
unexpected | Unexpected value |
result | Result value |
... | Optional. See CTEST_SETTER() for details |
#define C_ASSERT_NOT_EQUAL_S8 | ( | expected, | |
... | |||
) | assert_not_equal_s8(expected, __VA_ARGS__, VAS_END_SIGNATURE); |
Checks if expected and result value are NOT equal.
unexpected | Unexpected value |
result | Result value |
... | Optional. See CTEST_SETTER() for details |
#define C_ASSERT_NOT_EQUAL_STRING | ( | expected, | |
... | |||
) | assert_not_equal_string(expected, __VA_ARGS__, VAS_END_SIGNATURE); |
Checks if two strings are not equal.
unexpected | Unexpected value |
result | Result value |
... | Optional. See CTEST_SETTER() for details |
#define C_ASSERT_NOT_EQUAL_STRING_IGNORE_CASE | ( | expected, | |
... | |||
) | assert_not_equal_string_ignore_case(expected, __VA_ARGS__, VAS_END_SIGNATURE); |
Checks if two strings are NOT equal ignoring case.
unexpected | Unexpected value |
result | Result value |
... | Optional. See CTEST_SETTER() for details |
#define C_ASSERT_NOT_EQUAL_U16 | ( | expected, | |
... | |||
) | assert_not_equal_u16(expected, __VA_ARGS__, VAS_END_SIGNATURE); |
Checks if expected and result value are NOT equal.
unexpected | Unexpected value |
result | Result value |
... | Optional. See CTEST_SETTER() for details |
#define C_ASSERT_NOT_EQUAL_U32 | ( | expected, | |
... | |||
) | assert_not_equal_u32(expected, __VA_ARGS__, VAS_END_SIGNATURE); |
Checks if expected and result value are NOT equal.
unexpected | Unexpected value |
result | Result value |
... | Optional. See CTEST_SETTER() for details |
#define C_ASSERT_NOT_EQUAL_U64 | ( | expected, | |
... | |||
) | assert_not_equal_u64(expected, __VA_ARGS__, VAS_END_SIGNATURE); |
Checks if expected and result value are NOT equal.
unexpected | Unexpected value |
result | Result value |
... | Optional. See CTEST_SETTER() for details |
#define C_ASSERT_NOT_EQUAL_U8 | ( | expected, | |
... | |||
) | assert_not_equal_u8(expected, __VA_ARGS__, VAS_END_SIGNATURE); |
Checks if expected and result value are NOT equal.
unexpected | Unexpected value |
result | Result value |
... | Optional. See CTEST_SETTER() for details |
#define C_ASSERT_NOT_EQUAL_UNSIGNED_LONG_INT | ( | expected, | |
... | |||
) | assert_not_equal_unsigned_longint(expected, __VA_ARGS__, VAS_END_SIGNATURE); |
Checks if expected and result value are NOT equal.
unexpected | Unexpected value |
result | Result value |
... | Optional. See CTEST_SETTER() for details |
#define C_ASSERT_NOT_NULL | ( | ... | ) | assert_not_null(__VA_ARGS__, VAS_END_SIGNATURE); |
Checks if pointer is not NULL
result | Result pointer |
... | Optional. See CTEST_SETTER() for details |
#define C_ASSERT_NULL | ( | ... | ) | assert_null(__VA_ARGS__, VAS_END_SIGNATURE); |
Checks if pointer is NULL
result | Result pointer |
... | Optional. See CTEST_SETTER() for details |
#define C_ASSERT_TRUE | ( | ... | ) | assert_true(__VA_ARGS__, VAS_END_SIGNATURE); |
Checks if result is TRUE
result | Result value |
... | Optional. See CTEST_SETTER() for details |
#define C_TEST_BEGIN_IGNORE _c_test_ignore(); |
#define C_TEST_END_IGNORE _c_test_ignore_end(); |
#define CTEST_INFO | ( | ... | ) | set_varg(C_TEST_VARGS_INFO, __VA_ARGS__) |
Set a info message to test.
It is only used with CTEST_SETTER macro
#define CTEST_ON_ERROR | ( | ... | ) | set_varg(C_TEST_VARGS_ERROR, __VA_ARGS__) |
#define CTEST_ON_ERROR_CB | ( | ... | ) | set_varg_callback(C_TEST_VARGS_ON_ERROR_CALLBACK, __VA_ARGS__, NULL, VAS_END_SIGNATURE) |
#define CTEST_ON_SUCCESS | ( | ... | ) | set_varg(C_TEST_VARGS_SUCCESS, __VA_ARGS__) |
#define CTEST_ON_SUCCESS_CB | ( | ... | ) | set_varg_callback(C_TEST_VARGS_ON_SUCCESS_CALLBACK, __VA_ARGS__, NULL, VAS_END_SIGNATURE) |
#define CTEST_SETTER | ( | ... | ) | vargs_setter(-1, __VA_ARGS__, NULL, VA_END_SIGNATURE) |
Setter for CTEST.
This setter allows callback function such on_error and on_success and add custom message, warn, error, info and title
#define CTEST_TITLE | ( | ... | ) | set_varg(C_TEST_VARGS_TITLE, __VA_ARGS__) |
Set a title message to test.
It is only used with CTEST_SETTER macro
#define CTEST_WARN | ( | ... | ) | set_varg(C_TEST_VARGS_WARNING, __VA_ARGS__) |
Set a warn message to test.
It is only used with CTEST_SETTER macro
#define ERROR_MSG | ( | msg | ) | write_title(msg, ERROR_CODE); |
Add error text message.
#define ERROR_MSG_FMT | ( | ... | ) | write_title_fmt(ERROR_CODE, __VA_ARGS__); |
#define INFO_MSG | ( | msg | ) | write_title(msg, INFO_CODE); |
#define INFO_MSG_FMT | ( | ... | ) | write_title_fmt(INFO_CODE, __VA_ARGS__); |
#define SUCCESS_MSG | ( | msg | ) | write_title(msg, SUCCESS_CODE); |
Add success text message.
#define SUCCESS_MSG_FMT | ( | ... | ) | write_title_fmt(SUCCESS_CODE, __VA_ARGS__); |
Add success text message with formatted string.
#define TITLE_MSG | ( | msg | ) | write_title(msg, INITIAL_TITLE); |
Add title text message.
#define TITLE_MSG_FMT | ( | ... | ) | write_title_fmt(INITIAL_TITLE, __VA_ARGS__); |
#define WARN_MSG | ( | msg | ) | write_title(msg, WARNING_CODE); |
Add warning text message.
#define WARN_MSG_FMT | ( | ... | ) | write_title_fmt(WARNING_CODE, __VA_ARGS__); |
void end_tests | ( | ) |
This function is called in every tests.
It shows statistics of the tests
void on_abort | ( | header_on_cb | callback | ) |
Call function callback if any test fails.
void on_add_test | ( | header_on_cb | callback | ) |
Call function callback on adding test event.
void on_begin_test | ( | header_on_cb | callback | ) |
Call function callback on each beginning test event.
void on_end_test | ( | header_on_cb | callback | ) |
Call function callback if at the end of all tests (if success)
void on_test | ( | header_on_cb | callback | ) |
Call function callback on each test event.
void rm_begin_test | ( | ) |
Removes callback pointer from global on_begin_test context.
void rm_on_abort | ( | ) |
Removes callback pointer from global on_abort context.
void rm_on_add_test | ( | ) |
Removes callback pointer from global rm_on_add_test context.
void rm_on_end_test | ( | ) |
Removes callback pointer from global rm_on_end_test context.
void rm_on_test | ( | ) |
Removes callback pointer from global on_test context.