From fa40365faea6b87288504f0d8ad39dab8ff302b4 Mon Sep 17 00:00:00 2001 From: jvoisin Date: Thu, 13 Apr 2023 23:44:52 +0200 Subject: Add tests for strcat and strcpy --- tests/Makefile | 2 ++ tests/test_strcat_static_write.c | 16 ++++++++++++++++ tests/test_strcpy_static_write.c | 16 ++++++++++++++++ 3 files changed, 34 insertions(+) create mode 100644 tests/test_strcat_static_write.c create mode 100644 tests/test_strcpy_static_write.c diff --git a/tests/Makefile b/tests/Makefile index 25f6f66..9cca6f5 100644 --- a/tests/Makefile +++ b/tests/Makefile @@ -11,6 +11,8 @@ TARGETS=test_memcpy_static_write \ test_memmove_dynamic_read \ test_memset_static_write \ test_memset_dynamic_write \ + test_strcpy_static_write \ + test_strcat_static_write \ .SILENT: diff --git a/tests/test_strcat_static_write.c b/tests/test_strcat_static_write.c new file mode 100644 index 0000000..d0cb903 --- /dev/null +++ b/tests/test_strcat_static_write.c @@ -0,0 +1,16 @@ +#include "common.h" + +#include + +int main(int argc, char** argv) { + char buffer[8] = {0}; + strcat(buffer, "1234567"); + puts(buffer); + + CHK_FAIL_START + strcat(buffer, "1234567890"); + CHK_FAIL_END + + puts(buffer); + return ret; +} diff --git a/tests/test_strcpy_static_write.c b/tests/test_strcpy_static_write.c new file mode 100644 index 0000000..a3e8100 --- /dev/null +++ b/tests/test_strcpy_static_write.c @@ -0,0 +1,16 @@ +#include "common.h" + +#include + +int main(int argc, char** argv) { + char buffer[8] = {0}; + strcpy(buffer, "1234567"); + puts(buffer); + + CHK_FAIL_START + strcpy(buffer, "1234567890"); + CHK_FAIL_END + + puts(buffer); + return ret; +} -- cgit v1.3