diff options
author | Joseph Hunkeler <jhunkeler@gmail.com> | 2024-11-01 00:55:19 -0400 |
---|---|---|
committer | Joseph Hunkeler <jhunkeler@gmail.com> | 2024-11-01 08:35:19 -0400 |
commit | 35d0480f743abaa5c2c332f513043edd7c59081c (patch) | |
tree | 0e4071402281e44e492df78292002adad0c997d2 /tests/test_str.c | |
parent | d4cbcbfb77476ba8f21b82c608322af80cd6a303 (diff) | |
download | stasis-35d0480f743abaa5c2c332f513043edd7c59081c.tar.gz |
Initialize structs to {0} and combine declaration and assignment where possible
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); } |