1
0
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:
Ted John
2017-02-24 21:48:06 +00:00
parent 84d69b797b
commit 3b341de835
3 changed files with 38 additions and 19 deletions

27
test/tests/StringTest.cpp Normal file
View 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);
}