mirror of
https://github.com/baldurk/renderdoc.git
synced 2026-05-13 05:20:45 +00:00
Don't process split of an empty string
This commit is contained in:
@@ -152,6 +152,9 @@ std::wstring get_dirname(const std::wstring &path)
|
||||
|
||||
void split(const std::string &in, std::vector<std::string> &out, const char sep)
|
||||
{
|
||||
if(in.empty())
|
||||
return;
|
||||
|
||||
{
|
||||
size_t numSeps = 0;
|
||||
|
||||
@@ -388,6 +391,20 @@ TEST_CASE("String manipulation", "[string]")
|
||||
merge(vec, str, ' ');
|
||||
CHECK(str == "Hello World");
|
||||
};
|
||||
|
||||
SECTION("degenerate cases")
|
||||
{
|
||||
std::vector<std::string> vec;
|
||||
std::string str;
|
||||
|
||||
split(std::string(), vec, ',');
|
||||
|
||||
REQUIRE(vec.empty());
|
||||
|
||||
merge(vec, str, ',');
|
||||
|
||||
REQUIRE(str == "");
|
||||
};
|
||||
};
|
||||
|
||||
#endif // ENABLED(ENABLE_UNIT_TESTS)
|
||||
|
||||
Reference in New Issue
Block a user