Next: assertions strings, Up: assertions [Contents][Index]
Evaluate the expression expr; this macro is similar, but not equal, to the standard
assert(). If the expression evaluates to true: just return. Otherwise raise an exception
of type cctests_condition_assertion_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.
An alias for cctests_assert().
Evaluate the expression expr. If the expression evaluates to false: just return.
Otherwise raise an exception of type cctests_condition_assertion_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 are some usage examples:
void
test_1_1 (cce_destination_t L)
{
cctests_assert(L, true); /* success */
}
void
test_1_2 (cce_destination_t L)
{
cctests_assert(L, false); /* failure */
}
void
test_1_3 (cce_destination_t L)
{
void * P = malloc(16);
cctests_assert(L, NULL != P);
}
void
test_1_4 (cce_destination_t L)
{
char const * A = "ciao";
char const * B = "hello";
cctests_assert(L, 0 == strcmp(A, B),
"Unqual strings: %s, %s", A, B);
}
void
test_1_5 (cce_destination_t upper_L)
{
cce_location_t L[1];
cce_clean_handler_t P_H[1];
if (cce_location(L)) {
cce_run_catch_handlers_raise(L, upper_L);
} else {
void * P = cce_sys_malloc_guarded(L, P_H, 1024);
/* do something with P, then: */
cctests_assert(L, some_predicate(P));
cce_run_body_handlers(L);
}
}
Next: assertions strings, Up: assertions [Contents][Index]
This document describes version 0.4.1-devel.1 of CCTests.