1
0
mirror of https://github.com/OpenRCT2/OpenRCT2 synced 2026-02-01 03:05:24 +01:00

Migrate remaining C strings in config handling

This commit is contained in:
Gymnasiast
2023-01-07 15:27:29 +01:00
parent 18d9e72173
commit b6d422ff95
11 changed files with 48 additions and 80 deletions

View File

@@ -35,7 +35,7 @@ TEST_F(IniReaderTest, create_empty)
auto ir = CreateIniReader(&ms);
ASSERT_NE(ir, nullptr);
ASSERT_EQ(ir->GetBoolean("nobody", true), true);
ASSERT_EQ(ir->GetCString("expects", nullptr), nullptr);
ASSERT_EQ(ir->GetString("expects", ""), "");
ASSERT_EQ(ir->GetEnum<int32_t>("spanish", 12345, Enum_Currency), 12345);
ASSERT_EQ(ir->GetFloat("inquisition", 1.234f), 1.234f);
ASSERT_EQ(ir->GetInt32("universal_answer", 42), 42);
@@ -64,9 +64,8 @@ TEST_F(IniReaderTest, read_prepared)
// values from different sections
ASSERT_EQ(ir->GetInt32("one", 42), 42);
ASSERT_EQ(ir->GetBoolean("boolval", false), true);
const utf8* str = ir->GetCString("path", nullptr);
ASSERT_STREQ(str, u8"C:'\\some/dir\\here/神鷹暢遊");
Memory::Free(str);
const auto& str = ir->GetString("path", "");
ASSERT_STREQ(str.c_str(), u8"C:'\\some/dir\\here/神鷹暢遊");
// go back a section
ASSERT_EQ(ir->ReadSection("int"), true);
ASSERT_EQ(ir->GetInt32("one", 42), 1);
@@ -107,9 +106,8 @@ TEST_F(IniReaderTest, read_untrimmed)
// there should only be data from the last section
ASSERT_EQ(ir->ReadSection("section"), true);
ASSERT_EQ(ir->GetBoolean("one", false), true);
const utf8* str = ir->GetCString("str", nullptr);
ASSERT_STREQ(str, " xxx ");
Memory::Free(str);
const auto& str = ir->GetString("str", "");
ASSERT_STREQ(str.c_str(), " xxx ");
ASSERT_EQ(ir->GetString("str", "yyy"), " xxx ");
ASSERT_EQ(ir->GetString("nosuchthing", " yyy "), " yyy ");
}