]> pd.if.org Git - pdclib/blobdiff - functions/string/memchr.c
Added test driver.
[pdclib] / functions / string / memchr.c
index 9aef229e69f040f5b74b150c3987f633ba692a13..75809e079d62a7b35a789ca863cd113d059287a4 100644 (file)
@@ -24,4 +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()
+{
+    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