1 /* _PDCLIB_assert( char const * )
3 This file is part of the Public Domain C Library (PDCLib).
4 Permission is granted to use, modify, and / or redistribute at will.
13 #include <_PDCLIB_aux.h>
15 void _PDCLIB_assert99( char const * const message1, char const * const function, char const * const message2 )
17 fputs( message1, stderr );
18 fputs( function, stderr );
19 fputs( message2, stderr );
23 void _PDCLIB_assert89( char const * const message )
25 fputs( message, stderr );
32 #include <_PDCLIB_test.h>
35 static int EXPECTED_ABORT = 0;
36 static int UNEXPECTED_ABORT = 1;
38 static void aborthandler( int sig )
40 TESTCASE( ! EXPECTED_ABORT );
41 exit( (signed int)TEST_RESULTS );
47 static int disabled_test( void )
50 assert( i == 0 ); /* NDEBUG set, condition met */
51 assert( i == 1 ); /* NDEBUG set, condition fails */
60 TESTCASE( signal( SIGABRT, &aborthandler ) != SIG_ERR );
61 TESTCASE( disabled_test() == 0 );
62 assert( UNEXPECTED_ABORT ); /* NDEBUG not set, condition met */
63 assert( EXPECTED_ABORT ); /* NDEBUG not set, condition fails - should abort */