diff options
| author | jvoisin | 2023-06-22 18:14:24 +0200 |
|---|---|---|
| committer | jvoisin | 2023-06-22 18:14:24 +0200 |
| commit | b714dbd77f79262b00298fcdb3f69bf518dcd242 (patch) | |
| tree | 143567b7ca04389f6a5b80a24afa0139e32be5b5 /tests | |
| parent | 532f4bfd0ba906e5a1410b9d2a46cf8a4992f062 (diff) | |
Add a test for strncat
Diffstat (limited to 'tests')
| -rw-r--r-- | tests/Makefile | 1 | ||||
| -rw-r--r-- | tests/test_strncat_static_write.c | 16 |
2 files changed, 17 insertions, 0 deletions
diff --git a/tests/Makefile b/tests/Makefile index 11718cc..dcfe22e 100644 --- a/tests/Makefile +++ b/tests/Makefile | |||
| @@ -19,6 +19,7 @@ TARGETS=test_memcpy_static_write \ | |||
| 19 | test_strcpy_overwrite_over \ | 19 | test_strcpy_overwrite_over \ |
| 20 | test_strcpy_overwrite_under \ | 20 | test_strcpy_overwrite_under \ |
| 21 | test_strcpy_static_write \ | 21 | test_strcpy_static_write \ |
| 22 | test_strncat_static_write \ | ||
| 22 | test_strncpy_overwrite_over \ | 23 | test_strncpy_overwrite_over \ |
| 23 | test_strncpy_overwrite_under \ | 24 | test_strncpy_overwrite_under \ |
| 24 | test_strncpy_static_write \ | 25 | test_strncpy_static_write \ |
diff --git a/tests/test_strncat_static_write.c b/tests/test_strncat_static_write.c new file mode 100644 index 0000000..9332adc --- /dev/null +++ b/tests/test_strncat_static_write.c | |||
| @@ -0,0 +1,16 @@ | |||
| 1 | #include "common.h" | ||
| 2 | |||
| 3 | #include <string.h> | ||
| 4 | |||
| 5 | int main(int argc, char** argv) { | ||
| 6 | char buffer[8] = {0}; | ||
| 7 | strncat(buffer, "1234567", 5); | ||
| 8 | puts(buffer); | ||
| 9 | |||
| 10 | CHK_FAIL_START | ||
| 11 | strncat(buffer, "1234567890", 10); | ||
| 12 | CHK_FAIL_END | ||
| 13 | |||
| 14 | puts(buffer); | ||
| 15 | return ret; | ||
| 16 | } | ||
