diff options
author | David Garcia Quintas <dgq@google.com> | 2015-07-08 20:13:41 -0700 |
---|---|---|
committer | David Garcia Quintas <dgq@google.com> | 2015-07-08 20:13:41 -0700 |
commit | ffe3d2b1908933a149932502fd0607239ccef88a (patch) | |
tree | d7763ca2f7293ce432542bc67ece431412962535 /test/core/support | |
parent | e35ed0821b445c1df2d23fe267dda78194c47582 (diff) |
Modified gpr_slice_split to take a char* separator.
Diffstat (limited to 'test/core/support')
-rw-r--r-- | test/core/support/string_test.c | 21 |
1 files changed, 9 insertions, 12 deletions
diff --git a/test/core/support/string_test.c b/test/core/support/string_test.c index 7a58307d05..9023d0746b 100644 --- a/test/core/support/string_test.c +++ b/test/core/support/string_test.c @@ -223,7 +223,6 @@ static void test_strjoin_sep(void) { static void test_strsplit(void) { gpr_slice_buffer* parts; gpr_slice str; - gpr_slice sep; LOG_TEST_NAME("test_strsplit"); @@ -231,8 +230,7 @@ static void test_strsplit(void) { gpr_slice_buffer_init(parts); str = gpr_slice_from_copied_string("one, two, three, four"); - sep = gpr_slice_from_copied_string(", "); - gpr_slice_split(str, sep, parts); + gpr_slice_split(str, ", ", parts); GPR_ASSERT(4 == parts->count); GPR_ASSERT(0 == gpr_slice_str_cmp(parts->slices[0], "one")); GPR_ASSERT(0 == gpr_slice_str_cmp(parts->slices[1], "two")); @@ -243,15 +241,15 @@ static void test_strsplit(void) { /* separator not present in string */ str = gpr_slice_from_copied_string("one two three four"); - gpr_slice_split(str, sep, parts); + gpr_slice_split(str, ", ", parts); GPR_ASSERT(1 == parts->count); GPR_ASSERT(0 == gpr_slice_str_cmp(parts->slices[0], "one two three four")); gpr_slice_buffer_reset_and_unref(parts); gpr_slice_unref(str); /* separator at the end */ - str = gpr_slice_from_copied_string("foo, "); - gpr_slice_split(str, sep, parts); + str = gpr_slice_from_copied_string("foo,"); + gpr_slice_split(str, ",", parts); GPR_ASSERT(2 == parts->count); GPR_ASSERT(0 == gpr_slice_str_cmp(parts->slices[0], "foo")); GPR_ASSERT(0 == gpr_slice_str_cmp(parts->slices[1], "")); @@ -259,8 +257,8 @@ static void test_strsplit(void) { gpr_slice_unref(str); /* separator at the beginning */ - str = gpr_slice_from_copied_string(", foo"); - gpr_slice_split(str, sep, parts); + str = gpr_slice_from_copied_string(",foo"); + gpr_slice_split(str, ",", parts); GPR_ASSERT(2 == parts->count); GPR_ASSERT(0 == gpr_slice_str_cmp(parts->slices[0], "")); GPR_ASSERT(0 == gpr_slice_str_cmp(parts->slices[1], "foo")); @@ -268,8 +266,8 @@ static void test_strsplit(void) { gpr_slice_unref(str); /* standalone separator */ - str = gpr_slice_from_copied_string(", "); - gpr_slice_split(str, sep, parts); + str = gpr_slice_from_copied_string(","); + gpr_slice_split(str, ",", parts); GPR_ASSERT(2 == parts->count); GPR_ASSERT(0 == gpr_slice_str_cmp(parts->slices[0], "")); GPR_ASSERT(0 == gpr_slice_str_cmp(parts->slices[1], "")); @@ -278,13 +276,12 @@ static void test_strsplit(void) { /* empty input */ str = gpr_slice_from_copied_string(""); - gpr_slice_split(str, sep, parts); + gpr_slice_split(str, ", ", parts); GPR_ASSERT(1 == parts->count); GPR_ASSERT(0 == gpr_slice_str_cmp(parts->slices[0], "")); gpr_slice_buffer_reset_and_unref(parts); gpr_slice_unref(str); - gpr_slice_unref(sep); gpr_slice_buffer_destroy(parts); gpr_free(parts); } |