From 90aa957ca9b7c217af7569009d1675e0f3ff8e9b Mon Sep 17 00:00:00 2001 From: Lexi Winter Date: Thu, 26 Jun 2025 20:47:45 +0100 Subject: ucl, config: use monadic error handling more --- nihil.ucl/tests/string.cc | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) (limited to 'nihil.ucl/tests/string.cc') diff --git a/nihil.ucl/tests/string.cc b/nihil.ucl/tests/string.cc index e7eb0ad..995e95a 100644 --- a/nihil.ucl/tests/string.cc +++ b/nihil.ucl/tests/string.cc @@ -109,8 +109,11 @@ TEST_CASE("ucl: string: key()", "[ucl]") { using namespace nihil::ucl; - auto obj = parse("a_string = \"test\""); - REQUIRE(object_cast(obj["a_string"]).key() == "a_string"); + auto err = parse("a_string = \"test\""); + REQUIRE(err); + + auto obj = *err; + REQUIRE(object_cast(obj["a_string"])->key() == "a_string"); auto s = nihil::ucl::string("test"); REQUIRE(s.key() == ""); @@ -188,7 +191,10 @@ TEST_CASE("ucl: string: parse", "[ucl]") { using namespace std::literals; - auto obj = nihil::ucl::parse("value = \"te\\\"st\""sv); + auto err = nihil::ucl::parse("value = \"te\\\"st\""sv); + REQUIRE(err); + + auto obj = *err; auto v = obj["value"]; REQUIRE(v.key() == "value"); REQUIRE(object_cast(v) == "te\"st"); @@ -204,9 +210,10 @@ TEST_CASE("ucl: string: emit", "[ucl]") TEST_CASE("ucl: string: parse and emit", "[ucl]") { auto ucl = nihil::ucl::parse("str = \"te\\\"st\";"); + REQUIRE(ucl); auto output = std::string(); - emit(ucl, nihil::ucl::emitter::configuration, + emit(*ucl, nihil::ucl::emitter::configuration, std::back_inserter(output)); REQUIRE(output == "str = \"te\\\"st\";\n"); -- cgit v1.2.3