diff options
Diffstat (limited to 'libabort_stracat.c')
| -rw-r--r-- | libabort_stracat.c | 33 |
1 files changed, 33 insertions, 0 deletions
diff --git a/libabort_stracat.c b/libabort_stracat.c new file mode 100644 index 0000000..a3a32fb --- /dev/null +++ b/libabort_stracat.c @@ -0,0 +1,33 @@ +/* See LICENSE file for copyright and license details. */ +#include "common.h" +#ifndef TEST + +extern inline char *libabort_stracat(char *dst, const char *src, size_t size); + +#else + +int +main(void) +{ + char buf[16]; + char *p; + + INIT_TEST_ABORT(); + + buf[0] = '\0'; + EXPECT_NO_ABORT(p = libabort_stracat(buf, "hello", sizeof(buf))); + EXPECT(p == buf); + EXPECT(!buf[5]); + EXPECT(!strcmp(buf, "hello")); + + EXPECT_NO_ABORT(p = libabort_stracat(buf, " world", sizeof(buf))); + EXPECT(p == buf); + EXPECT(!buf[11]); + EXPECT(!strcmp(buf, "hello world")); + + EXPECT_ABORT(libabort_stracat(buf, " 0123456789abcdef", sizeof(buf))); + + return 0; +} + +#endif |
