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(x_test_logger(), "\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).
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).
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(x_test_logger(), "\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).
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(x_test_logger(), "\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).
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(x_test_logger(), "\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).
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.