lldiv_t rc;
rc.quot = numer / denom;
rc.rem = numer % denom;
- /* TODO */
+ /* TODO: pre-C99 compilers might require modulus corrections */
return rc;
}
#ifdef TEST
#include <_PDCLIB_test.h>
+#ifndef _PDCLIB_CONFIG_H
+#include <_PDCLIB_config.h>
+#endif
+
int main()
{
- int NO_TESTDRIVER = 0;
+ lldiv_t div;
BEGIN_TESTS;
- TESTCASE( NO_TESTDRIVER );
+ div = lldiv( 5, 2 );
+ TESTCASE( div.quot == 2 && div.rem == 1 );
+ div = lldiv( -5, 2 );
+ TESTCASE( div.quot == -2 && div.rem == -1 );
+ div = lldiv( 5, -2 );
+ TESTCASE( div.quot == -2 && div.rem == 1 );
+ TESTCASE( sizeof( div.quot ) == _PDCLIB_LLONG_BYTES );
+ TESTCASE( sizeof( div.rem ) == _PDCLIB_LLONG_BYTES );
return TEST_RESULTS;
}