summaryrefslogtreecommitdiff
path: root/lib/replace/test
diff options
context:
space:
mode:
authorAndrew Tridgell <tridge@samba.org>2010-01-02 10:01:11 +1100
committerAndrew Tridgell <tridge@samba.org>2010-01-02 10:08:12 +1100
commitfef3c910da421e890925e5e61275fc457da87f6e (patch)
tree3884c2b98c9ccf3b13b11f2c156769014c1e5527 /lib/replace/test
parent00b39c70f57882a453a8d2e6b0f1f37fd39a2d2a (diff)
downloadsamba-fef3c910da421e890925e5e61275fc457da87f6e.tar.gz
samba-fef3c910da421e890925e5e61275fc457da87f6e.tar.bz2
samba-fef3c910da421e890925e5e61275fc457da87f6e.zip
libreplace: some systems don't have memmem()
added rep_memmem() and a testsuite
Diffstat (limited to 'lib/replace/test')
-rw-r--r--lib/replace/test/testsuite.c37
1 files changed, 37 insertions, 0 deletions
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;
}