From fef3c910da421e890925e5e61275fc457da87f6e Mon Sep 17 00:00:00 2001 From: Andrew Tridgell Date: Sat, 2 Jan 2010 10:01:11 +1100 Subject: libreplace: some systems don't have memmem() added rep_memmem() and a testsuite --- lib/replace/test/testsuite.c | 37 +++++++++++++++++++++++++++++++++++++ 1 file changed, 37 insertions(+) (limited to 'lib/replace/test/testsuite.c') diff --git a/lib/replace/test/testsuite.c b/lib/replace/test/testsuite.c index 7929f11add..caa70d68e3 100644 --- a/lib/replace/test/testsuite.c +++ b/lib/replace/test/testsuite.c @@ -1015,6 +1015,42 @@ static int test_utimes(void) return true; } +static int test_memmem(void) +{ + char *s; + + printf("test: memmem\n"); + + s = memmem("foo", 3, "fo", 2); + if (strcmp(s, "foo") != 0) { + printf(__location__ ": Failed memmem\n"); + return false; + } + + s = memmem("foo", 3, "", 0); + if (strcmp(s, "foo") != 0) { + printf(__location__ ": Failed memmem\n"); + return false; + } + + s = memmem("foo", 4, "o", 1); + if (strcmp(s, "oo") != 0) { + printf(__location__ ": Failed memmem\n"); + return false; + } + + s = memmem("foobarfodx", 11, "fod", 3); + if (strcmp(s, "fodx") != 0) { + printf(__location__ ": Failed memmem\n"); + return false; + } + + printf("success: memmem\n"); + + return true; +} + + struct torture_context; bool torture_local_replace(struct torture_context *ctx) { @@ -1065,6 +1101,7 @@ bool torture_local_replace(struct torture_context *ctx) ret &= test_getifaddrs(); ret &= test_utime(); ret &= test_utimes(); + ret &= test_memmem(); return ret; } -- cgit