]> pd.if.org Git - pdclib/blobdiff - functions/stdlib/ldiv.c
Added test drivers.
[pdclib] / functions / stdlib / ldiv.c
index 92a56b94c88f767c84fe27b10f486c8504d2558b..11940de59fc05f0eda949bd2c14d9329bde32596 100644 (file)
@@ -2,7 +2,7 @@
 
 /* Release $Name$ */
 
-/* ldiv( int, int )
+/* ldiv( long int, long int )
 
    This file is part of the Public Domain C Library (PDCLib).
    Permission is granted to use, modify, and / or redistribute at will.
@@ -17,7 +17,7 @@ ldiv_t ldiv( long int numer, long int denom )
     ldiv_t rc;
     rc.quot = numer / denom;
     rc.rem  = numer % denom;
-    /* TODO: pre-C99 compilers might require modulus correction */
+    /* TODO: pre-C99 compilers might require modulus corrections */
     return rc;
 }
 
@@ -26,11 +26,22 @@ ldiv_t ldiv( long int numer, long int denom )
 #ifdef TEST
 #include <_PDCLIB_test.h>
 
+#ifndef _PDCLIB_CONFIG_H
+#include <_PDCLIB_config.h>
+#endif
+
 int main()
 {
-    int NO_TESTDRIVER = 0;
+    ldiv_t div;
     BEGIN_TESTS;
-    TESTCASE( NO_TESTDRIVER );
+    div = ldiv( 5, 2 );
+    TESTCASE( div.quot == 2 && div.rem == 1 );
+    div = ldiv( -5, 2 );
+    TESTCASE( div.quot == -2 && div.rem == -1 );
+    div = ldiv( 5, -2 );
+    TESTCASE( div.quot == -2 && div.rem == 1 );
+    TESTCASE( sizeof( div.quot ) == _PDCLIB_LONG_BYTES );
+    TESTCASE( sizeof( div.rem )  == _PDCLIB_LONG_BYTES );
     return TEST_RESULTS;
 }