Example #1
0
# include "testing.h"
# include <signal.h>


void * custom_initialize_handler(const e4c_exception * exception);
E4C_DEFINE_EXCEPTION(CustomException, "This is a custom exception", RuntimeException);
char initialization[64] = "FOOBAR";
e4c_signal_mapping custom_mappings[2] = {
    E4C_SIGNAL_MAPPING(SIGTERM, CustomException),
    E4C_NULL_SIGNAL_MAPPING
};


/**
 * Mixing custom initialization handler and signal mappings
 *
 * This test sets both custom *initialization handler* and *signal mappings*.
 * Then a *signal* is raised and the `catch` block inspects the exception.
 *
 */
TEST_CASE{

    volatile E4C_BOOL SIGTERM_was_thrown = E4C_FALSE;

    e4c_context_begin(E4C_FALSE);

    e4c_context_set_signal_mappings(custom_mappings);

    e4c_context_set_handlers(NULL, NULL, custom_initialize_handler, NULL);
Example #2
0
# include "testing.h"
# include <signal.h>


static e4c_signal_mapping custom_mappings[] = {

	E4C_SIGNAL_MAPPING(SIGTERM, WildException),
	E4C_NULL_SIGNAL_MAPPING
};

static char foobar[] = "FOOBAR";

static void * custom_initialize_handler(const e4c_exception * exception){

	fprintf(stderr, "CUSTOM_INITIALIZE_HANDLER\n");

	return(foobar);
}


DEFINE_TEST(
	i13,
	"Mixing custom initialization handler and signal mappings",
	"This test sets both custom initialization handler and signal mappings. Then a <em>signal</em> is raised and the <code>catch</code> block inspects the exception.",
	NULL,
	EXIT_SUCCESS,
	"before_CONTEXT_END",
	"WildException_FOOBAR"
){