X-Git-Url: https://pd.if.org/git/?a=blobdiff_plain;f=functions%2Fstring%2Fstrrchr.c;h=b8a83f0bd74fc04886cb46c8191da6c46990f28e;hb=d6f1494a4f38a212b29a13ee713885058dcf0fe7;hp=77b633fffc6968ac6e8286d1c1f5aa8fd684a377;hpb=bdaff7ee88189505e6b66699571034aed015a3bd;p=pdclib diff --git a/functions/string/strrchr.c b/functions/string/strrchr.c index 77b633f..b8a83f0 100644 --- a/functions/string/strrchr.c +++ b/functions/string/strrchr.c @@ -1,8 +1,4 @@ -/* $Id$ */ - -/* Release $Name$ */ - -/* strrchr( const char *, int c ) +/* strrchr( const char *, int ) This file is part of the Public Domain C Library (PDCLib). Permission is granted to use, modify, and / or redistribute at will. @@ -10,6 +6,8 @@ #include +#ifndef REGTEST + char * strrchr( const char * s, int c ) { size_t i = 0; @@ -24,4 +22,18 @@ char * strrchr( const char * s, int c ) return NULL; } -#warning Test driver missing. +#endif + +#ifdef TEST +#include "_PDCLIB_test.h" + +int main( void ) +{ + char abccd[] = "abccd"; + 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