Previous: , Up: overview   [Contents][Index]


1.2 Handling exceptional conditions

CCTests uses the facilities of the package CCExceptions to signal exceptional conditions by performing non–local exits to a previously defined location; (ccexceptions)CCExceptions. The basic template of such mechanism is:

cce_location_t  L[1];

if (cce_location(L)) {
  /* Handle the exception here. */
  cce_run_catch_handlers_final(L);
} else {
  /* Do the work here. */
  cce_run_body_handlers(L);
}

CCExceptions allows us to perform destruction operations upon leaving a location (represented by an initialised instance of cce_location_t), by using exception handlers that register an asynchronous resource for destruction; (ccexceptions)The locations handlers API.

CCTests defines two categories of constructors:

plain

A plain constructor does not register the struct instance it builds for destruction upon leaving a location. It is up to us to do so, using CCException’s handlers API or one of its variants.

guarded

A guarded constructor does register the struct instance it builds for destruction upon leaving a location. The destructor will be called by cce_run_body_handlers() or cce_run_catch_handlers() or one of their variants.

When the facilities of ccnames.h are used: the guarded constructors have names built by ccname_init() or ccname_new() with the clean or error variants.


Previous: , Up: overview   [Contents][Index]

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