Next: , Previous: , Up: assertions   [Contents][Index]


6.2 Expecting strings

Preprocessor Macro: void cctests_assert_asciiz (cce_destination_t L, char const * expected, char const * result)
Preprocessor Macro: void cctests_assert_asciiz (cce_destination_t L, char const * expected, char const * result, char const * message, …)

Assert that the ASCIIZ string expected equals the ASCIIZ string result; the comparison is performed with the standard function strcmp(). If the strings are equal: just return. Otherwise raise an exception of type cctests_condition_assertion_expected_asciiz_t by performing a non–local exit to L.

When the optional argument message and the following arguments are used: a dynamically allocated string is formatted using message as template and printf() format specifiers; this string is used as description message for the assertion violation.

Preprocessor Macro: void cctests_assert_ascii (cce_destination_t L, char const * expected, char const * result, size_t result_len)
Preprocessor Macro: void cctests_assert_ascii (cce_destination_t L, char const * expected, char const * result, size_t result_len, char const * message, …)

Assert that the first result_len octets in the ASCII string expected equal the first result_len octets in the ASCII string result; the comparison is performed with the standard function strncmp(). If the strings are equal: just return. Otherwise raise an exception of type cctests_condition_assertion_expected_ascii_t by performing a non–local exit to L.

When the optional argument message and the following arguments are used: a dynamically allocated string is formatted using message as template and printf() format specifiers; this string is used as description message for the assertion violation.

Here some usage examples:

void
test_1_1 (cce_destination_t L)
{
  cctests_assert_asciiz(L, "hello", "ciao");
}

Next: , Previous: , Up: assertions   [Contents][Index]

This document describes version 0.4.1-devel.1 of CCTests.