#ifndef REGTEST
-/* TODO: Required by both atexit() and exit(). */
-struct _PDCLIB_exitfunc_t
-{
- struct _PDCLIB_exitfunc_t * next;
- void (*func)( void );
-};
-
extern struct _PDCLIB_exitfunc_t * regstack;
int atexit( void (*func)( void ) )
#ifdef TEST
#include <_PDCLIB_test.h>
+#include <assert.h>
+
+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;
}