From a30e8a9e1849de1c2dc440bf73d5f9291950b875 Mon Sep 17 00:00:00 2001 From: axtloss Date: Tue, 9 Jul 2024 23:02:51 +0200 Subject: Fix tests --- tests/test.c | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) (limited to 'tests') diff --git a/tests/test.c b/tests/test.c index a58602a..b58dfe4 100644 --- a/tests/test.c +++ b/tests/test.c @@ -3,6 +3,7 @@ #include #include #include +#define USE_SECURE_MEM #include "../src/extlib.h" int @@ -50,6 +51,7 @@ test_fcopy() int test_strlwr_strupr () { + char *test_string = strdup ("hello"); char *uppr_string = strupr (test_string); char *lower_string = strlwr (uppr_string); @@ -69,12 +71,22 @@ test_strlwr_strupr () int test_trim() { +#undef free char *test_string = strdup ("\t\thi\t\t"); - char *trimmed_string = trim (test_string); + int rem_front = 0; + int rem_back = 0; + char *trimmed_string = trim (test_string, &rem_front, &rem_back); if (strstr (trimmed_string, "\t") != NULL) { + free (trimmed_string-rem_front); free_secure ((void**)&test_string, strlen (test_string)); return 1; } + if (rem_front != 2 && rem_back != 2) { + free (trimmed_string-rem_front); + free_secure ((void**)&test_string, strlen (test_string)); + return 2; + } + free (trimmed_string-rem_front); free_secure ((void**)&test_string, strlen (test_string)); return 0; } -- cgit v1.2.3