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