]> pd.if.org Git - pdclib.old/blobdiff - functions/stdlib/lldiv.c
Removed the $Name$ tags (not supported by SVN). Added $Id$ to Makefile / text files.
[pdclib.old] / functions / stdlib / lldiv.c
index 349ff2b0a8b78fa5173100e1a43db79e169c4b7e..302888393e8950b80fdfc3f18d0bd9a6a4c73712 100644 (file)
@@ -1,7 +1,5 @@
 /* $Id$ */
 
-/* Release $Name$ */
-
 /* lldiv( long long int, long long int )
 
    This file is part of the Public Domain C Library (PDCLib).
@@ -17,7 +15,7 @@ lldiv_t lldiv( long long int numer, long long int denom )
     lldiv_t rc;
     rc.quot = numer / denom;
     rc.rem  = numer % denom;
-    /* TODO */
+    /* TODO: pre-C99 compilers might require modulus corrections */
     return rc;
 }
 
@@ -26,11 +24,21 @@ lldiv_t lldiv( long long int numer, long long int denom )
 #ifdef TEST
 #include <_PDCLIB_test.h>
 
-int main()
+#ifndef _PDCLIB_CONFIG_H
+#include <_PDCLIB_config.h>
+#endif
+
+int main( void )
 {
-    int NO_TESTDRIVER = 0;
-    BEGIN_TESTS;
-    TESTCASE( NO_TESTDRIVER );
+    lldiv_t result;
+    result = lldiv( 5ll, 2ll );
+    TESTCASE( result.quot == 2 && result.rem == 1 );
+    result = lldiv( -5ll, 2ll );
+    TESTCASE( result.quot == -2 && result.rem == -1 );
+    result = lldiv( 5ll, -2ll );
+    TESTCASE( result.quot == -2 && result.rem == 1 );
+    TESTCASE( sizeof( result.quot ) == _PDCLIB_LLONG_BYTES );
+    TESTCASE( sizeof( result.rem )  == _PDCLIB_LLONG_BYTES );
     return TEST_RESULTS;
 }