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
  • [in] FormatString: (optional) printf-like format string

  • [in] ...: (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
  • [in] FormatString: (optional) printf-like format string

  • [in] ...: (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
  • [in] Condition: Condition to test

  • [in] FormatString: (optional) printf-like format string

  • [in] ...: (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
  • [in] Condition: Condition to test

  • [in] FormatString: (optional) printf-like format string

  • [in] ...: (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
  • [in] Condition: Condition to test

  • [in] FormatString: (optional) printf-like format string

  • [in] ...: (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
  • [in] Condition: Condition to test

  • [in] FormatString: (optional) printf-like format string

  • [in] ...: (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
  • [in] Actual: Value to test

  • [in] Expected: Expected value

  • [in] FormatString: (optional) printf-like format string

  • [in] ...: (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
  • [in] Actual: Value to test

  • [in] Expected: Expected value

  • [in] FormatString: (optional) printf-like format string

  • [in] ...: (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
  • [in] Actual: Value to test

  • [in] Unexpected: Unexpected Value

  • [in] FormatString: (optional) printf-like format string

  • [in] ...: (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
  • [in] Actual: Value to test

  • [in] Unexpected: Unexpected Value

  • [in] FormatString: (optional) printf-like format string

  • [in] ...: (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
  • [in] Actual: Value to test

  • [in] Reference: Reference value

  • [in] FormatString: (optional) printf-like format string

  • [in] ...: (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
  • [in] Actual: Value to test

  • [in] Reference: Reference value

  • [in] FormatString: (optional) printf-like format string

  • [in] ...: (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
  • [in] Actual: Value to test

  • [in] Reference: Reference value

  • [in] FormatString: (optional) printf-like format string

  • [in] ...: (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
  • [in] Actual: Value to test

  • [in] Reference: Reference value

  • [in] FormatString: (optional) printf-like format string

  • [in] ...: (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
  • [in] Actual: Value to test

  • [in] Reference: Reference value

  • [in] FormatString: (optional) printf-like format string

  • [in] ...: (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
  • [in] Actual: Value to test

  • [in] Reference: Reference value

  • [in] FormatString: (optional) printf-like format string

  • [in] ...: (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
  • [in] Actual: Value to test

  • [in] Reference: Reference value

  • [in] FormatString: (optional) printf-like format string

  • [in] ...: (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
  • [in] Actual: Value to test

  • [in] Reference: Reference value

  • [in] FormatString: (optional) printf-like format string

  • [in] ...: (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
  • [in] Actual: Value to test

  • [in] FormatString: (optional) printf-like format string

  • [in] ...: (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
  • [in] Actual: Value to test

  • [in] FormatString: (optional) printf-like format string

  • [in] ...: (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
  • [in] Value: Value to test

  • [in] FormatString: (optional) printf-like format string

  • [in] ...: (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
  • [in] Value: Value to test

  • [in] FormatString: (optional) printf-like format string

  • [in] ...: (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
  • [in] Actual: Value to test

  • [in] Expected: Expected value

  • [in] Epsilon: Tolerance between Actual and Expected

  • [in] FormatString: (optional) printf-like format string

  • [in] ...: (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
  • [in] Actual: Value to test

  • [in] Expected: Expected value

  • [in] Epsilon: Tolerance between Actual and Expected

  • [in] FormatString: (optional) printf-like format string

  • [in] ...: (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
  • [in] Actual: Value to test

  • [in] Unexpected: Unexpected value

  • [in] Epsilon: Tolerance between Actual and Expected

  • [in] FormatString: (optional) printf-like format string

  • [in] ...: (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
  • [in] Actual: Value to test

  • [in] Unexpected: Unexpected value

  • [in] Epsilon: Tolerance between Actual and Expected

  • [in] FormatString: (optional) printf-like format string

  • [in] ...: (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
  • [in] Value: String to test

  • [in] FormatString: (optional) printf-like format string

  • [in] ...: (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
  • [in] Value: String to test

  • [in] FormatString: (optional) printf-like format string

  • [in] ...: (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
  • [in] Value: String to test

  • [in] FormatString: (optional) printf-like format string

  • [in] ...: (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
  • [in] Value: String to test

  • [in] FormatString: (optional) printf-like format string

  • [in] ...: (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
  • [in] Actual: String to test

  • [in] Expected: Expected String

  • [in] FormatString: (optional) printf-like format string

  • [in] ...: (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
  • [in] Actual: String to test

  • [in] Expected: Expected String

  • [in] FormatString: (optional) printf-like format string

  • [in] ...: (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
  • [in] Actual: String to test

  • [in] Unexpected: Unexpected String

  • [in] FormatString: (optional) printf-like format string

  • [in] ...: (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
  • [in] Actual: String to test

  • [in] Unexpected: Unexpected String

  • [in] FormatString: (optional) printf-like format string

  • [in] ...: (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
  • [in] Actual: String to test

  • [in] Reference: Reference String

  • [in] FormatString: (optional) printf-like format string

  • [in] ...: (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
  • [in] Actual: String to test

  • [in] Reference: Reference String

  • [in] FormatString: (optional) printf-like format string

  • [in] ...: (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
  • [in] Actual: String to test

  • [in] Reference: Reference String

  • [in] FormatString: (optional) printf-like format string

  • [in] ...: (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
  • [in] Actual: String to test

  • [in] Reference: Reference String

  • [in] FormatString: (optional) printf-like format string

  • [in] ...: (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
  • [in] Actual: String to test

  • [in] Reference: Reference String

  • [in] FormatString: (optional) printf-like format string

  • [in] ...: (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
  • [in] Actual: String to test

  • [in] Reference: Reference String

  • [in] FormatString: (optional) printf-like format string

  • [in] ...: (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
  • [in] Actual: String to test

  • [in] Reference: Reference String

  • [in] FormatString: (optional) printf-like format string

  • [in] ...: (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
  • [in] Actual: String to test

  • [in] Reference: Reference String

  • [in] FormatString: (optional) printf-like format string

  • [in] ...: (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
  • [in] Value: Wide string to test

  • [in] FormatString: (optional) printf-like format string

  • [in] ...: (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
  • [in] Value: Wide string to test

  • [in] FormatString: (optional) printf-like format string

  • [in] ...: (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
  • [in] Value: Wide string to test

  • [in] FormatString: (optional) printf-like format string

  • [in] ...: (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
  • [in] Value: Wide string to test

  • [in] FormatString: (optional) printf-like format string

  • [in] ...: (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
  • [in] Actual: Wide string to test

  • [in] Expected: Expected wide string

  • [in] FormatString: (optional) printf-like format string

  • [in] ...: (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
  • [in] Actual: Wide string to test

  • [in] Expected: Expected wide string

  • [in] FormatString: (optional) printf-like format string

  • [in] ...: (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
  • [in] Actual: Wide string to test

  • [in] Unexpected: Unexpected wide string

  • [in] FormatString: (optional) printf-like format string

  • [in] ...: (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
  • [in] Actual: Wide string to test

  • [in] Unexpected: Unexpected wide string

  • [in] FormatString: (optional) printf-like format string

  • [in] ...: (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
  • [in] Actual: Wide string to test

  • [in] Reference: Reference wide string

  • [in] FormatString: (optional) printf-like format string

  • [in] ...: (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
  • [in] Actual: Wide string to test

  • [in] Reference: Reference wide string

  • [in] FormatString: (optional) printf-like format string

  • [in] ...: (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
  • [in] Actual: Wide string to test

  • [in] Reference: Reference wide string

  • [in] FormatString: (optional) printf-like format string

  • [in] ...: (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
  • [in] Actual: Wide string to test

  • [in] Reference: Reference wide string

  • [in] FormatString: (optional) printf-like format string

  • [in] ...: (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
  • [in] Actual: Wide string to test

  • [in] Reference: Reference wide string

  • [in] FormatString: (optional) printf-like format string

  • [in] ...: (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
  • [in] Actual: Wide string to test

  • [in] Reference: Reference wide string

  • [in] FormatString: (optional) printf-like format string

  • [in] ...: (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
  • [in] Actual: Wide string to test

  • [in] Reference: Reference wide string

  • [in] FormatString: (optional) printf-like format string

  • [in] ...: (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
  • [in] Actual: Wide string to test

  • [in] Reference: Reference wide string

  • [in] FormatString: (optional) printf-like format string

  • [in] ...: (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
  • [in] Actual: Array to test

  • [in] Expected: Expected array

  • [in] FormatString: (optional) printf-like format string

  • [in] ...: (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
  • [in] Actual: Array to test

  • [in] Expected: Expected array

  • [in] FormatString: (optional) printf-like format string

  • [in] ...: (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
  • [in] Actual: Array to test

  • [in] Unexpected: Unexpected array

  • [in] Size: Number of bytes to check

  • [in] FormatString: (optional) printf-like format string

  • [in] ...: (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
  • [in] Actual: Array to test

  • [in] Unexpected: Unexpected array

  • [in] Size: Number of bytes to check

  • [in] FormatString: (optional) printf-like format string

  • [in] ...: (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
  • [in] Actual: Array to test

  • [in] Expected: Expected array

  • [in] Size: Number of bytes to check

  • [in] Cmp: The comparator to use

  • [in] FormatString: (optional) printf-like format string

  • [in] ...: (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
  • [in] Actual: Array to test

  • [in] Expected: Expected array

  • [in] Size: Number of bytes to check

  • [in] Cmp: The comparator to use

  • [in] FormatString: (optional) printf-like format string

  • [in] ...: (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
  • [in] Actual: Array to test

  • [in] Unexpected: Unexpected array

  • [in] Size: Number of bytes to check

  • [in] Cmp: The comparator to use

  • [in] FormatString: (optional) printf-like format string

  • [in] ...: (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
  • [in] Actual: Array to test

  • [in] Unexpected: Unexpected array

  • [in] Size: Number of bytes to check

  • [in] Cmp: The comparator to use

  • [in] FormatString: (optional) printf-like format string

  • [in] ...: (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
  • [in] Actual: Array to test

  • [in] Reference: Reference array

  • [in] Size: Number of bytes to check

  • [in] Cmp: The comparator to use

  • [in] FormatString: (optional) printf-like format string

  • [in] ...: (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
  • [in] Actual: Array to test

  • [in] Reference: Reference array

  • [in] Size: Number of bytes to check

  • [in] Cmp: The comparator to use

  • [in] FormatString: (optional) printf-like format string

  • [in] ...: (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
  • [in] Actual: Array to test

  • [in] Reference: Reference array

  • [in] Size: Number of bytes to check

  • [in] Cmp: The comparator to use

  • [in] FormatString: (optional) printf-like format string

  • [in] ...: (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
  • [in] Actual: Array to test

  • [in] Reference: Reference array

  • [in] Size: Number of bytes to check

  • [in] Cmp: The comparator to use

  • [in] FormatString: (optional) printf-like format string

  • [in] ...: (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
  • [in] Actual: Array to test

  • [in] Reference: Reference array

  • [in] Size: Number of bytes to check

  • [in] Cmp: The comparator to use

  • [in] FormatString: (optional) printf-like format string

  • [in] ...: (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
  • [in] Actual: Array to test

  • [in] Reference: Reference array

  • [in] Size: Number of bytes to check

  • [in] Cmp: The comparator to use

  • [in] FormatString: (optional) printf-like format string

  • [in] ...: (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
  • [in] Actual: Array to test

  • [in] Reference: Reference array

  • [in] Size: Number of bytes to check

  • [in] Cmp: The comparator to use

  • [in] FormatString: (optional) printf-like format string

  • [in] ...: (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
  • [in] Actual: Array to test

  • [in] Reference: Reference array

  • [in] Size: Number of bytes to check

  • [in] Cmp: The comparator to use

  • [in] FormatString: (optional) printf-like format string

  • [in] ...: (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
  • [in] Statement: Statement to be executed

  • [in] Exception: Expected exception

  • [in] FormatString: (optional) printf-like format string

  • [in] ...: (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
  • [in] Statement: Statement to be executed

  • [in] Exception: Expected exception

  • [in] FormatString: (optional) printf-like format string

  • [in] ...: (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
  • [in] Statement: Statement to be executed

  • [in] Exception: Unexpected exception

  • [in] FormatString: (optional) printf-like format string

  • [in] ...: (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
  • [in] Statement: Statement to be executed

  • [in] Exception: Unexpected exception

  • [in] FormatString: (optional) printf-like format string

  • [in] ...: (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
  • [in] Statement: Statement to be executed

  • [in] FormatString: (optional) printf-like format string

  • [in] ...: (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
  • [in] Statement: Statement to be executed

  • [in] FormatString: (optional) printf-like format string

  • [in] ...: (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
  • [in] Statement: Statement to be executed

  • [in] FormatString: (optional) printf-like format string

  • [in] ...: (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
  • [in] Statement: Statement to be executed

  • [in] FormatString: (optional) printf-like format string

  • [in] ...: (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
  • [in] File: Pointer to a FILE object that specifies an input stream

  • [in] ExpectedContents: C string with the ExpectedContents

  • [in] FormatString: (optional) printf-like format string

  • [in] ...: (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
  • [in] File: Pointer to a FILE object that specifies an input stream

  • [in] ExpectedContents: C string with the ExpectedContents

  • [in] FormatString: (optional) printf-like format string

  • [in] ...: (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
  • [in] File: Pointer to a FILE object that specifies an input stream

  • [in] UnexpectedContents: C string with the UnexpectedContents

  • [in] FormatString: (optional) printf-like format string

  • [in] ...: (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
  • [in] File: Pointer to a FILE object that specifies an input stream

  • [in] UnexpectedContents: C string with the UnexpectedContents

  • [in] FormatString: (optional) printf-like format string

  • [in] ...: (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
  • [in] File: Pointer to a FILE object that specifies an input stream

  • [in] RefFile: Pointer to a FILE object that specifies an input stream

  • [in] FormatString: (optional) printf-like format string

  • [in] ...: (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
  • [in] File: Pointer to a FILE object that specifies an input stream

  • [in] RefFile: Pointer to a FILE object that specifies an input stream

  • [in] FormatString: (optional) printf-like format string

  • [in] ...: (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
  • [in] File: Pointer to a FILE object that specifies an input stream

  • [in] RefFile: Pointer to a FILE object that specifies an input stream

  • [in] FormatString: (optional) printf-like format string

  • [in] ...: (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
  • [in] File: Pointer to a FILE object that specifies an input stream

  • [in] RefFile: Pointer to a FILE object that specifies an input stream

  • [in] FormatString: (optional) printf-like format string

  • [in] ...: (optional) format string parameters