summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAndrew Tridgell <tridge@samba.org>2006-09-04 13:28:54 +0000
committerGerald (Jerry) Carter <jerry@samba.org>2007-10-10 14:17:07 -0500
commit73493a095ae4802cd3e1222b22321454db17b988 (patch)
tree28050109b13160da02edb21a7e6f0976b6afd04a
parenteab9f6d1027d678e45215f2db24c5cc44db14c8c (diff)
downloadsamba-73493a095ae4802cd3e1222b22321454db17b988.tar.gz
samba-73493a095ae4802cd3e1222b22321454db17b988.tar.bz2
samba-73493a095ae4802cd3e1222b22321454db17b988.zip
r18043: added strlcpy() test
(This used to be commit a68b3395199d2d47af3b23959e6da7109a9c5193)
-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();