svn commit: samba r18043 - in
branches/SAMBA_4_0/source/lib/replace/test: .
tridge at samba.org
tridge at samba.org
Mon Sep 4 13:28:54 GMT 2006
Author: tridge
Date: 2006-09-04 13:28:54 +0000 (Mon, 04 Sep 2006)
New Revision: 18043
WebSVN: http://websvn.samba.org/cgi-bin/viewcvs.cgi?view=rev&root=samba&rev=18043
Log:
added strlcpy() test
Modified:
branches/SAMBA_4_0/source/lib/replace/test/testsuite.c
Changeset:
Modified: branches/SAMBA_4_0/source/lib/replace/test/testsuite.c
===================================================================
--- branches/SAMBA_4_0/source/lib/replace/test/testsuite.c 2006-09-04 13:27:16 UTC (rev 18042)
+++ branches/SAMBA_4_0/source/lib/replace/test/testsuite.c 2006-09-04 13:28:54 UTC (rev 18043)
@@ -75,9 +75,31 @@
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 @@
int torture_local_replace()
{
int ret = true;
-;
ret &= test_ftruncate();
ret &= test_strlcpy();
ret &= test_strlcat();
More information about the samba-cvs
mailing list