diff options
author | axtloss <axtlos@getcryst.al> | 2024-07-09 23:02:51 +0200 |
---|---|---|
committer | axtloss <axtlos@getcryst.al> | 2024-07-09 23:02:51 +0200 |
commit | a30e8a9e1849de1c2dc440bf73d5f9291950b875 (patch) | |
tree | 254d58c78cf6bfce4b2f57683e3ae777d73ba133 /tests | |
parent | 5a0598e0b8d42bc3800cf0d0a49572d13f7b0afa (diff) | |
download | extlib-a30e8a9e1849de1c2dc440bf73d5f9291950b875.tar.gz extlib-a30e8a9e1849de1c2dc440bf73d5f9291950b875.tar.bz2 |
Fix tests
Diffstat (limited to 'tests')
-rw-r--r-- | tests/test.c | 14 |
1 files changed, 13 insertions, 1 deletions
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 <stdio.h> #include <assert.h> #include <sys/types.h> +#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; } |