Skip to content

Commit fc8ba88

Browse files
author
thk123
committed
Revert to aborting precondition for function inputs
1 parent a385d9b commit fc8ba88

File tree

2 files changed

+8
-40
lines changed

2 files changed

+8
-40
lines changed

src/util/string_utils.cpp

Lines changed: 4 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -53,11 +53,8 @@ void split_string(
5353
bool remove_empty)
5454
{
5555
PRECONDITION(result.empty());
56-
if(strip && std::isspace(delim))
57-
{
58-
throw std::invalid_argument(
59-
"delim can't be a space character if using strip");
60-
}
56+
// delim can't be a space character if using strip
57+
PRECONDITION(!std::isspace(delim) || !strip);
6158

6259
if(s.empty())
6360
{
@@ -106,11 +103,8 @@ void split_string(
106103
std::string &right,
107104
bool strip)
108105
{
109-
if(strip && std::isspace(delim))
110-
{
111-
throw std::invalid_argument(
112-
"delim can't be a space character if using strip");
113-
}
106+
// delim can't be a space character if using strip
107+
PRECONDITION(!std::isspace(delim) || !strip);
114108

115109
std::vector<std::string> result;
116110

unit/util/string_utils/split_string.cpp

Lines changed: 4 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -165,26 +165,8 @@ SCENARIO("split_string", "[core][utils][string_utils][split_string]")
165165
Catch::Matchers::Vector::EqualsMatcher<std::string>{expected_result});
166166
}
167167
}
168-
WHEN("Stripping, not removing empty")
169-
{
170-
std::vector<std::string> result;
171-
THEN("Should throw an exception")
172-
{
173-
REQUIRE_THROWS_AS(
174-
split_string(string, delimiter, result, true, false),
175-
std::invalid_argument);
176-
}
177-
}
178-
WHEN("Stripping and removing empty")
179-
{
180-
std::vector<std::string> result;
181-
THEN("Should throw an exception")
182-
{
183-
REQUIRE_THROWS_AS(
184-
split_string(string, delimiter, result, true, true),
185-
std::invalid_argument);
186-
}
187-
}
168+
// TODO(tkiley): here we should check what happens when trying to enable
169+
// TODO(tkiley): strip, but currently the behaviour terminates the unit test
188170
}
189171
}
190172

@@ -223,15 +205,7 @@ SCENARIO("split_string into two", "[core][utils][string_utils][split_string]")
223205
REQUIRE(s2 == "b");
224206
}
225207
}
226-
WHEN("Splitting in two and stripping")
227-
{
228-
THEN("An invalid argument exception should be raised")
229-
{
230-
std::string s1;
231-
std::string s2;
232-
REQUIRE_THROWS_AS(
233-
split_string(string, delimiter, s1, s2, true), std::invalid_argument);
234-
}
235-
}
208+
// TODO(tkiley): here we should check what happens when trying to enable
209+
// TODO(tkiley): strip, but currently the behaviour terminates the unit test
236210
}
237211
}

0 commit comments

Comments
 (0)