From 09b5fc1fd8fefe672fa1bb3ef63cb43e0f5f5476 Mon Sep 17 00:00:00 2001 From: jvoisin Date: Sun, 17 Sep 2023 15:12:47 +0200 Subject: Add a test for stpcpy --- tests/Makefile | 3 ++- tests/test_stpcpy_dynamic_write.c | 16 ++++++++++++++++ tests/test_stpcpy_static_write.c | 2 +- 3 files changed, 19 insertions(+), 2 deletions(-) create mode 100644 tests/test_stpcpy_dynamic_write.c (limited to 'tests') diff --git a/tests/Makefile b/tests/Makefile index 7f846c2..b702e2e 100644 --- a/tests/Makefile +++ b/tests/Makefile @@ -78,6 +78,7 @@ TARGETS= \ test_stpcpy_overwrite_over \ test_stpcpy_overwrite_under \ test_stpcpy_static_write \ + test_stpcpy_dynamic_write \ test_stpncpy_overwrite_over \ test_stpncpy_overwrite_under \ test_stpncpy_static_write \ @@ -141,7 +142,7 @@ $(TARGETS): %: %.c run: $(TARGETS) $(foreach EXE, $(TARGETS), \ - timeout 1s ./$(EXE) 1 2 3 4 5 6 7 8 9 0 >/dev/null && echo "$(EXE) OK" || echo "$(EXE) FAIL" ; \ + timeout 1s ./$(EXE) 1234567890 2 3 4 5 6 7 8 9 0 >/dev/null && echo "$(EXE) OK" || echo "$(EXE) FAIL"; \ ) clean: diff --git a/tests/test_stpcpy_dynamic_write.c b/tests/test_stpcpy_dynamic_write.c new file mode 100644 index 0000000..0cacda7 --- /dev/null +++ b/tests/test_stpcpy_dynamic_write.c @@ -0,0 +1,16 @@ +#include "common.h" + +#include + +int main(int argc, char** argv) { + char buffer[8] = {0}; + stpcpy(buffer, "1234567"); + puts(buffer); + + CHK_FAIL_START + stpcpy(buffer, argv[1]); + CHK_FAIL_END + + puts(buffer); + return ret; +} diff --git a/tests/test_stpcpy_static_write.c b/tests/test_stpcpy_static_write.c index 4aa4aee..6eff5a5 100644 --- a/tests/test_stpcpy_static_write.c +++ b/tests/test_stpcpy_static_write.c @@ -4,7 +4,7 @@ int main(int argc, char** argv) { char buffer[8] = {0}; - strcpy(buffer, "1234567"); + stpcpy(buffer, "1234567"); puts(buffer); CHK_FAIL_START -- cgit v1.3