X-Git-Url: https://pd.if.org/git/?a=blobdiff_plain;f=functions%2Fstdlib%2Fldiv.c;h=4745446ce7e76fa2244012f814eaa7fa3cc0712c;hb=b08f4b52b1cd1f7a9553c0f357a7c90859fa3e73;hp=92a56b94c88f767c84fe27b10f486c8504d2558b;hpb=3645cf5a3d3d1344b7863b5202a2d107c0f1964b;p=pdclib diff --git a/functions/stdlib/ldiv.c b/functions/stdlib/ldiv.c index 92a56b9..4745446 100644 --- a/functions/stdlib/ldiv.c +++ b/functions/stdlib/ldiv.c @@ -1,8 +1,6 @@ /* $Id$ */ -/* 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 +15,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 +24,21 @@ ldiv_t ldiv( long int numer, 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 ); + ldiv_t result; + result = ldiv( 5, 2 ); + TESTCASE( result.quot == 2 && result.rem == 1 ); + result = ldiv( -5, 2 ); + TESTCASE( result.quot == -2 && result.rem == -1 ); + result = ldiv( 5, -2 ); + TESTCASE( result.quot == -2 && result.rem == 1 ); + TESTCASE( sizeof( result.quot ) == _PDCLIB_LONG_BYTES ); + TESTCASE( sizeof( result.rem ) == _PDCLIB_LONG_BYTES ); return TEST_RESULTS; }