diff options
author | Joseph Hunkeler <jhunkeler@users.noreply.github.com> | 2024-11-06 08:55:52 -0500 |
---|---|---|
committer | GitHub <noreply@github.com> | 2024-11-06 08:55:52 -0500 |
commit | 52e6d0f495023c0aa939bf6b2170ca5ea853202b (patch) | |
tree | 897a87316c280b6824892368662afcb848de1cf6 /tests/test_str.c | |
parent | 6db1b15b5c62d6fb52825c1d833ac8dfa9a49fbb (diff) | |
parent | 46ae10e55603b8852612ebe12c7636c2b358bdd6 (diff) | |
download | stasis-52e6d0f495023c0aa939bf6b2170ca5ea853202b.tar.gz |
Merge pull request #67 from jhunkeler/safety-and-convenience
Safety and convenience
Diffstat (limited to 'tests/test_str.c')
-rw-r--r-- | tests/test_str.c | 8 |
1 files changed, 3 insertions, 5 deletions
diff --git a/tests/test_str.c b/tests/test_str.c index 4991c1c..3aea50b 100644 --- a/tests/test_str.c +++ b/tests/test_str.c @@ -204,8 +204,7 @@ void test_split() { {.data = NULL, .delim = NULL, NULL}, }; for (size_t i = 0; i < sizeof(tc) / sizeof(*tc); i++) { - char **result; - result = split(tc[i].data, tc[i].delim, tc[i].max_split); + char **result = split((char *) tc[i].data, tc[i].delim, tc[i].max_split); STASIS_ASSERT(strcmp_array((const char **) result, tc[i].expected) == 0, "Split failed"); GENERIC_ARRAY_FREE(result); } @@ -243,8 +242,7 @@ void test_join_ex() { {.delim = "\n\n", .expected = "a\n\nb\n\nc\n\nd\n\ne"}, }; for (size_t i = 0; i < sizeof(tc) / sizeof(*tc); i++) { - char *result; - result = join_ex((char *) tc[i].delim, "a", "b", "c", "d", "e", NULL); + char *result = join_ex((char *) tc[i].delim, "a", "b", "c", "d", "e", NULL); STASIS_ASSERT(strcmp(result ? result : "", tc[i].expected) == 0, "failed to join array"); guard_free(result); } @@ -270,7 +268,7 @@ void test_substring_between() { {.data = "nothing () here", .delim = "()", .expected = ""}, // nothing exists between delimiters }; for (size_t i = 0; i < sizeof(tc) / sizeof(*tc); i++) { - char *result = substring_between(tc[i].data, tc[i].delim); + char *result = substring_between((char *) tc[i].data, tc[i].delim); STASIS_ASSERT(strcmp(result ? result : "", tc[i].expected) == 0, "unable to extract substring"); guard_free(result); } |