]> pd.if.org Git - pdclib/blobdiff - functions/string/memchr.c
Porting current working set from CVS.
[pdclib] / functions / string / memchr.c
index 4194a854bb0ac5ab1f5ac3f6f81f76857be290ae..6402dc271a0d63d56c98e36d0452d43e4f4a365d 100644 (file)
@@ -10,6 +10,8 @@
 
 #include <string.h>
 
+#ifndef REGTEST
+
 void * memchr( const void * s, int c, size_t n )
 {
     const unsigned char * p = (const unsigned char *) s;
@@ -23,3 +25,19 @@ void * memchr( const void * s, int c, size_t n )
     }
     return NULL;
 }
+
+#endif
+
+#ifdef TEST
+#include <_PDCLIB_test.h>
+
+int main( void )
+{
+    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