summaryrefslogtreecommitdiff
path: root/tests/port/test_strlcpy.c
diff options
context:
space:
mode:
authorAndreas Baumann <abaumann@yahoo.com>2009-03-24 11:51:12 +0100
committerAndreas Baumann <abaumann@yahoo.com>2009-03-24 11:51:12 +0100
commit8e3274f153f89ecf1611fa8468d2d7dbe596a23f (patch)
treed53ed483e4714599826dab45a82574b9a5be2a11 /tests/port/test_strlcpy.c
parent2f0a989a9ebd8d93fdcaf9a8530fea94877f607f (diff)
downloadwolfbones-8e3274f153f89ecf1611fa8468d2d7dbe596a23f.tar.gz
wolfbones-8e3274f153f89ecf1611fa8468d2d7dbe596a23f.tar.bz2
added strlcpy and strlcat (safe BSD C functions)
Diffstat (limited to 'tests/port/test_strlcpy.c')
-rw-r--r--tests/port/test_strlcpy.c26
1 files changed, 26 insertions, 0 deletions
diff --git a/tests/port/test_strlcpy.c b/tests/port/test_strlcpy.c
new file mode 100644
index 0000000..d83ed58
--- /dev/null
+++ b/tests/port/test_strlcpy.c
@@ -0,0 +1,26 @@
+#include "port/sys.h"
+
+#define TEST_STRLCPY
+#include "port/string.c" /* for strlcpy */
+
+#include <stdlib.h> /* for exit, EXIT_SUCCESS, free */
+
+int main( void ) {
+ const char *s = "test";
+ char d11[10];
+ char d12[4];
+ char d21[10];
+ char d22[4];
+
+ wolf_port_strlcpy( d11, s, 10 );
+ strlcpy( d21, s, 10 );
+ if( strcmp( d11, s ) != 0 ) return EXIT_FAILURE;
+ if( strcmp( d11, d21 ) != 0 ) return EXIT_FAILURE;
+
+ wolf_port_strlcpy( d12, s, 4 );
+ strlcpy( d22, s, 4 );
+ if( strcmp( d12, "tes" ) != 0 ) return EXIT_FAILURE;
+ if( strcmp( d12, d22 ) != 0 ) return EXIT_FAILURE;
+
+ return EXIT_SUCCESS;
+}