X-Git-Url: https://pd.if.org/git/?a=blobdiff_plain;f=functions%2Fstdlib%2Fatexit.c;h=14363566a8147dba4f6c6c7962a9c62ea26eb61f;hb=5c311ed91d33b96bd39b80bc16cbe4951de35ac6;hp=1ca1e7fa3eeb3e06fd8424d5690854e0eaab4e90;hpb=9776b3400080a53347b2d45de16617342d4c7794;p=pdclib diff --git a/functions/stdlib/atexit.c b/functions/stdlib/atexit.c index 1ca1e7f..1436356 100644 --- a/functions/stdlib/atexit.c +++ b/functions/stdlib/atexit.c @@ -34,12 +34,33 @@ int atexit( void (*func)( void ) ) #ifdef TEST #include <_PDCLIB_test.h> +#include + +static int flags[ 32 ]; + +static void counthandler() +{ + static int rc = 0; + flags[ rc ] = rc; + ++rc; +} + +static void checkhandler() +{ + for ( int i = 0; i < 31; ++i ) + { + assert( flags[ i ] == i ); + } +} int main() { - int NO_TESTDRIVER = 0; BEGIN_TESTS; - TESTCASE( NO_TESTDRIVER ); + TESTCASE( atexit( &checkhandler ) == 0 ); + for ( int i = 0; i < 31; ++i ) + { + TESTCASE( atexit( &counthandler ) == 0 ); + } return TEST_RESULTS; }