Next: , Up: conditions   [Contents][Index]


8.1 Base condition object

The base exceptional–condition object–type is the base for all the condition types defined by CCTests related to testing operations; CCTests might raise exceptions not derived from this type, when an internal error occurs.

We are not meant to instantiate condition objects of type base (so there is no new function), but we can derive new types from it (so there is an init function).

To catch this exceptional condition we can do:

cce_location_t        L[1];

if (cce_location(L)) {
  if (cctests_condition_is_base(cce_condition(L))) {
    CCTESTS_PC(cctests_condition_base_t, C, cce_condition(L));
    do_something_with(C);
  }
  cce_run_catch_handlers_final(L);
} else {
  do_something(L);
  cce_run_body_handlers(L);
}
Struct Typedef: cctests_descriptor_base_t

Type of data structure representing the base exceptional–condition descriptor. It has the following public fields:

cce_descriptor_t descriptor

The condition descriptor’s base values.

The parent of this type descriptor is the root descriptor; See CCExceptions in CCExceptions.

Struct Typedef: cctests_condition_base_t

Type of data structure representing the base exceptional–condition object. It has the following public fields:

cce_condition_root_t root

The parent condition type.

Function: void cce_descriptor_set_parent_to(cctests_condition_base_t) (cce_descriptor_t * const D)

Set the parent of the descriptor referenced by D to the descriptor of the exceptional–condition object–type cctests_condition_base_t.

Function: void cctests_condition_init_base (cctests_condition_base_t * C)

Initialisation function for the condition object. This function is meant to be called from the initialisation function of sub–types of cctests_condition_base_t.

Function: bool cctests_condition_is_base (cce_condition_t const * C)

Return true if C if of type cctests_condition_base_t; otherwise return false.

Sub–typing example

To define a sub–type of cctests_condition_base_t we can copy the code in the files:

condition-base-subtype.c
condition-base-subtype-headear.h
condition-base-subtype-body.c

under the tests directory of the source distribution; the code defines a new condition–object type my_condition_base_subtype_t.


Next: , Up: conditions   [Contents][Index]

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