Unverified Commit 20f6ed92 authored by ravil-mobile's avatar ravil-mobile Committed by GitHub
Browse files

Fixed `split_string` from stringutils (#2160)

parent bded0949
......@@ -86,7 +86,7 @@ inline std::string join_strings(Strings strings, const std::string& delim)
inline std::vector<std::string> split_string(const std::string& s, char delim)
{
std::vector<std::string> elems;
std::stringstream ss(s + ' ');
std::stringstream ss(s + delim);
std::string item;
while(std::getline(ss, item, delim))
{
......
......@@ -99,4 +99,29 @@ TEST_CASE(interpolate_string_custom3)
EXPECT(s == "****b****");
}
TEST_CASE(slit_string_simple1)
{
std::string input = "one,two,three";
auto resuts = migraphx::split_string(input, ',');
EXPECT(resuts.size() == 3);
EXPECT(resuts.front() == "one");
EXPECT(resuts.back() == "three");
}
TEST_CASE(slit_string_simple2)
{
std::string input = "one";
auto resuts = migraphx::split_string(input, ',');
EXPECT(resuts.size() == 1);
EXPECT(resuts.front() == "one");
}
TEST_CASE(slit_string_simple3)
{
std::string input = "one two three";
auto resuts = migraphx::split_string(input, ',');
EXPECT(resuts.size() == 1);
EXPECT(resuts.front() == "one two three");
}
int main(int argc, const char* argv[]) { test::run(argc, argv); }
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment