#include #include TEST_CASE("Check handling of optional values") { std::filesystem::path path("TestConfigs/Optionality.conf"); Garbage::SimpleConf config(path); SECTION("GetOptional behaviour") { REQUIRE(!config.GetOptional("non-existent key")); REQUIRE(*config.GetOptional("existing key") == "existing value"); } SECTION("Get behaviour") { using Required = Garbage::SimpleConf::Required; using LookupError = Garbage::SimpleConfImplementation::LookupError; REQUIRE(config.Get("non-existent key", "a default") == "a default"); REQUIRE(config.Get("existing key") == "existing value"); REQUIRE_THROWS_AS((config.Get("non-existent key")), LookupError); } }