From 7aa261f8d57cb53cc334f6bf1920a6f8517ff054 Mon Sep 17 00:00:00 2001 From: axtloss Date: Fri, 27 Sep 2024 12:11:52 +0200 Subject: Rework test suite to be more modular --- tests/test_strlwr_strupr.c | 32 ++++++++++++++++++++++++++++++++ 1 file changed, 32 insertions(+) create mode 100644 tests/test_strlwr_strupr.c (limited to 'tests/test_strlwr_strupr.c') diff --git a/tests/test_strlwr_strupr.c b/tests/test_strlwr_strupr.c new file mode 100644 index 0000000..ce166f1 --- /dev/null +++ b/tests/test_strlwr_strupr.c @@ -0,0 +1,32 @@ +#include +#define USE_SECURE_MEM +#include "../src/extlib.h" + +int +test_strlwr_strupr () +{ + int errno = 0; + char *test_string = strdup ("meow"); + + char *uppr_string = strupr (test_string); + if (strcmp (uppr_string, "MEOW") != 0) + errno = 1; + + char *lower_string = strlwr (uppr_string); + if (strcmp (lower_string, "meow") != 0) + errno = 2; + + free_secure ((void **) &test_string, strlen (test_string)); + return errno; +} + +struct test_t* +test_strlwr_strupr_t () +{ + struct test_t* test = malloc (sizeof (struct test_t)); + test->test_func=test_strlwr_strupr; + test->test_name="test_strlwr_strupr"; + test->test_desc="strlwr strupr"; + return test; +} + -- cgit v1.2.3