mirror of
https://github.com/OpenRCT2/OpenRCT2
synced 2025-12-21 23:03:04 +01:00
Fix String::Trim and add test
This commit is contained in:
27
test/tests/StringTest.cpp
Normal file
27
test/tests/StringTest.cpp
Normal file
@@ -0,0 +1,27 @@
|
||||
#include <string>
|
||||
#include <tuple>
|
||||
#include <gtest/gtest.h>
|
||||
#include <openrct2/core/String.hpp>
|
||||
|
||||
using TCase = std::tuple<std::string, std::string>;
|
||||
|
||||
class StringTest : public testing::TestWithParam<TCase>
|
||||
{
|
||||
};
|
||||
|
||||
INSTANTIATE_TEST_CASE_P(TrimData, StringTest, testing::Values(
|
||||
TCase("string", "string"),
|
||||
TCase(" string", "string"),
|
||||
TCase("string ", "string"),
|
||||
TCase(" some string ", "some string"),
|
||||
TCase(" ", ""),
|
||||
TCase("", "")
|
||||
));
|
||||
TEST_P(StringTest, Trim)
|
||||
{
|
||||
auto testCase = GetParam();
|
||||
std::string input = std::get<0>(testCase);
|
||||
std::string expected = std::get<1>(testCase);
|
||||
std::string actual = String::Trim(input);
|
||||
ASSERT_EQ(expected, actual);
|
||||
}
|
||||
Reference in New Issue
Block a user