aboutsummaryrefslogtreecommitdiffstats
path: root/libabort_stracpy.c
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--libabort_stracpy.c28
1 files changed, 28 insertions, 0 deletions
diff --git a/libabort_stracpy.c b/libabort_stracpy.c
new file mode 100644
index 0000000..53541a8
--- /dev/null
+++ b/libabort_stracpy.c
@@ -0,0 +1,28 @@
+/* See LICENSE file for copyright and license details. */
+#include "common.h"
+#ifndef TEST
+
+extern inline char *libabort_stracpy(char *dst, const char *src, size_t size);
+
+#else
+
+int
+main(void)
+{
+ char buf[6];
+ char *p;
+
+ INIT_TEST_ABORT();
+
+ EXPECT_NO_ABORT(p = libabort_stracpy(buf, "hello", sizeof(buf)));
+ EXPECT(p == buf);
+ EXPECT(!buf[5]);
+ EXPECT(!strcmp(buf, "hello"));
+
+ EXPECT_ABORT(libabort_stracpy(buf, "hello!", sizeof(buf)));
+ EXPECT_ABORT(libabort_stracpy(buf, "", 0));
+
+ return 0;
+}
+
+#endif