X-Git-Url: https://pd.if.org/git/?a=blobdiff_plain;f=functions%2Fstring%2Fstrrchr.c;h=69321b29e15e8ad4b2e6a37e81c2bfca80fabde9;hb=0e0c0fbd57380a25f109e876516a22d5e19cbc2c;hp=77b633fffc6968ac6e8286d1c1f5aa8fd684a377;hpb=bdaff7ee88189505e6b66699571034aed015a3bd;p=pdclib diff --git a/functions/string/strrchr.c b/functions/string/strrchr.c index 77b633f..69321b2 100644 --- a/functions/string/strrchr.c +++ b/functions/string/strrchr.c @@ -10,6 +10,8 @@ #include +#ifndef REGTEST + char * strrchr( const char * s, int c ) { size_t i = 0; @@ -24,4 +26,19 @@ char * strrchr( const char * s, int c ) return NULL; } -#warning Test driver missing. +#endif + +#ifdef TEST +#include <_PDCLIB_test.h> + +int main() +{ + char abccd[] = "abccd"; + BEGIN_TESTS; + TESTCASE( strrchr( abcde, '\0' ) == &abcde[5] ); + TESTCASE( strrchr( abcde, 'e' ) == &abcde[4] ); + TESTCASE( strrchr( abcde, 'a' ) == &abcde[0] ); + TESTCASE( strrchr( abccd, 'c' ) == &abccd[3] ); + return TEST_RESULTS; +} +#endif