3 /* _PDCLIB_assert( char const * )
5 This file is part of the Public Domain C Library (PDCLib).
6 Permission is granted to use, modify, and / or redistribute at will.
15 #include <_PDCLIB_aux.h>
17 #if _PDCLIB_C_VERSION == 99
18 void _PDCLIB_assert( char const * const message1, char const * const function, char const * const message2 )
20 fputs( message1, stderr );
21 fputs( function, stderr );
22 fputs( message2, stderr );
26 void _PDCLIB_assert( char const * const message )
28 fputs( message, stderr );
36 #include <_PDCLIB_test.h>
39 static int EXPECTED_ABORT = 0;
40 static int UNEXPECTED_ABORT = 1;
42 static void aborthandler( int sig )
44 TESTCASE( ! EXPECTED_ABORT );
45 exit( (signed int)TEST_RESULTS );
51 static int disabled_test( void )
54 assert( i == 0 ); /* NDEBUG set, condition met */
55 assert( i == 1 ); /* NDEBUG set, condition fails */
64 TESTCASE( signal( SIGABRT, &aborthandler ) != SIG_ERR );
65 TESTCASE( disabled_test() == 0 );
66 assert( UNEXPECTED_ABORT ); /* NDEBUG not set, condition met */
67 assert( EXPECTED_ABORT ); /* NDEBUG not set, condition fails - should abort */