Skip to content

Commit 145f474

Browse files
author
thk123
committed
Adding tests for empty string edge cases
1 parent 07009d4 commit 145f474

File tree

1 file changed

+33
-0
lines changed

1 file changed

+33
-0
lines changed

unit/util/string_utils/split_string.cpp

+33
Original file line numberDiff line numberDiff line change
@@ -101,6 +101,39 @@ SCENARIO("split_string", "[core][utils][string_utils][split_string]")
101101

102102
run_on_all_variants(string, delimiter, expected_results);
103103
}
104+
GIVEN("An empty string")
105+
{
106+
std::string string = "";
107+
WHEN("Splitting it")
108+
{
109+
expected_resultst expected_results;
110+
expected_results.no_strip_no_remove = {""};
111+
expected_results.strip_no_remove = {""};
112+
113+
// TODO(tkiley): This is probably wrong, since I'd expect removing empty
114+
// TODO(tkiley): elements to return an empty vector here.
115+
expected_results.no_strip_remove_empty = {""};
116+
expected_results.strip_remove_empty = {""};
117+
118+
run_on_all_variants(string, ',', expected_results);
119+
}
120+
}
121+
GIVEN("A whitespace only string")
122+
{
123+
std::string string = " ";
124+
WHEN("Splitting it")
125+
{
126+
expected_resultst expected_results;
127+
expected_results.no_strip_no_remove = {" "};
128+
expected_results.strip_no_remove = {""};
129+
expected_results.no_strip_remove_empty = {" "};
130+
// TODO(tkiley): This is probably wrong, since I'd expect removing empty
131+
// TODO(tkiley): elements to return an empty vector here.
132+
expected_results.strip_remove_empty = {""};
133+
134+
run_on_all_variants(string, ',', expected_results);
135+
}
136+
}
104137
}
105138

106139
SCENARIO("split_string into two", "[core][utils][string_utils][split_string]")

0 commit comments

Comments
 (0)