Macro

X_TEST_VERSION_MAJOR

#define X_TEST_VERSION_MAJOR 1
Macro

X_TEST_VERSION_MINOR

#define X_TEST_VERSION_MINOR 0
Macro

X_TEST_VERSION_PATCH

#define X_TEST_VERSION_PATCH 0
Macro

X_TEST_SUCCESS

#define X_TEST_SUCCESS 0
Macro

X_TEST_FAIL

#define X_TEST_FAIL -1
Macro

XLOG_GREEN

#define XLOG_GREEN(msg, ...) x_log_raw(stdout, XLOG_LEVEL_INFO, XLOG_COLOR_GREEN, XLOG_COLOR_BLACK, 0, msg, __VA_ARGS__, 0)
Macro

XLOG_WHITE

#define XLOG_WHITE(msg, ...) x_log_raw(stdout, XLOG_LEVEL_INFO, XLOG_COLOR_WHITE, XLOG_COLOR_BLACK, 0, msg, __VA_ARGS__, 0)
Macro

XLOG_RED

#define XLOG_RED(msg, ...) x_log_raw(stderr, XLOG_LEVEL_INFO, XLOG_COLOR_RED, XLOG_COLOR_BLACK, 0, msg, __VA_ARGS__, 0)
Macro

ASSERT_TRUE

Assert that an expression evaluates to true; logs an error and returns 1 from the test on failure.

#define ASSERT_TRUE(expr) do{\
if(!(expr)){\
x_log_error("\t%s:%d: Assertion failed: %s\n", __FILE__, __LINE__, (#expr));\
return 1;\
}\
}while(0)

Parameters

expr
Boolean expression to evaluate.

Returns

Nothing (on failure, returns 1 from the calling function).

Macro

ASSERT_FALSE

Assert that an expression evaluates to false; logs an error and returns 1 from the test on failure.

#define ASSERT_FALSE(expr) ASSERT_TRUE(!(expr))

Parameters

expr
Boolean expression to evaluate.

Returns

Nothing (on failure, returns 1 from the calling function).

Macro

ASSERT_EQ

Assert that two values are equal; logs an error and returns 1 from the test on failure.

#define ASSERT_EQ(actual, expected) do{\
if((actual)!=(expected)){\
x_log_error("\t%s:%d: Assertion failed: %s == %s", __FILE__, __LINE__, #actual, #expected);\
return 1;\
}\
}while(0)

Parameters

actual
Value produced by the code under test.
expected
Value the test expects.

Returns

Nothing (on failure, returns 1 from the calling function).

Macro

X_TEST_FLOAT_EPSILON

Default epsilon used by ASSERT_FLOAT_EQ for approximate float comparisons.

#define X_TEST_FLOAT_EPSILON 0.1f

Parameters

None.
@return Nothing.
Macro

ASSERT_FLOAT_EQ

Assert that two floating-point values are approximately equal within X_TEST_FLOAT_EPSILON.

#define ASSERT_FLOAT_EQ(actual, expected) do{\
if(fabs((actual)-(expected))>X_TEST_FLOAT_EPSILON){\
x_log_error("\t%s:%d: Assertion failed: %s == %s", __FILE__, __LINE__, #actual, #expected);\
return 1;\
}\
}while(0)

Parameters

actual
Floating-point value produced by the code under test.
expected
Floating-point value the test expects.

Returns

Nothing (on failure, returns 1 from the calling function).

Macro

ASSERT_NEQ

Assert that two values are not equal; logs an error and returns 1 from the test on failure.

#define ASSERT_NEQ(actual, expected) do{\
if((actual)==(expected)){\
x_log_error("\t%s:%d: Assertion failed: %s != %s", __FILE__, __LINE__, #actual, #expected);\
return 1;\
}\
}while(0)

Parameters

actual
Value produced by the code under test.
expected
Value the test expects it to differ from.

Returns

Nothing (on failure, returns 1 from the calling function).

Typedef

STDXTestFunction

Test function signature used by the STDX test runner.

typedef int32_t(*STDXTestFunction)();

Parameters

None.
@return 0 on success, 1 (or non-zero) on failure.
Struct

STDXTestCase

typedef struct{
  const char *name;
  STDXTestFunction func;
}STDXTestCase;
Macro

X_TEST

#define X_TEST(name) {#name, name}
Function

x_tests_run

int x_tests_run(
 STDXTestCase *tests,
 int32_t num_tests
);