X-Git-Url: https://pd.if.org/git/?a=blobdiff_plain;f=functions%2Fstring%2Fmemchr.c;h=972e7ffa82038908872e99f22e5ed2c4d9566922;hb=40d0246771c8e593d4b5fdc97dd87b4afd260be2;hp=4194a854bb0ac5ab1f5ac3f6f81f76857be290ae;hpb=c2f1367984ba4153d892062759c3813020b65a9a;p=pdclib diff --git a/functions/string/memchr.c b/functions/string/memchr.c index 4194a85..972e7ff 100644 --- a/functions/string/memchr.c +++ b/functions/string/memchr.c @@ -10,6 +10,8 @@ #include +#ifndef REGTEST + void * memchr( const void * s, int c, size_t n ) { const unsigned char * p = (const unsigned char *) s; @@ -23,3 +25,20 @@ void * memchr( const void * s, int c, size_t n ) } return NULL; } + +#endif + +#ifdef TEST +#include <_PDCLIB_test.h> + +int main() +{ + BEGIN_TESTS; + TESTCASE( memchr( abcde, 'c', 5 ) == &abcde[2] ); + TESTCASE( memchr( abcde, 'a', 1 ) == &abcde[0] ); + TESTCASE( memchr( abcde, 'a', 0 ) == NULL ); + TESTCASE( memchr( abcde, '\0', 5 ) == NULL ); + TESTCASE( memchr( abcde, '\0', 6 ) == &abcde[5] ); + return TEST_RESULTS; +} +#endif