]> pd.if.org Git - pdclib/blobdiff - functions/string/memchr.c
Added test driver.
[pdclib] / functions / string / memchr.c
index 1e8ff7073c46c911dc408257a402a2190644e7b6..75809e079d62a7b35a789ca863cd113d059287a4 100644 (file)
@@ -24,11 +24,17 @@ void * memchr( const void * s, int c, size_t n )
     return NULL;
 }
 
-#warning Test driver missing.
-
 #ifdef TEST
+#include <_PDCLIB_test.h>
+
 int main()
 {
-    return 0;
+    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