summaryrefslogtreecommitdiff
path: root/source4/lib
diff options
context:
space:
mode:
Diffstat (limited to 'source4/lib')
-rw-r--r--source4/lib/replace/test/testsuite.c25
1 files changed, 23 insertions, 2 deletions
diff --git a/source4/lib/replace/test/testsuite.c b/source4/lib/replace/test/testsuite.c
index c00e2a788f..5d20c345f8 100644
--- a/source4/lib/replace/test/testsuite.c
+++ b/source4/lib/replace/test/testsuite.c
@@ -75,9 +75,31 @@ static int test_ftruncate()
return true;
}
+/*
+ test strlcpy() function.
+ see http://www.gratisoft.us/todd/papers/strlcpy.html
+ */
static int test_strlcpy()
{
- /* FIXME */
+ char buf[4];
+ const struct {
+ const char *src;
+ int result;
+ } tests[] = {
+ { "abc", 3 },
+ { "abcdef", 6 },
+ { "abcd", 4 },
+ { "", 0 },
+ { NULL, 0 }
+ };
+ int i;
+ printf("testing strlcpy\n");
+ for (i=0;tests[i].src;i++) {
+ if (strlcpy(buf, tests[i].src, sizeof(buf)) != tests[i].result) {
+ printf("strlcpy test %d failed\n");
+ return false;
+ }
+ }
return true;
}
@@ -347,7 +369,6 @@ static int test_MAX()
int torture_local_replace()
{
int ret = true;
-;
ret &= test_ftruncate();
ret &= test_strlcpy();
ret &= test_strlcat();