]> pd.if.org Git - pdclib.old/blobdiff - functions/string/memchr.c
Porting current working set from CVS.
[pdclib.old] / functions / string / memchr.c
index 1e8ff7073c46c911dc408257a402a2190644e7b6..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;
@@ -24,11 +26,18 @@ void * memchr( const void * s, int c, size_t n )
     return NULL;
 }
 
-#warning Test driver missing.
+#endif
 
 #ifdef TEST
-int main()
+#include <_PDCLIB_test.h>
+
+int main( void )
 {
-    return 0;
+    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