Assertion reference¶
This is an exhaustive list of all assertion macros that Criterion provides.
As each assert
macros have an expect
counterpart with the exact same
number of parameters and name suffix, there is no benefit in adding expect
macros to this list. Hence only assert
macros are represented here.
All assert
macros may take an optional printf
format string and
parameters.
Base Assertions¶
-
group
BaseAsserts
Defines
-
cr_assert_fail
(FormatString, ...)¶ Fails always.
The test is marked as failure and the execution of the function is aborted.
The optional string is printed on failure.
- Parameters
FormatString
: (optional) printf-like format string...
: (optional) format string parameters
-
cr_skip_test
(FormatString, ...)¶ Skips the test.
The test is marked as skipped and the execution of the function is aborted.
-
cr_expect_fail
(FormatString, ...)¶ Fails always.
The test is marked as failure but the execution will continue.
The optional string is printed on failure.
- Parameters
FormatString
: (optional) printf-like format string...
: (optional) format string parameters
-
cr_assert
(Condition, FormatString, ...)¶ Passes if Condition is true.
Evaluates the condition and passes if it is true. Otherwise the test is marked as failure and the execution of the function is aborted.
The optional string is printed on failure.
- Parameters
Condition
: Condition to testFormatString
: (optional) printf-like format string...
: (optional) format string parameters
-
cr_expect
(Condition, FormatString, ...)¶ Passes if Condition is true.
Evaluates the condition and passes if it is true. Otherwise the test is marked as failure but the execution will continue.
The optional string is printed on failure.
- Parameters
Condition
: Condition to testFormatString
: (optional) printf-like format string...
: (optional) format string parameters
-
cr_assert_not
(Condition, FormatString, ...)¶ Passes if Condition is false.
Evaluates the condition and passes if it is false. Otherwise the test is marked as failure and the execution of the function is aborted.
The optional string is printed on failure.
- Parameters
Condition
: Condition to testFormatString
: (optional) printf-like format string...
: (optional) format string parameters
-
cr_expect_not
(Condition, FormatString, ...)¶ Passes if Condition is false.
Evaluates the condition and passes if it is false. Otherwise the test is marked as failure but the execution will continue.
The optional string is printed on failure.
- Parameters
Condition
: Condition to testFormatString
: (optional) printf-like format string...
: (optional) format string parameters
-
Common Assertions¶
-
group
CommonBinAsserts
Defines
-
cr_assert_eq
(Actual, Expected, FormatString, ...)¶ Passes if Actual is equal to Expected.
Passes if Actual is equal to Expected. Otherwise the test is marked as failure and the execution of the function is aborted.
The optional string is printed on failure.
- Note
- Compatible with C++ operator overloading.
- Parameters
Actual
: Value to testExpected
: Expected valueFormatString
: (optional) printf-like format string...
: (optional) format string parameters
-
cr_expect_eq
(Actual, Expected, FormatString, ...)¶ Passes if Actual is equal to Expected.
Passes if Actual is equal to Expected. Otherwise the test is marked as failure but the execution will continue.
The optional string is printed on failure.
- Note
- Compatible with C++ operator overloading.
- Parameters
Actual
: Value to testExpected
: Expected valueFormatString
: (optional) printf-like format string...
: (optional) format string parameters
-
cr_assert_neq
(Actual, Unexpected, FormatString, ...)¶ Passes if Actual is not equal to Unexpected.
Passes if Actual is not equal to Unexpected Otherwise the test is marked as failure and the execution of the function is aborted.
The optional string is printed on failure.
- Note
- Compatible with C++ operator overloading.
- Parameters
Actual
: Value to testUnexpected
: Unexpected ValueFormatString
: (optional) printf-like format string...
: (optional) format string parameters
-
cr_expect_neq
(Actual, Unexpected, FormatString, ...)¶ Passes if Actual is not equal to Unexpected.
Passes if Actual is not equal to Unexpected. Otherwise the test is marked as failure but the execution will continue.
The optional string is printed on failure.
- Note
- Compatible with C++ operator overloading.
- Parameters
Actual
: Value to testUnexpected
: Unexpected ValueFormatString
: (optional) printf-like format string...
: (optional) format string parameters
-
cr_assert_lt
(Actual, Reference, FormatString, ...)¶ Passes if Actual is less than Reference.
Passes if Actual is less than Reference. Otherwise the test is marked as failure and the execution of the function is aborted.
The optional string is printed on failure.
- Note
- Compatible with C++ operator overloading.
- Parameters
Actual
: Value to testReference
: Reference valueFormatString
: (optional) printf-like format string...
: (optional) format string parameters
-
cr_expect_lt
(Actual, Reference, FormatString, ...)¶ Passes if Actual is less than Reference.
Passes if Actual is less than Reference. Otherwise the test is marked as failure but the execution will continue.
The optional string is printed on failure.
- Note
- Compatible with C++ operator overloading.
- Parameters
Actual
: Value to testReference
: Reference valueFormatString
: (optional) printf-like format string...
: (optional) format string parameters
-
cr_assert_leq
(Actual, Reference, FormatString, ...)¶ Passes if Actual is less or equal to Reference.
Passes if Actual is less or equal to Reference. Otherwise the test is marked as failure and the execution of the function is aborted.
The optional string is printed on failure.
- Note
- Compatible with C++ operator overloading.
- Parameters
Actual
: Value to testReference
: Reference valueFormatString
: (optional) printf-like format string...
: (optional) format string parameters
-
cr_expect_leq
(Actual, Reference, FormatString, ...)¶ Passes if Actual is less or equal to Reference.
Passes if Actual is less or equal to Reference. Otherwise the test is marked as failure but the execution will continue.
The optional string is printed on failure.
- Note
- Compatible with C++ operator overloading.
- Parameters
Actual
: Value to testReference
: Reference valueFormatString
: (optional) printf-like format string...
: (optional) format string parameters
-
cr_assert_gt
(Actual, Reference, FormatString, ...)¶ Passes if Actual is greater than Reference.
Passes if Actual is greater than Reference. Otherwise the test is marked as failure and the execution of the function is aborted.
The optional string is printed on failure.
- Note
- Compatible with C++ operator overloading.
- Parameters
Actual
: Value to testReference
: Reference valueFormatString
: (optional) printf-like format string...
: (optional) format string parameters
-
cr_expect_gt
(Actual, Reference, FormatString, ...)¶ Passes if Actual is greater than Reference.
Passes if Actual is greater than Reference. Otherwise the test is marked as failure but the execution will continue.
The optional string is printed on failure.
- Note
- Compatible with C++ operator overloading.
- Parameters
Actual
: Value to testReference
: Reference valueFormatString
: (optional) printf-like format string...
: (optional) format string parameters
-
cr_assert_geq
(Actual, Reference, FormatString, ...)¶ Passes if Actual is greater or equal to Reference.
Passes if Actual is greater or equal to Reference. Otherwise the test is marked as failure and the execution of the function is aborted.
The optional string is printed on failure.
- Note
- Compatible with C++ operator overloading.
- Parameters
Actual
: Value to testReference
: Reference valueFormatString
: (optional) printf-like format string...
: (optional) format string parameters
-
cr_expect_geq
(Actual, Reference, FormatString, ...)¶ Passes if Actual is greater or equal to Reference.
Passes if Actual is greater or equal to Reference. Otherwise the test is marked as failure but the execution will continue.
The optional string is printed on failure.
- Note
- Compatible with C++ operator overloading.
- Parameters
Actual
: Value to testReference
: Reference valueFormatString
: (optional) printf-like format string...
: (optional) format string parameters
-
-
group
CommonUnaryAsserts
Defines
-
cr_assert_null
(Value, FormatString, ...)¶ Passes if Value is NULL.
Passes if Value is NULL. Otherwise the test is marked as failure and the execution of the function is aborted.
The optional string is printed on failure.
- Parameters
Actual
: Value to testFormatString
: (optional) printf-like format string...
: (optional) format string parameters
-
cr_expect_null
(Value, FormatString, ...)¶ Passes if Value is NULL.
Passes if Value is NULL. Otherwise the test is marked as failure but the execution will continue.
The optional string is printed on failure.
- Parameters
Actual
: Value to testFormatString
: (optional) printf-like format string...
: (optional) format string parameters
-
cr_assert_not_null
(Value, FormatString, ...)¶ Passes if Value is not NULL.
Passes if Value is not NULL. Otherwise the test is marked as failure and the execution of the function is aborted.
The optional string is printed on failure.
- Parameters
Value
: Value to testFormatString
: (optional) printf-like format string...
: (optional) format string parameters
-
cr_expect_not_null
(Value, FormatString, ...)¶ Passes if Value is not NULL.
Passes if Value is not NULL. Otherwise the test is marked as failure but the execution will continue.
The optional string is printed on failure.
- Parameters
Value
: Value to testFormatString
: (optional) printf-like format string...
: (optional) format string parameters
-
-
group
FloatAsserts
Defines
-
cr_assert_float_eq
(Actual, Expected, Epsilon, FormatString, ...)¶ Passes if Actual is equal to Expected with a tolerance of Epsilon.
Passes if Actual is equal to Expected with a tolerance of Epsilon. Otherwise the test is marked as failure and the execution of the function is aborted.
The optional string is printed on failure.
- Note
- Use this to test equality between floats
- Parameters
Actual
: Value to testExpected
: Expected valueEpsilon
: Tolerance between Actual and ExpectedFormatString
: (optional) printf-like format string...
: (optional) format string parameters
-
cr_expect_float_eq
(Actual, Expected, Epsilon, FormatString, ...)¶ Passes if Actual is equal to Expected with a tolerance of Epsilon.
Passes if Actual is equal to Expected with a tolerance of Epsilon. Otherwise the test is marked as failure but the execution will continue.
The optional string is printed on failure.
- Note
- Use this to test equality between floats
- Parameters
Actual
: Value to testExpected
: Expected valueEpsilon
: Tolerance between Actual and ExpectedFormatString
: (optional) printf-like format string...
: (optional) format string parameters
-
cr_assert_float_neq
(Actual, Unexpected, Epsilon, FormatString, ...)¶ Passes if Actual is not equal to Unexpected with a tolerance of Epsilon.
Passes if Actual is not equal to Unexpected with a tolerance of Epsilon. Otherwise the test is marked as failure and the execution of the function is aborted.
The optional string is printed on failure.
- Note
- Use this to test inequality between floats
- Parameters
Actual
: Value to testUnexpected
: Unexpected valueEpsilon
: Tolerance between Actual and ExpectedFormatString
: (optional) printf-like format string...
: (optional) format string parameters
-
cr_expect_float_neq
(Actual, Unexpected, Epsilon, FormatString, ...)¶ Passes if Actual is not equal to Unexpected with a tolerance of Epsilon.
Passes if Actual is not equal to Unexpected with a tolerance of Epsilon. Otherwise the test is marked as failure but the execution will continue.
The optional string is printed on failure.
- Note
- Use this to test inequality between floats
- Parameters
Actual
: Value to testUnexpected
: Unexpected valueEpsilon
: Tolerance between Actual and ExpectedFormatString
: (optional) printf-like format string...
: (optional) format string parameters
-
String Assertions¶
-
group
StringAsserts
- Note
- These macros are meant to deal with native strings, i.e. char arrays. Most of them won’t work on
std::string
in C++, with some exceptions forstd::string
, you should use regular comparison assersions.
Defines
-
cr_assert_str_empty
(Value, FormatString, ...)¶ Passes if Value is an empty string.
Passes if Value is an empty string. Otherwise the test is marked as failure and the execution of the function is aborted.
The optional string is printed on failure.
- Note
- Also works on std::string.
- Parameters
Value
: String to testFormatString
: (optional) printf-like format string...
: (optional) format string parameters
-
cr_expect_str_empty
(Value, FormatString, ...)¶ Passes if Value is an empty string.
Passes if Value is an empty string. Otherwise the test is marked as failure but the execution will continue.
The optional string is printed on failure.
- Note
- Also works on std::string.
- Parameters
Value
: String to testFormatString
: (optional) printf-like format string...
: (optional) format string parameters
-
cr_assert_str_not_empty
(Value, FormatString, ...)¶ Passes if Value is not an empty string.
Passes if Value is not an empty string. Otherwise the test is marked as failure and the execution of the function is aborted.
The optional string is printed on failure.
- Note
- Also works on std::string.
- Parameters
Value
: String to testFormatString
: (optional) printf-like format string...
: (optional) format string parameters
-
cr_expect_str_not_empty
(Value, FormatString, ...)¶ Passes if Value is not an empty string.
Passes if Value is not an empty string. Otherwise the test is marked as failure but the execution will continue.
The optional string is printed on failure.
- Note
- Also works on std::string.
- Parameters
Value
: String to testFormatString
: (optional) printf-like format string...
: (optional) format string parameters
-
cr_assert_str_eq
(Actual, Expected, FormatString, ...)¶ Passes if Actual is lexicographically equal to Expected.
Passes if Actual is lexicographically equal to Expected. Otherwise the test is marked as failure and the execution of the function is aborted.
The optional string is printed on failure.
- Parameters
Actual
: String to testExpected
: Expected StringFormatString
: (optional) printf-like format string...
: (optional) format string parameters
-
cr_expect_str_eq
(Actual, Expected, FormatString, ...)¶ Passes if Actual is lexicographically equal to Expected.
Passes if Actual is lexicographically equal to Expected. Otherwise the test is marked as failure but the execution will continue.
The optional string is printed on failure.
- Parameters
Actual
: String to testExpected
: Expected StringFormatString
: (optional) printf-like format string...
: (optional) format string parameters
-
cr_assert_str_neq
(Actual, Unexpected, FormatString, ...)¶ Passes if Actual is not lexicographically equal to Unexpected.
Passes if Actual is not lexicographically equal to Unexpected. Otherwise the test is marked as failure and the execution of the function is aborted.
The optional string is printed on failure.
- Parameters
Actual
: String to testUnexpected
: Unexpected StringFormatString
: (optional) printf-like format string...
: (optional) format string parameters
-
cr_expect_str_neq
(Actual, Unexpected, FormatString, ...)¶ Passes if Actual is not lexicographically equal to Unexpected.
Passes if Actual is not lexicographically equal to Unexpected. Otherwise the test is marked as failure but the execution will continue.
The optional string is printed on failure.
- Parameters
Actual
: String to testUnexpected
: Unexpected StringFormatString
: (optional) printf-like format string...
: (optional) format string parameters
-
cr_assert_str_lt
(Actual, Reference, FormatString, ...)¶ Passes if Actual is lexicographically less than Reference.
Passes if Actual is lexicographically less than Reference. Otherwise the test is marked as failure and the execution of the function is aborted.
The optional string is printed on failure.
- Parameters
Actual
: String to testReference
: Reference StringFormatString
: (optional) printf-like format string...
: (optional) format string parameters
-
cr_expect_str_lt
(Actual, Reference, FormatString, ...)¶ Passes if Actual is lexicographically less than Reference.
Passes if Actual is lexicographically less than Reference. Otherwise the test is marked as failure but the execution will continue.
The optional string is printed on failure.
- Parameters
Actual
: String to testReference
: Reference StringFormatString
: (optional) printf-like format string...
: (optional) format string parameters
-
cr_assert_str_leq
(Actual, Reference, FormatString, ...)¶ Passes if Actual is lexicographically less or equal to Reference.
Passes if Actual is lexicographically less or equal to Reference. Otherwise the test is marked as failure and the execution of the function is aborted.
The optional string is printed on failure.
- Parameters
Actual
: String to testReference
: Reference StringFormatString
: (optional) printf-like format string...
: (optional) format string parameters
-
cr_expect_str_leq
(Actual, Reference, FormatString, ...)¶ Passes if Actual is lexicographically less or equal to Reference.
Passes if Actual is lexicographically less or equal to Reference. Otherwise the test is marked as failure but the execution will continue.
The optional string is printed on failure.
- Parameters
Actual
: String to testReference
: Reference StringFormatString
: (optional) printf-like format string...
: (optional) format string parameters
-
cr_assert_str_gt
(Actual, Reference, FormatString, ...)¶ Passes if Actual is lexicographically greater than Reference.
Passes if Actual is lexicographically greater than Reference. Otherwise the test is marked as failure and the execution of the function is aborted.
The optional string is printed on failure.
- Parameters
Actual
: String to testReference
: Reference StringFormatString
: (optional) printf-like format string...
: (optional) format string parameters
-
cr_expect_str_gt
(Actual, Reference, FormatString, ...)¶ Passes if Actual is lexicographically greater than Reference.
Passes if Actual is lexicographically greater than Reference. Otherwise the test is marked as failure but the execution will continue.
The optional string is printed on failure.
- Parameters
Actual
: String to testReference
: Reference StringFormatString
: (optional) printf-like format string...
: (optional) format string parameters
-
cr_assert_str_geq
(Actual, Reference, FormatString, ...)¶ Passes if Actual is lexicographically greater or equal to Reference.
Passes if Actual is lexicographically greater or equal to Reference. Otherwise the test is marked as failure and the execution of the function is aborted.
The optional string is printed on failure.
- Parameters
Actual
: String to testReference
: Reference StringFormatString
: (optional) printf-like format string...
: (optional) format string parameters
-
cr_expect_str_geq
(Actual, Reference, FormatString, ...)¶ Passes if Actual is lexicographically greater or equal to Reference.
Passes if Actual is lexicographically greater or equal to Reference. Otherwise the test is marked as failure but the execution will continue.
The optional string is printed on failure.
- Parameters
Actual
: String to testReference
: Reference StringFormatString
: (optional) printf-like format string...
: (optional) format string parameters
Wide String Assertions¶
-
group
WideStringAsserts
- Note
- These macros are meant to deal with native wide character strings, i.e. wchar_t arrays. Most of them won’t work on
std::wstring
in C++, with some exceptions forstd::wstring
, you should use regular comparison assertions.
Defines
-
cr_assert_wcs_empty
(Value, FormatString, ...)¶ Passes if Value is an empty wide string.
Passes if Value is an empty wide string. Otherwise the test is marked as failure and the execution of the function is aborted.
The optional (non-wide) string is printed on failure.
- Note
- Also works on std::wstring.
- Parameters
Value
: Wide string to testFormatString
: (optional) printf-like format string...
: (optional) format string parameters
-
cr_expect_wcs_empty
(Value, FormatString, ...)¶ Passes if Value is an empty wide string.
Passes if Value is an empty wide string. Otherwise the test is marked as failure but the execution will continue.
The optional (non-wide) string is printed on failure.
- Note
- Also works on std::wstring.
- Parameters
Value
: Wide string to testFormatString
: (optional) printf-like format string...
: (optional) format string parameters
-
cr_assert_wcs_not_empty
(Value, FormatString, ...)¶ Passes if Value is not an empty wide string.
Passes if Value is not an empty wide string. Otherwise the test is marked as failure and the execution of the function is aborted.
The optional (non-wide) string is printed on failure.
- Note
- Also works on std::string.
- Parameters
Value
: Wide string to testFormatString
: (optional) printf-like format string...
: (optional) format string parameters
-
cr_expect_wcs_not_empty
(Value, FormatString, ...)¶ Passes if Value is not an empty wide string.
Passes if Value is not an empty wide string. Otherwise the test is marked as failure but the execution will continue.
The optional (non-wide) string is printed on failure.
- Note
- Also works on std::string.
- Parameters
Value
: Wide string to testFormatString
: (optional) printf-like format string...
: (optional) format string parameters
-
cr_assert_wcs_eq
(Actual, Expected, FormatString, ...)¶ Passes if Actual is lexicographically equal to Expected.
Passes if Actual is lexicographically equal to Expected. Otherwise the test is marked as failure and the execution of the function is aborted.
The optional (non-wide) string is printed on failure.
- Parameters
Actual
: Wide string to testExpected
: Expected wide stringFormatString
: (optional) printf-like format string...
: (optional) format string parameters
-
cr_expect_wcs_eq
(Actual, Expected, FormatString, ...)¶ Passes if Actual is lexicographically equal to Expected.
Passes if Actual is lexicographically equal to Expected. Otherwise the test is marked as failure but the execution will continue.
The optional (non-wide) string is printed on failure.
- Parameters
Actual
: Wide string to testExpected
: Expected wide stringFormatString
: (optional) printf-like format string...
: (optional) format string parameters
-
cr_assert_wcs_neq
(Actual, Unexpected, FormatString, ...)¶ Passes if Actual is not lexicographically equal to Unexpected.
Passes if Actual is not lexicographically equal to Unexpected. Otherwise the test is marked as failure and the execution of the function is aborted.
The optional (non-wide) string is printed on failure.
- Parameters
Actual
: Wide string to testUnexpected
: Unexpected wide stringFormatString
: (optional) printf-like format string...
: (optional) format string parameters
-
cr_expect_wcs_neq
(Actual, Unexpected, FormatString, ...)¶ Passes if Actual is not lexicographically equal to Unexpected.
Passes if Actual is not lexicographically equal to Unexpected. Otherwise the test is marked as failure but the execution will continue.
The optional (non-wide) string is printed on failure.
- Parameters
Actual
: Wide string to testUnexpected
: Unexpected wide stringFormatString
: (optional) printf-like format string...
: (optional) format string parameters
-
cr_assert_wcs_lt
(Actual, Reference, FormatString, ...)¶ Passes if Actual is lexicographically less than Reference.
Passes if Actual is lexicographically less than Reference. Otherwise the test is marked as failure and the execution of the function is aborted.
The optional (non-wide) string is printed on failure.
- Parameters
Actual
: Wide string to testReference
: Reference wide stringFormatString
: (optional) printf-like format string...
: (optional) format string parameters
-
cr_expect_wcs_lt
(Actual, Reference, FormatString, ...)¶ Passes if Actual is lexicographically less than Reference.
Passes if Actual is lexicographically less than Reference. Otherwise the test is marked as failure but the execution will continue.
The optional (non-wide) string is printed on failure.
- Parameters
Actual
: Wide string to testReference
: Reference wide stringFormatString
: (optional) printf-like format string...
: (optional) format string parameters
-
cr_assert_wcs_leq
(Actual, Reference, FormatString, ...)¶ Passes if Actual is lexicographically less or equal to Reference.
Passes if Actual is lexicographically less or equal to Reference. Otherwise the test is marked as failure and the execution of the function is aborted.
The optional (non-wide) string is printed on failure.
- Parameters
Actual
: Wide string to testReference
: Reference wide stringFormatString
: (optional) printf-like format string...
: (optional) format string parameters
-
cr_expect_wcs_leq
(Actual, Reference, FormatString, ...)¶ Passes if Actual is lexicographically less or equal to Reference.
Passes if Actual is lexicographically less or equal to Reference. Otherwise the test is marked as failure but the execution will continue.
The optional (non-wide) string is printed on failure.
- Parameters
Actual
: Wide string to testReference
: Reference wide stringFormatString
: (optional) printf-like format string...
: (optional) format string parameters
-
cr_assert_wcs_gt
(Actual, Reference, FormatString, ...)¶ Passes if Actual is lexicographically greater than Reference.
Passes if Actual is lexicographically greater than Reference. Otherwise the test is marked as failure and the execution of the function is aborted.
The optional (non-wide) string is printed on failure.
- Parameters
Actual
: Wide string to testReference
: Reference wide stringFormatString
: (optional) printf-like format string...
: (optional) format string parameters
-
cr_expect_wcs_gt
(Actual, Reference, FormatString, ...)¶ Passes if Actual is lexicographically greater than Reference.
Passes if Actual is lexicographically greater than Reference. Otherwise the test is marked as failure but the execution will continue.
The optional (non-wide) string is printed on failure.
- Parameters
Actual
: Wide string to testReference
: Reference wide stringFormatString
: (optional) printf-like format string...
: (optional) format string parameters
-
cr_assert_wcs_geq
(Actual, Reference, FormatString, ...)¶ Passes if Actual is lexicographically greater or equal to Reference.
Passes if Actual is lexicographically greater or equal to Reference. Otherwise the test is marked as failure and the execution of the function is aborted.
The optional (non-wide) string is printed on failure.
- Parameters
Actual
: Wide string to testReference
: Reference wide stringFormatString
: (optional) printf-like format string...
: (optional) format string parameters
-
cr_expect_wcs_geq
(Actual, Reference, FormatString, ...)¶ Passes if Actual is lexicographically greater or equal to Reference.
Passes if Actual is lexicographically greater or equal to Reference. Otherwise the test is marked as failure but the execution will continue.
The optional (non-wide) string is printed on failure.
- Parameters
Actual
: Wide string to testReference
: Reference wide stringFormatString
: (optional) printf-like format string...
: (optional) format string parameters
Array Assertions¶
-
group
ArrayAsserts
Defines
-
cr_assert_arr_eq
(Actual, Expected, FormatString, ...)¶ Passes if Actual is byte-to-byte equal to Expected.
Passes if Actual is byte-to-byte equal to Expected. Otherwise the test is marked as failure and the execution of the function is aborted.
The optional string is printed on failure.
- Warning
- This should not be used on struct arrays, consider using
cr_assert_arr_eq_cmp()
instead. - Parameters
Actual
: Array to testExpected
: Expected arrayFormatString
: (optional) printf-like format string...
: (optional) format string parameters
-
cr_expect_arr_eq
(Actual, Expected, FormatString, ...)¶ Passes if Actual is byte-to-byte equal to Expected.
Passes if Actual is byte-to-byte equal to Expected. Otherwise the test is marked as failure but the execution will continue.
The optional string is printed on failure.
- Warning
- This should not be used on struct arrays, consider using
cr_expect_arr_eq_cmp()
instead. - Parameters
Actual
: Array to testExpected
: Expected arrayFormatString
: (optional) printf-like format string...
: (optional) format string parameters
-
cr_assert_arr_neq
(Actual, Unexpected, Size, FormatString, ...)¶ Passes if Actual is not byte-to-byte equal to Expected.
Passes if Actual is not byte-to-byte equal to Unexpected. Otherwise the test is marked as failure and the execution of the function is aborted.
The optional string is printed on failure.
- Warning
- This should not be used on struct arrays, consider using
cr_assert_arr_neq_cmp()
instead. - Parameters
Actual
: Array to testUnexpected
: Unexpected arraySize
: Number of bytes to checkFormatString
: (optional) printf-like format string...
: (optional) format string parameters
-
cr_expect_arr_neq
(Actual, Unexpected, Size, FormatString, ...)¶ Passes if Actual is not byte-to-byte equal to Unexpected.
Passes if Actual is not byte-to-byte equal to Expected. Otherwise the test is marked as failure but the execution will continue.
The optional string is printed on failure.
- Warning
- This should not be used on struct arrays, consider using
cr_expect_arr_neq_cmp()
instead. - Parameters
Actual
: Array to testUnexpected
: Unexpected arraySize
: Number of bytes to checkFormatString
: (optional) printf-like format string...
: (optional) format string parameters
-
-
group
SafeArrCmpAsserts
C++ / GNU C only!
These macros are only available on C++ compilers.
Defines
-
cr_assert_arr_eq_cmp
(Actual, Expected, Size, Cmp, FormatString, ...)¶ Passes if Actual is comparatively equal to Expected (C++ / GNU C99 only)
Passes if Actual is comparatively equal to Expected. Otherwise the test is marked as failure and the execution of the function is aborted.
The macro takes a
int (*comparator)(typeof(Actual) a, typeof(Expected) b)
function pointer, that returns -1, 0, or 1 whena
is respectively less, equal to, or greater thanb
.The optional string is printed on failure.
- Note
- This macro is only available on C++ and GNU C compilers.
- Parameters
Actual
: Array to testExpected
: Expected arraySize
: Number of bytes to checkCmp
: The comparator to useFormatString
: (optional) printf-like format string...
: (optional) format string parameters
-
cr_expect_arr_eq_cmp
(Actual, Expected, Size, Cmp, FormatString, ...)¶ Passes if Actual is comparatively equal to Expected (C++ / GNU C99 only)
Passes if Actual is comparatively equal to Expected. Otherwise the test is marked as failure but the execution will continue.
The macro takes a
int (*comparator)(typeof(Actual) a, typeof(Expected) b)
function pointer, that returns -1, 0, or 1 whena
is respectively less, equal to, or greater thanb
.The optional string is printed on failure.
- Note
- This macro is only available on C++ and GNU C compilers.
- Parameters
Actual
: Array to testExpected
: Expected arraySize
: Number of bytes to checkCmp
: The comparator to useFormatString
: (optional) printf-like format string...
: (optional) format string parameters
-
cr_assert_arr_neq_cmp
(Actual, Unexpected, Size, Cmp, FormatString, ...)¶ Passes if Actual is not comparatively equal to Unexpected (C++ / GNU C99 only)
Passes if Actual is not comparatively equal to Unexpected. Otherwise the test is marked as failure and the execution of the function is aborted.
The macro takes a
int (*comparator)(typeof(Actual) a, typeof(Expected) b)
function pointer, that returns -1, 0, or 1 whena
is respectively less, equal to, or greater thanb
.The optional string is printed on failure.
- Note
- This macro is only available on C++ and GNU C compilers.
- Parameters
Actual
: Array to testUnexpected
: Unexpected arraySize
: Number of bytes to checkCmp
: The comparator to useFormatString
: (optional) printf-like format string...
: (optional) format string parameters
-
cr_expect_arr_neq_cmp
(Actual, Unexpected, Size, Cmp, FormatString, ...)¶ Passes if Actual is not comparatively equal to Unexpected (C++ / GNU C99 only)
Passes if Actual is not comparatively equal to Unexpected. Otherwise the test is marked as failure but the execution will continue.
The macro takes a
int (*comparator)(typeof(Actual) a, typeof(Expected) b)
function pointer, that returns -1, 0, or 1 whena
is respectively less, equal to, or greater thanb
.The optional string is printed on failure.
- Note
- This macro is only available on C++ and GNU C compilers.
- Parameters
Actual
: Array to testUnexpected
: Unexpected arraySize
: Number of bytes to checkCmp
: The comparator to useFormatString
: (optional) printf-like format string...
: (optional) format string parameters
-
cr_assert_arr_lt_cmp
(Actual, Reference, Size, Cmp, FormatString, ...)¶ Passes if Actual is comparatively less than Reference (C++ / GNU C99 only)
Passes if Actual is comparatively less than Reference. Otherwise the test is marked as failure and the execution of the function is aborted.
The macro takes a
int (*comparator)(typeof(Actual) a, typeof(Expected) b)
function pointer, that returns -1, 0, or 1 whena
is respectively less, equal to, or greater thanb
.The optional string is printed on failure.
- Note
- This macro is only available on C++ and GNU C compilers.
- Parameters
Actual
: Array to testReference
: Reference arraySize
: Number of bytes to checkCmp
: The comparator to useFormatString
: (optional) printf-like format string...
: (optional) format string parameters
-
cr_expect_arr_lt_cmp
(Actual, Reference, Size, Cmp, FormatString, ...)¶ Passes if Actual is comparatively less than Reference (C++ / GNU C99 only)
Passes if Actual is comparatively less than Reference. Otherwise the test is marked as failure but the execution will continue.
The macro takes a
int (*comparator)(typeof(Actual) a, typeof(Expected) b)
function pointer, that returns -1, 0, or 1 whena
is respectively less, equal to, or greater thanb
.The optional string is printed on failure.
- Note
- This macro is only available on C++ and GNU C compilers.
- Parameters
Actual
: Array to testReference
: Reference arraySize
: Number of bytes to checkCmp
: The comparator to useFormatString
: (optional) printf-like format string...
: (optional) format string parameters
-
cr_assert_arr_leq_cmp
(Actual, Reference, Size, Cmp, FormatString, ...)¶ Passes if Actual is comparatively less or equal to Reference (C++ / GNU C99 only)
Passes if Actual is comparatively less or equal to Reference. Otherwise the test is marked as failure and the execution of the function is aborted.
The macro takes a
int (*comparator)(typeof(Actual) a, typeof(Expected) b)
function pointer, that returns -1, 0, or 1 whena
is respectively less, equal to, or greater thanb
.The optional string is printed on failure.
- Note
- This macro is only available on C++ and GNU C compilers.
- Parameters
Actual
: Array to testReference
: Reference arraySize
: Number of bytes to checkCmp
: The comparator to useFormatString
: (optional) printf-like format string...
: (optional) format string parameters
-
cr_expect_arr_leq_cmp
(Actual, Reference, Size, Cmp, FormatString, ...)¶ Passes if Actual is comparatively less or equal to Reference (C++ / GNU C99 only)
Passes if Actual is comparatively less or equal to Reference. Otherwise the test is marked as failure but the execution will continue.
The macro takes a
int (*comparator)(typeof(Actual) a, typeof(Expected) b)
function pointer, that returns -1, 0, or 1 whena
is respectively less, equal to, or greater thanb
.The optional string is printed on failure.
- Note
- This macro is only available on C++ and GNU C compilers.
- Parameters
Actual
: Array to testReference
: Reference arraySize
: Number of bytes to checkCmp
: The comparator to useFormatString
: (optional) printf-like format string...
: (optional) format string parameters
-
cr_assert_arr_gt_cmp
(Actual, Reference, Size, Cmp, FormatString, ...)¶ Passes if Actual is comparatively greater than Reference (C++ / GNU C99 only)
Passes if Actual is comparatively greater than Reference. Otherwise the test is marked as failure and the execution of the function is aborted.
The macro takes a
int (*comparator)(typeof(Actual) a, typeof(Expected) b)
function pointer, that returns -1, 0, or 1 whena
is respectively less, equal to, or greater thanb
.The optional string is printed on failure.
- Note
- This macro is only available on C++ and GNU C compilers.
- Parameters
Actual
: Array to testReference
: Reference arraySize
: Number of bytes to checkCmp
: The comparator to useFormatString
: (optional) printf-like format string...
: (optional) format string parameters
-
cr_expect_arr_gt_cmp
(Actual, Reference, Size, Cmp, FormatString, ...)¶ Passes if Actual is comparatively greater than Reference (C++ / GNU C99 only)
Passes if Actual is comparatively greater than Reference. Otherwise the test is marked as failure but the execution will continue.
The macro takes a
int (*comparator)(typeof(Actual) a, typeof(Expected) b)
function pointer, that returns -1, 0, or 1 whena
is respectively less, equal to, or greater thanb
.The optional string is printed on failure.
- Note
- This macro is only available on C++ and GNU C compilers.
- Parameters
Actual
: Array to testReference
: Reference arraySize
: Number of bytes to checkCmp
: The comparator to useFormatString
: (optional) printf-like format string...
: (optional) format string parameters
-
cr_assert_arr_geq_cmp
(Actual, Reference, Size, Cmp, FormatString, ...)¶ Passes if Actual is comparatively greater or equal to Reference (C++ / GNU C99 only)
Passes if Actual is comparatively greater or equal to Reference. Otherwise the test is marked as failure and the execution of the function is aborted.
The macro takes a
int (*comparator)(typeof(Actual) a, typeof(Expected) b)
function pointer, that returns -1, 0, or 1 whena
is respectively less, equal to, or greater thanb
.The optional string is printed on failure.
- Note
- This macro is only available on C++ and GNU C compilers.
- Parameters
Actual
: Array to testReference
: Reference arraySize
: Number of bytes to checkCmp
: The comparator to useFormatString
: (optional) printf-like format string...
: (optional) format string parameters
-
cr_expect_arr_geq_cmp
(Actual, Reference, Size, Cmp, FormatString, ...)¶ Passes if Actual is comparatively greater or equal to Reference (C++ / GNU C99 only)
Passes if Actual is comparatively greater or equal to Reference. Otherwise the test is marked as failure but the execution will continue.
The macro takes a
int (*comparator)(typeof(Actual) a, typeof(Expected) b)
function pointer, that returns -1, 0, or 1 whena
is respectively less, equal to, or greater thanb
.The optional string is printed on failure.
- Note
- This macro is only available on C++ and GNU C compilers.
- Parameters
Actual
: Array to testReference
: Reference arraySize
: Number of bytes to checkCmp
: The comparator to useFormatString
: (optional) printf-like format string...
: (optional) format string parameters
-
Exception Assertions¶
-
group
ExceptionAsserts
C++ only!
These macros are only available on C++ compilers.
Defines
-
cr_assert_throw
(Statement, Exception, FormatString, ...)¶ Passes if Statement throws an instance of Exception (C++ only)
Passes if Statement throws an instance of Exception. Otherwise the test is marked as failure and the execution of the function is aborted.
The optional string is printed on failure.
- Note
- This macro is only available on C++ compilers.
- Parameters
Statement
: Statement to be executedException
: Expected exceptionFormatString
: (optional) printf-like format string...
: (optional) format string parameters
-
cr_expect_throw
(Statement, Exception, FormatString, ...)¶ Passes if Statement throws an instance of Exception (C++ only)
Passes if Statement throws an instance of Exception. Otherwise the test is marked as failure but the execution will continue.
The optional string is printed on failure.
- Note
- This macro is only available on C++ compilers.
- Parameters
Statement
: Statement to be executedException
: Expected exceptionFormatString
: (optional) printf-like format string...
: (optional) format string parameters
-
cr_assert_no_throw
(Statement, Exception, FormatString, ...)¶ Passes if Statement does not throws an instance of Exception (C++ only)
Passes if Statement does not throws an instance of Exception. Otherwise the test is marked as failure and the execution of the function is aborted.
The optional string is printed on failure.
- Note
- This macro is only available on C++ compilers.
- Parameters
Statement
: Statement to be executedException
: Unexpected exceptionFormatString
: (optional) printf-like format string...
: (optional) format string parameters
-
cr_expect_no_throw
(Statement, Exception, FormatString, ...)¶ Passes if Statement does not throws an instance of Exception (C++ only)
Passes if Statement does not throws an instance of Exception. Otherwise the test is marked as failure but the execution will continue.
The optional string is printed on failure.
- Note
- This macro is only available on C++ compilers.
- Parameters
Statement
: Statement to be executedException
: Unexpected exceptionFormatString
: (optional) printf-like format string...
: (optional) format string parameters
-
cr_assert_any_throw
(Statement, FormatString, ...)¶ Passes if Statement throws any kind of exception (C++ only)
Passes if Statement throws any kind of exception Otherwise the test is marked as failure and the execution of the function is aborted.
The optional string is printed on failure.
- Note
- This macro is only available on C++ compilers.
- Parameters
Statement
: Statement to be executedFormatString
: (optional) printf-like format string...
: (optional) format string parameters
-
cr_expect_any_throw
(Statement, FormatString, ...)¶ Passes if Statement throws any kind of exception (C++ only)
Passes if Statement throws any kind of exception Otherwise the test is marked as failure but the execution will continue.
The optional string is printed on failure.
- Note
- This macro is only available on C++ compilers.
- Parameters
Statement
: Statement to be executedFormatString
: (optional) printf-like format string...
: (optional) format string parameters
-
cr_assert_none_throw
(Statement, FormatString, ...)¶ Passes if Statement does not throws any kind of exception (C++ only)
Passes if Statement does not throws any kind of exception Otherwise the test is marked as failure and the execution of the function is aborted.
The optional string is printed on failure.
- Note
- This macro is only available on C++ compilers.
- Parameters
Statement
: Statement to be executedFormatString
: (optional) printf-like format string...
: (optional) format string parameters
-
cr_expect_none_throw
(Statement, FormatString, ...)¶ Passes if Statement does not throws any kind of exception (C++ only)
Passes if Statement does not throws any kind of exception Otherwise the test is marked as failure but the execution will continue.
The optional string is printed on failure.
- Note
- This macro is only available on C++ compilers.
- Parameters
Statement
: Statement to be executedFormatString
: (optional) printf-like format string...
: (optional) format string parameters
-
File Assertions¶
-
group
FileAsserts
Defines
-
cr_assert_file_contents_eq_str
(File, ExpectedContents, FormatString, ...)¶ Passes if the contents of
File
are equal to the stringExpectedContents
.Passes if the contents of
File
are equal to the stringExpectedContents
. Otherwise the test is marked as failure and the execution of the function is aborted.The optional string is printed on failure.
- Parameters
File
: Pointer to a FILE object that specifies an input streamExpectedContents
: C string with the ExpectedContentsFormatString
: (optional) printf-like format string...
: (optional) format string parameters
-
cr_expect_file_contents_eq_str
(File, ExpectedContents, FormatString, ...)¶ Passes if the contents of
File
are equal to the stringExpectedContents
.Passes if the contents of
File
are equal to the stringExpectedContents
. Otherwise the test is marked as failure but the execution will continue.The optional string is printed on failure.
- Parameters
File
: Pointer to a FILE object that specifies an input streamExpectedContents
: C string with the ExpectedContentsFormatString
: (optional) printf-like format string...
: (optional) format string parameters
-
cr_assert_file_contents_neq_str
(File, UnexpectedContents, FormatString, ...)¶ Passes if the contents of
File
are not equal to the stringUnexpectedContents
.Passes if the contents of
File
are not equal to the stringUnexpectedContents
. Otherwise the test is marked as failure and the execution of the function is aborted.The optional string is printed on failure.
- Parameters
File
: Pointer to a FILE object that specifies an input streamUnexpectedContents
: C string with the UnexpectedContentsFormatString
: (optional) printf-like format string...
: (optional) format string parameters
-
cr_expect_file_contents_neq_str
(File, UnexpectedContents, FormatString, ...)¶ Passes if the contents of
File
are not equal to the stringUnexpectedContents
.Passes if the contents of
File
are not equal to the stringUnexpectedContents
. Otherwise the test is marked as failure but the execution will continue.The optional string is printed on failure.
- Parameters
File
: Pointer to a FILE object that specifies an input streamUnexpectedContents
: C string with the UnexpectedContentsFormatString
: (optional) printf-like format string...
: (optional) format string parameters
-
cr_assert_file_contents_eq
(File, RefFile, FormatString, ...)¶ Passes if the contents of
File
are equal to the contents ofRefFile
.Passes if the contents of
File
are equal to the contents ofRefFile
. Otherwise the test is marked as failure and the execution of the function is aborted.The optional string is printed on failure.
- Parameters
File
: Pointer to a FILE object that specifies an input streamRefFile
: Pointer to a FILE object that specifies an input streamFormatString
: (optional) printf-like format string...
: (optional) format string parameters
-
cr_expect_file_contents_eq
(File, RefFile, FormatString, ...)¶ Passes if the contents of
File
are equal to the contents ofRefFile
.Passes if the contents of
File
are equal to the contents ofRefFile
. Otherwise the test is marked as failure but the execution will continue.The optional string is printed on failure.
- Parameters
File
: Pointer to a FILE object that specifies an input streamRefFile
: Pointer to a FILE object that specifies an input streamFormatString
: (optional) printf-like format string...
: (optional) format string parameters
-
cr_assert_file_contents_neq
(File, RefFile, FormatString, ...)¶ Passes if the contents of
File
are not equal to the contents ofRefFile
.Passes if the contents of
File
are not equal to the contents ofRefFile
. Otherwise the test is marked as failure and the execution of the function is aborted.The optional string is printed on failure.
- Parameters
File
: Pointer to a FILE object that specifies an input streamRefFile
: Pointer to a FILE object that specifies an input streamFormatString
: (optional) printf-like format string...
: (optional) format string parameters
-
cr_expect_file_contents_neq
(File, RefFile, FormatString, ...)¶ Passes if the contents of
File
are not equal to the contents ofRefFile
.Passes if the contents of
File
are not equal to the contents ofRefFile
. Otherwise the test is marked as failure but the execution will continue.The optional string is printed on failure.
- Parameters
File
: Pointer to a FILE object that specifies an input streamRefFile
: Pointer to a FILE object that specifies an input streamFormatString
: (optional) printf-like format string...
: (optional) format string parameters
-