X-Git-Url: https://pd.if.org/git/?a=blobdiff_plain;f=functions%2Fstdlib%2Flldiv.c;h=302888393e8950b80fdfc3f18d0bd9a6a4c73712;hb=e6fd9753e785702792a00236f86f257a22f5c794;hp=349ff2b0a8b78fa5173100e1a43db79e169c4b7e;hpb=3645cf5a3d3d1344b7863b5202a2d107c0f1964b;p=pdclib diff --git a/functions/stdlib/lldiv.c b/functions/stdlib/lldiv.c index 349ff2b..3028883 100644 --- a/functions/stdlib/lldiv.c +++ b/functions/stdlib/lldiv.c @@ -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; }