Move tests from .h to .cpp

This commit is contained in:
Lucca Jiménez Könings 2024-06-26 11:07:46 +02:00
parent 73ecef1a87
commit 509225f151
2 changed files with 16 additions and 14 deletions

View File

@ -141,18 +141,4 @@ struct Settings {
void setConsoleInputAccessMapping(const ComposedKey& keyName, bool value); void setConsoleInputAccessMapping(const ComposedKey& keyName, bool value);
}; };
TEST_CASE("settings get/set") {
Settings settings;
settings.set(Settings::General_Name, "hello, world");
CHECK_EQ(settings.getAsString(Settings::General_Name), "hello, world");
settings.set(Settings::General_Name, std::string("hello, world"));
CHECK_EQ(settings.getAsString(Settings::General_Name), "hello, world");
settings.set(Settings::General_MaxPlayers, 12);
CHECK_EQ(settings.getAsInt(Settings::General_MaxPlayers), 12);
}
TEST_CASE("settings check for exception on wrong input type") {
Settings settings;
CHECK_THROWS(settings.set(Settings::General_Debug, "hello, world"));
CHECK_NOTHROW(settings.set(Settings::General_Debug, false));
}

View File

@ -173,3 +173,19 @@ void Settings::setConsoleInputAccessMapping(const ComposedKey& keyName, bool val
map->at(key) = value; map->at(key) = value;
} }
TEST_CASE("settings get/set") {
Settings settings;
settings.set(Settings::General_Name, "hello, world");
CHECK_EQ(settings.getAsString(Settings::General_Name), "hello, world");
settings.set(Settings::General_Name, std::string("hello, world"));
CHECK_EQ(settings.getAsString(Settings::General_Name), "hello, world");
settings.set(Settings::General_MaxPlayers, 12);
CHECK_EQ(settings.getAsInt(Settings::General_MaxPlayers), 12);
}
TEST_CASE("settings check for exception on wrong input type") {
Settings settings;
CHECK_THROWS(settings.set(Settings::General_Debug, "hello, world"));
CHECK_NOTHROW(settings.set(Settings::General_Debug, false));
}