forked from rosebudai/OpenRCT2-Web
Improve String::Split and add tests
This commit is contained in:
1 parent
7ccce750a6
commit
0ec43e3611
5 files changed
+74
-15
No files matched your search
@@ -2,6 +2,7 @@
|
||||
#include <tuple>
|
||||
#include <gtest/gtest.h>
|
||||
#include <openrct2/core/String.hpp>
|
||||
#include "AssertHelpers.hpp"
|
||||
|
||||
using TCase = std::tuple<std::string, std::string>;
|
||||
|
||||
@@ -28,3 +29,23 @@ TEST_P(StringTest, Trim)
|
||||
std::string actual = String::Trim(input);
|
||||
ASSERT_EQ(expected, actual);
|
||||
}
|
||||
|
||||
TEST_F(StringTest, Split_ByComma)
|
||||
{
|
||||
auto actual = String::Split("a,bb,ccc,dd", ",");
|
||||
AssertVector<std::string>(actual, { "a", "bb", "ccc", "dd" });
|
||||
}
|
||||
TEST_F(StringTest, Split_ByColonColon)
|
||||
{
|
||||
auto actual = String::Split("a::bb:ccc:::::dd", "::");
|
||||
AssertVector<std::string>(actual, { "a", "bb:ccc", "", ":dd" });
|
||||
}
|
||||
TEST_F(StringTest, Split_Empty)
|
||||
{
|
||||
auto actual = String::Split("", ".");
|
||||
AssertVector<std::string>(actual, { });
|
||||
}
|
||||
TEST_F(StringTest, Split_ByEmpty)
|
||||
{
|
||||
EXPECT_THROW(String::Split("string", ""), std::invalid_argument);
|
||||
}
|
||||
Reference in new issue
Block a user