aboutsummaryrefslogtreecommitdiffstats
path: root/nihil.ucl/tests/boolean.cc
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.ucl/tests/boolean.cc
parent1db86c401df11423c945634d8b2a483e97afa878 (diff)
downloadnihil-90aa957ca9b7c217af7569009d1675e0f3ff8e9b.tar.gz
nihil-90aa957ca9b7c217af7569009d1675e0f3ff8e9b.tar.bz2
ucl, config: use monadic error handling more
Diffstat (limited to 'nihil.ucl/tests/boolean.cc')
-rw-r--r--nihil.ucl/tests/boolean.cc18
1 files changed, 13 insertions, 5 deletions
diff --git a/nihil.ucl/tests/boolean.cc b/nihil.ucl/tests/boolean.cc
index 49dc408..495071d 100644
--- a/nihil.ucl/tests/boolean.cc
+++ b/nihil.ucl/tests/boolean.cc
@@ -62,8 +62,11 @@ TEST_CASE("ucl: boolean: key()", "[ucl]")
{
using namespace nihil::ucl;
- auto obj = parse("a_bool = true");
- REQUIRE(object_cast<boolean>(obj["a_bool"]).key() == "a_bool");
+ auto err = parse("a_bool = true");
+ REQUIRE(err);
+
+ auto obj = *err;
+ REQUIRE(object_cast<boolean>(obj["a_bool"])->key() == "a_bool");
auto b = nihil::ucl::boolean(true);
REQUIRE(b.key() == "");
@@ -95,10 +98,14 @@ TEST_CASE("ucl: boolean: parse", "[ucl]")
{
using namespace std::literals;
- auto obj = nihil::ucl::parse("value = true"sv);
+ auto err = nihil::ucl::parse("value = true"sv);
+ REQUIRE(err);
+
+ auto obj = *err;
+
auto v = obj["value"];
REQUIRE(v.key() == "value");
- REQUIRE(object_cast<nihil::ucl::boolean>(v) == true);
+ REQUIRE(*object_cast<nihil::ucl::boolean>(v) == true);
}
TEST_CASE("ucl: boolean: emit", "[ucl]")
@@ -111,9 +118,10 @@ TEST_CASE("ucl: boolean: emit", "[ucl]")
TEST_CASE("ucl: boolean: parse and emit", "[ucl]")
{
auto ucl = nihil::ucl::parse("bool = true;");
+ REQUIRE(ucl);
auto output = std::string();
- emit(ucl, nihil::ucl::emitter::configuration,
+ emit(*ucl, nihil::ucl::emitter::configuration,
std::back_inserter(output));
REQUIRE(output == "bool = true;\n");