diff options
author | axtloss <axtlos@getcryst.al> | 2024-09-27 12:11:52 +0200 |
---|---|---|
committer | axtloss <axtlos@getcryst.al> | 2024-09-27 12:11:52 +0200 |
commit | 7aa261f8d57cb53cc334f6bf1920a6f8517ff054 (patch) | |
tree | f23a96feda17de737c71b45dc94e7e044410ad35 /tests/test_replace_str.c | |
parent | 27bb394bc0bf2ca66d06931bf1e73a3e20d5741a (diff) | |
download | extlib-7aa261f8d57cb53cc334f6bf1920a6f8517ff054.tar.gz extlib-7aa261f8d57cb53cc334f6bf1920a6f8517ff054.tar.bz2 |
Rework test suite to be more modular
Diffstat (limited to 'tests/test_replace_str.c')
-rw-r--r-- | tests/test_replace_str.c | 26 |
1 files changed, 26 insertions, 0 deletions
diff --git a/tests/test_replace_str.c b/tests/test_replace_str.c new file mode 100644 index 0000000..020149f --- /dev/null +++ b/tests/test_replace_str.c @@ -0,0 +1,26 @@ +#include <string.h> +#define USE_SECURE_MEM +#include "../src/extlib.h" + +int +test_replace_str () +{ + int errno = 0; + char *test_string = strdup ("replace world!"); + char *replaced_string = replace_str (test_string, "replace", "hello"); + if (strcmp (replaced_string, "hello world!") != 0) + errno = 1; + + free_secure ((void **) &test_string, strlen (test_string)); + free_secure ((void **) &replaced_string, strlen (replaced_string)); + return errno; +} + +struct test_t* +test_replace_str_t () +{ + struct test_t* test = malloc (sizeof (struct test_t)); + test->test_func = test_replace_str; + test->test_name = "test_replace_str"; + test->test_desc = "replace_str"; +} |