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 test
  • FormatString: (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 test
  • FormatString: (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 test
  • FormatString: (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 test
  • FormatString: (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 test
  • Expected: Expected value
  • FormatString: (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 test
  • Expected: Expected value
  • FormatString: (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 test
  • Unexpected: Unexpected Value
  • FormatString: (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 test
  • Unexpected: Unexpected Value
  • FormatString: (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 test
  • Reference: Reference value
  • FormatString: (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 test
  • Reference: Reference value
  • FormatString: (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 test
  • Reference: Reference value
  • FormatString: (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 test
  • Reference: Reference value
  • FormatString: (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 test
  • Reference: Reference value
  • FormatString: (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 test
  • Reference: Reference value
  • FormatString: (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 test
  • Reference: Reference value
  • FormatString: (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 test
  • Reference: Reference value
  • FormatString: (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 test
  • FormatString: (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 test
  • FormatString: (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 test
  • FormatString: (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 test
  • FormatString: (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 test
  • Expected: Expected value
  • Epsilon: Tolerance between Actual and Expected
  • FormatString: (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 test
  • Expected: Expected value
  • Epsilon: Tolerance between Actual and Expected
  • FormatString: (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 test
  • Unexpected: Unexpected value
  • Epsilon: Tolerance between Actual and Expected
  • FormatString: (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 test
  • Unexpected: Unexpected value
  • Epsilon: Tolerance between Actual and Expected
  • FormatString: (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 for std::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 test
  • FormatString: (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 test
  • FormatString: (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 test
  • FormatString: (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 test
  • FormatString: (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 test
  • Expected: Expected String
  • FormatString: (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 test
  • Expected: Expected String
  • FormatString: (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 test
  • Unexpected: Unexpected String
  • FormatString: (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 test
  • Unexpected: Unexpected String
  • FormatString: (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 test
  • Reference: Reference String
  • FormatString: (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 test
  • Reference: Reference String
  • FormatString: (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 test
  • Reference: Reference String
  • FormatString: (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 test
  • Reference: Reference String
  • FormatString: (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 test
  • Reference: Reference String
  • FormatString: (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 test
  • Reference: Reference String
  • FormatString: (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 test
  • Reference: Reference String
  • FormatString: (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 test
  • Reference: Reference String
  • FormatString: (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 for std::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 test
  • FormatString: (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 test
  • FormatString: (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 test
  • FormatString: (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 test
  • FormatString: (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 test
  • Expected: Expected wide string
  • FormatString: (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 test
  • Expected: Expected wide string
  • FormatString: (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 test
  • Unexpected: Unexpected wide string
  • FormatString: (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 test
  • Unexpected: Unexpected wide string
  • FormatString: (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 test
  • Reference: Reference wide string
  • FormatString: (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 test
  • Reference: Reference wide string
  • FormatString: (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 test
  • Reference: Reference wide string
  • FormatString: (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 test
  • Reference: Reference wide string
  • FormatString: (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 test
  • Reference: Reference wide string
  • FormatString: (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 test
  • Reference: Reference wide string
  • FormatString: (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 test
  • Reference: Reference wide string
  • FormatString: (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 test
  • Reference: Reference wide string
  • FormatString: (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 test
  • Expected: Expected array
  • FormatString: (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 test
  • Expected: Expected array
  • FormatString: (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 test
  • Unexpected: Unexpected array
  • Size: Number of bytes to check
  • FormatString: (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 test
  • Unexpected: Unexpected array
  • Size: Number of bytes to check
  • FormatString: (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 when a is respectively less, equal to, or greater than b.

The optional string is printed on failure.

Note
This macro is only available on C++ and GNU C compilers.
Parameters
  • Actual: Array to test
  • Expected: Expected array
  • Size: Number of bytes to check
  • Cmp: The comparator to use
  • FormatString: (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 when a is respectively less, equal to, or greater than b.

The optional string is printed on failure.

Note
This macro is only available on C++ and GNU C compilers.
Parameters
  • Actual: Array to test
  • Expected: Expected array
  • Size: Number of bytes to check
  • Cmp: The comparator to use
  • FormatString: (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 when a is respectively less, equal to, or greater than b.

The optional string is printed on failure.

Note
This macro is only available on C++ and GNU C compilers.
Parameters
  • Actual: Array to test
  • Unexpected: Unexpected array
  • Size: Number of bytes to check
  • Cmp: The comparator to use
  • FormatString: (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 when a is respectively less, equal to, or greater than b.

The optional string is printed on failure.

Note
This macro is only available on C++ and GNU C compilers.
Parameters
  • Actual: Array to test
  • Unexpected: Unexpected array
  • Size: Number of bytes to check
  • Cmp: The comparator to use
  • FormatString: (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 when a is respectively less, equal to, or greater than b.

The optional string is printed on failure.

Note
This macro is only available on C++ and GNU C compilers.
Parameters
  • Actual: Array to test
  • Reference: Reference array
  • Size: Number of bytes to check
  • Cmp: The comparator to use
  • FormatString: (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 when a is respectively less, equal to, or greater than b.

The optional string is printed on failure.

Note
This macro is only available on C++ and GNU C compilers.
Parameters
  • Actual: Array to test
  • Reference: Reference array
  • Size: Number of bytes to check
  • Cmp: The comparator to use
  • FormatString: (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 when a is respectively less, equal to, or greater than b.

The optional string is printed on failure.

Note
This macro is only available on C++ and GNU C compilers.
Parameters
  • Actual: Array to test
  • Reference: Reference array
  • Size: Number of bytes to check
  • Cmp: The comparator to use
  • FormatString: (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 when a is respectively less, equal to, or greater than b.

The optional string is printed on failure.

Note
This macro is only available on C++ and GNU C compilers.
Parameters
  • Actual: Array to test
  • Reference: Reference array
  • Size: Number of bytes to check
  • Cmp: The comparator to use
  • FormatString: (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 when a is respectively less, equal to, or greater than b.

The optional string is printed on failure.

Note
This macro is only available on C++ and GNU C compilers.
Parameters
  • Actual: Array to test
  • Reference: Reference array
  • Size: Number of bytes to check
  • Cmp: The comparator to use
  • FormatString: (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 when a is respectively less, equal to, or greater than b.

The optional string is printed on failure.

Note
This macro is only available on C++ and GNU C compilers.
Parameters
  • Actual: Array to test
  • Reference: Reference array
  • Size: Number of bytes to check
  • Cmp: The comparator to use
  • FormatString: (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 when a is respectively less, equal to, or greater than b.

The optional string is printed on failure.

Note
This macro is only available on C++ and GNU C compilers.
Parameters
  • Actual: Array to test
  • Reference: Reference array
  • Size: Number of bytes to check
  • Cmp: The comparator to use
  • FormatString: (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 when a is respectively less, equal to, or greater than b.

The optional string is printed on failure.

Note
This macro is only available on C++ and GNU C compilers.
Parameters
  • Actual: Array to test
  • Reference: Reference array
  • Size: Number of bytes to check
  • Cmp: The comparator to use
  • FormatString: (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 executed
  • Exception: Expected exception
  • FormatString: (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 executed
  • Exception: Expected exception
  • FormatString: (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 executed
  • Exception: Unexpected exception
  • FormatString: (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 executed
  • Exception: Unexpected exception
  • FormatString: (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 executed
  • FormatString: (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 executed
  • FormatString: (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 executed
  • FormatString: (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 executed
  • FormatString: (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 string ExpectedContents.

Passes if the contents of File are equal to the string ExpectedContents. 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 stream
  • ExpectedContents: C string with the ExpectedContents
  • FormatString: (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 string ExpectedContents.

Passes if the contents of File are equal to the string ExpectedContents. 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 stream
  • ExpectedContents: C string with the ExpectedContents
  • FormatString: (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 string UnexpectedContents.

Passes if the contents of File are not equal to the string UnexpectedContents. 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 stream
  • UnexpectedContents: C string with the UnexpectedContents
  • FormatString: (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 string UnexpectedContents.

Passes if the contents of File are not equal to the string UnexpectedContents. 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 stream
  • UnexpectedContents: C string with the UnexpectedContents
  • FormatString: (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 of RefFile.

Passes if the contents of File are equal to the contents of RefFile. 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 stream
  • RefFile: Pointer to a FILE object that specifies an input stream
  • FormatString: (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 of RefFile.

Passes if the contents of File are equal to the contents of RefFile. 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 stream
  • RefFile: Pointer to a FILE object that specifies an input stream
  • FormatString: (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 of RefFile.

Passes if the contents of File are not equal to the contents of RefFile. 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 stream
  • RefFile: Pointer to a FILE object that specifies an input stream
  • FormatString: (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 of RefFile.

Passes if the contents of File are not equal to the contents of RefFile. 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 stream
  • RefFile: Pointer to a FILE object that specifies an input stream
  • FormatString: (optional) printf-like format string
  • ...: (optional) format string parameters