]> pd.if.org Git - pdclib/commitdiff
Added test driver.
authorsolar <unknown>
Mon, 30 Jan 2006 20:17:24 +0000 (20:17 +0000)
committersolar <unknown>
Mon, 30 Jan 2006 20:17:24 +0000 (20:17 +0000)
functions/stdlib/atexit.c

index 52df21c22c1991ff523ec2d3e44e1d787141de79..14363566a8147dba4f6c6c7962a9c62ea26eb61f 100644 (file)
@@ -34,11 +34,33 @@ 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()
 {
     BEGIN_TESTS;
-    TESTCASE( NO_TESTDRIVER );
+    TESTCASE( atexit( &checkhandler ) == 0 );
+    for ( int i = 0; i < 31; ++i )
+    {
+        TESTCASE( atexit( &counthandler ) == 0 );
+    }
     return TEST_RESULTS;
 }