aboutsummaryrefslogtreecommitdiffstats
path: root/nihil.config/tests
diff options
context:
space:
mode:
authorLexi Winter <lexi@le-fay.org>2025-06-26 20:47:45 +0100
committerLexi Winter <lexi@le-fay.org>2025-06-26 20:47:45 +0100
commit90aa957ca9b7c217af7569009d1675e0f3ff8e9b (patch)
treee6a61ca2b6928e6414372b9b1484ce80fa2fb0b3 /nihil.config/tests
parent1db86c401df11423c945634d8b2a483e97afa878 (diff)
downloadnihil-90aa957ca9b7c217af7569009d1675e0f3ff8e9b.tar.gz
nihil-90aa957ca9b7c217af7569009d1675e0f3ff8e9b.tar.bz2
ucl, config: use monadic error handling more
Diffstat (limited to 'nihil.config/tests')
-rw-r--r--nihil.config/tests/string.cc22
1 files changed, 12 insertions, 10 deletions
diff --git a/nihil.config/tests/string.cc b/nihil.config/tests/string.cc
index 7e95190..aeb1ef8 100644
--- a/nihil.config/tests/string.cc
+++ b/nihil.config/tests/string.cc
@@ -12,23 +12,25 @@ TEST_CASE("nihil.config: string option", "[nihil][nihil.config]")
{
std::string storage;
- REQUIRE_THROWS_AS(nihil::config::get_option("test_option"),
- nihil::config::unknown_option);
+ auto opt = nihil::config::get_option("test_option");
+ REQUIRE(!opt);
{
auto string_option = nihil::config::string(
storage, "test_option", "This is a test option");
- auto &opt = nihil::config::get_option("test_option");
- REQUIRE(opt.name() == "test_option");
- REQUIRE(opt.description() == "This is a test option");
- REQUIRE(opt.is_default() == true);
- REQUIRE(opt.string() == "");
+ auto opt = nihil::config::get_option("test_option");
+ REQUIRE(opt);
- opt.string("testing");
+ REQUIRE((*opt)->name() == "test_option");
+ REQUIRE((*opt)->description() == "This is a test option");
+ REQUIRE((*opt)->is_default() == true);
+ REQUIRE((*opt)->string() == "");
+
+ REQUIRE((*opt)->string("testing"));
REQUIRE(storage == "testing");
}
- REQUIRE_THROWS_AS(nihil::config::get_option("test_option"),
- nihil::config::unknown_option);
+ opt = nihil::config::get_option("test_option");
+ REQUIRE(!opt);
}