aboutsummaryrefslogtreecommitdiff
path: root/tests/test_join_str.c
diff options
context:
space:
mode:
authoraxtloss <axtlos@getcryst.al>2024-09-27 12:11:52 +0200
committeraxtloss <axtlos@getcryst.al>2024-09-27 12:11:52 +0200
commit7aa261f8d57cb53cc334f6bf1920a6f8517ff054 (patch)
treef23a96feda17de737c71b45dc94e7e044410ad35 /tests/test_join_str.c
parent27bb394bc0bf2ca66d06931bf1e73a3e20d5741a (diff)
downloadextlib-7aa261f8d57cb53cc334f6bf1920a6f8517ff054.tar.gz
extlib-7aa261f8d57cb53cc334f6bf1920a6f8517ff054.tar.bz2
Rework test suite to be more modular
Diffstat (limited to 'tests/test_join_str.c')
-rw-r--r--tests/test_join_str.c35
1 files changed, 35 insertions, 0 deletions
diff --git a/tests/test_join_str.c b/tests/test_join_str.c
new file mode 100644
index 0000000..711c864
--- /dev/null
+++ b/tests/test_join_str.c
@@ -0,0 +1,35 @@
+#include <string.h>
+#define USE_SECURE_MEM
+#include "../src/extlib.h"
+#undef free
+
+int
+test_join_str ()
+{
+ int errno = 0;
+ char **test_string = malloc (sizeof (char *) * 4);
+ for (int i = 0; i < 3; i++)
+ test_string[i] = strdup ("hello");
+
+ char *joined_string = join_str (test_string, 3, ' ');
+
+ if (strcmp (joined_string, "hello hello hello") != 0)
+ errno = 1;
+
+ free_secure ((void **) &test_string[0], strlen (test_string[0]));
+ free_secure ((void **) &test_string[1], strlen (test_string[1]));
+ free_secure ((void **) &test_string[2], strlen (test_string[2]));
+ free (test_string);
+ free_secure ((void **) &joined_string, strlen (joined_string));
+ return errno;
+}
+
+struct test_t*
+test_join_str_t()
+{
+ struct test_t* test = malloc (sizeof (struct test_t));
+ test->test_func=test_join_str;
+ test->test_name="test_join_str";
+ test->test_desc="join_str";
+ return test;
+}