X-Git-Url: http://git.samba.org/?a=blobdiff_plain;f=lib%2Freplace%2Ftest%2Ftestsuite.c;h=caa70d68e390b6a047bb4dd3bce0bb8a6c0b8535;hb=42057793ebb3ccdc4e63f59753bca8dd677e9748;hp=7929f11addf0a660ba9ca6e19ca4d02f420339eb;hpb=92292ac55144521824610a5d4b09f8dc1ff19a8a;p=samba.git diff --git a/lib/replace/test/testsuite.c b/lib/replace/test/testsuite.c index 7929f11addf..caa70d68e39 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; }