X-Git-Url: https://pd.if.org/git/?p=pdclib;a=blobdiff_plain;f=functions%2Fstdlib%2Flldiv.c;h=e6552c3447a9d5167a7852b53fc203bc2c99be5f;hp=349ff2b0a8b78fa5173100e1a43db79e169c4b7e;hb=da0f3f353d417fed71f358a48d5d5394145e460d;hpb=3645cf5a3d3d1344b7863b5202a2d107c0f1964b diff --git a/functions/stdlib/lldiv.c b/functions/stdlib/lldiv.c index 349ff2b..e6552c3 100644 --- a/functions/stdlib/lldiv.c +++ b/functions/stdlib/lldiv.c @@ -1,7 +1,3 @@ -/* $Id$ */ - -/* Release $Name$ */ - /* lldiv( long long int, long long int ) This file is part of the Public Domain C Library (PDCLib). @@ -17,20 +13,26 @@ 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; } #endif #ifdef TEST -#include <_PDCLIB_test.h> +#include "_PDCLIB_test.h" -int main() +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 ) == sizeof( long long ) ); + TESTCASE( sizeof( result.rem ) == sizeof( long long ) ); return TEST_RESULTS; }