UTPP
Loading...
Searching...
No Matches
Assertion Checking Macros

Macros

#define CHECK(value)
 Generate a failure if value is 0. Failure message is the value itself.
#define CHECK_EX(value, ...)
 Generate a failure with the given message if value is 0.
#define CHECK_EQUAL(expected, actual)
 Generate a failure if actual value is different from expected.
#define CHECK_NAN(value)
 Generate a failure if value is not NaN.
#define CHECK_EQUAL_EX(expected, actual, ...)
 Generate a failure if actual value is different from expected. The given message is appended to the standard CHECK_EQUAL message.
#define CHECK_CLOSE(expected, actual, ...)
 Generate a failure if actual value differs from expected value with more than tolerance.
#define CHECK_CLOSE_EX(expected, actual, tolerance, ...)
 Generate a failure if actual value differs from expected value with more than given tolerance. The additional message is appended to the standard CHECK_CLOSE message.
#define CHECK_ARRAY_EQUAL(expected, actual, count)
 Generate a failure if actual array is different from expected one.
#define CHECK_ARRAY_CLOSE(expected, actual, count, ...)
 Generate a failure if actual array elements differs from expected ones with more than given tolerance.
#define CHECK_ARRAY2D_EQUAL(expected, actual, rows, columns)
 Generate a failure if 2D array actual differs from expected values.
#define CHECK_ARRAY2D_CLOSE(expected, actual, rows, columns, ...)
 Generate a failure if 2D array actual differs from expected values with more than given tolerance.
#define CHECK_THROW(expr, except)
 Generate a failure if evaluating the expression does not throw an exception of the expected type.
#define CHECK_THROW_EX(expr, except, ...)
 Generate a failure if evaluating the expression does not throw an exception of the expected type.
#define CHECK_THROW_EQUAL(expr, value, except)
 Checks if evaluating the expression triggers an exception of the given type and with the expected value.
#define CHECK_THROW_EQUAL_EX(expr, value, except, ...)
 Checks if evaluating the expression triggers an exception of the given type and with the expected value.
#define CHECK_FILE_EQUAL(expected, actual)
 Generate a failure if the two files are different.
#define FAILURE(...)
 Generate a failure.

Detailed Description

Macro-definitions used to check various conditions during tests

Macro Definition Documentation

◆ CHECK

#define CHECK ( value)

Generate a failure if value is 0. Failure message is the value itself.

Parameters
valueValue to check

◆ CHECK_ARRAY2D_CLOSE

#define CHECK_ARRAY2D_CLOSE ( expected,
actual,
rows,
columns,
... )

Generate a failure if 2D array actual differs from expected values with more than given tolerance.

Parameters
expectedExpected array values
actualActual array values
rowsNumber of rows in the 2D array
columnsNumber of columns in the 2D array
...Optional tolerance value

If no tolerance value is specified, it uses the UnitTest::default_tolerance value.

◆ CHECK_ARRAY2D_EQUAL

#define CHECK_ARRAY2D_EQUAL ( expected,
actual,
rows,
columns )

Generate a failure if 2D array actual differs from expected values.

Parameters
expectedExpected array values
actualActual array values
rowsNumber of rows in the 2D array
columnsNumber of columns in the 2D array

◆ CHECK_ARRAY_CLOSE

#define CHECK_ARRAY_CLOSE ( expected,
actual,
count,
... )

Generate a failure if actual array elements differs from expected ones with more than given tolerance.

Parameters
expectedExpected array values
actualActual array values
countNumber of values in the array
...Optional tolerance value

If no tolerance value is specified, it uses the UnitTest::default_tolerance value.

◆ CHECK_ARRAY_EQUAL

#define CHECK_ARRAY_EQUAL ( expected,
actual,
count )

Generate a failure if actual array is different from expected one.

Parameters
expectedExpected arrasy values
actualActual array values
countNumber of values in the array

◆ CHECK_CLOSE

#define CHECK_CLOSE ( expected,
actual,
... )

Generate a failure if actual value differs from expected value with more than tolerance.

Parameters
expectedExpected value
actualActual value
...Optional tolerance value

If no tolerance value is specified, it uses the UnitTest::default_tolerance value.

◆ CHECK_CLOSE_EX

#define CHECK_CLOSE_EX ( expected,
actual,
tolerance,
... )

Generate a failure if actual value differs from expected value with more than given tolerance. The additional message is appended to the standard CHECK_CLOSE message.

Parameters
expectedExpected value
actualActual value
toleranceTolerance value
...Additional parameters passed to a printf-type function

◆ CHECK_EQUAL

#define CHECK_EQUAL ( expected,
actual )

Generate a failure if actual value is different from expected.

Parameters
expectedExpected value
actualActual value

◆ CHECK_EQUAL_EX

#define CHECK_EQUAL_EX ( expected,
actual,
... )

Generate a failure if actual value is different from expected. The given message is appended to the standard CHECK_EQUAL message.

Parameters
expectedExpected value
actualActual value
...Additional parameters passed to a printf-type function

◆ CHECK_EX

#define CHECK_EX ( value,
... )

Generate a failure with the given message if value is 0.

Parameters
valueValue to check
...Additinal parameters passed to a printf-type function

◆ CHECK_FILE_EQUAL

#define CHECK_FILE_EQUAL ( expected,
actual )

Generate a failure if the two files are different.

Parameters
expectedName of file with expected values
actualName of file with actual values

◆ CHECK_NAN

#define CHECK_NAN ( value)

Generate a failure if value is not NaN.

Parameters
valueValue to check

◆ CHECK_THROW

#define CHECK_THROW ( expr,
except )

Generate a failure if evaluating the expression does not throw an exception of the expected type.

Parameters
exceptExpected exception type
exprExpression to evaluate

◆ CHECK_THROW_EQUAL

#define CHECK_THROW_EQUAL ( expr,
value,
except )

Checks if evaluating the expression triggers an exception of the given type and with the expected value.

Parameters
exprExpression to evaluate
valueExpected exception value
exceptExpected exception type

◆ CHECK_THROW_EQUAL_EX

#define CHECK_THROW_EQUAL_EX ( expr,
value,
except,
... )

Checks if evaluating the expression triggers an exception of the given type and with the expected value.

Parameters
exprExpression to evaluate
valueExpected exception value
exceptExpected exception type
...Additional parameters passed to a printf-type function

◆ CHECK_THROW_EX

#define CHECK_THROW_EX ( expr,
except,
... )

Generate a failure if evaluating the expression does not throw an exception of the expected type.

Parameters
exceptExpected exception type
exprExpression to evaluate
...Additional parameters passed to a printf-type function

◆ FAILURE

#define FAILURE ( ...)

Generate a failure.

Parameters
...Additional parameters passed to a printf-type function