diff options
| author | Lexi Winter <lexi@le-fay.org> | 2025-06-26 20:47:45 +0100 |
|---|---|---|
| committer | Lexi Winter <lexi@le-fay.org> | 2025-06-26 20:47:45 +0100 |
| commit | 90aa957ca9b7c217af7569009d1675e0f3ff8e9b (patch) | |
| tree | e6a61ca2b6928e6414372b9b1484ce80fa2fb0b3 /nihil.ucl/tests/integer.cc | |
| parent | 1db86c401df11423c945634d8b2a483e97afa878 (diff) | |
| download | nihil-90aa957ca9b7c217af7569009d1675e0f3ff8e9b.tar.gz nihil-90aa957ca9b7c217af7569009d1675e0f3ff8e9b.tar.bz2 | |
ucl, config: use monadic error handling more
Diffstat (limited to 'nihil.ucl/tests/integer.cc')
| -rw-r--r-- | nihil.ucl/tests/integer.cc | 16 |
1 files changed, 12 insertions, 4 deletions
diff --git a/nihil.ucl/tests/integer.cc b/nihil.ucl/tests/integer.cc index 811a864..05647fe 100644 --- a/nihil.ucl/tests/integer.cc +++ b/nihil.ucl/tests/integer.cc @@ -63,8 +63,11 @@ TEST_CASE("ucl: integer: key()", "[ucl]") { using namespace nihil::ucl; - auto obj = parse("an_int = 42"); - REQUIRE(object_cast<integer>(obj["an_int"]).key() == "an_int"); + auto err = parse("an_int = 42"); + REQUIRE(err); + + auto obj = *err; + REQUIRE(object_cast<integer>(obj["an_int"])->key() == "an_int"); auto i = nihil::ucl::integer(42); REQUIRE(i.key() == ""); @@ -96,7 +99,11 @@ TEST_CASE("ucl: integer: parse", "[ucl]") { using namespace std::literals; - auto obj = nihil::ucl::parse("value = 42"sv); + auto err = nihil::ucl::parse("value = 42"sv); + REQUIRE(err); + + auto obj = *err; + auto v = obj["value"]; REQUIRE(v.key() == "value"); REQUIRE(object_cast<nihil::ucl::integer>(v) == 42); @@ -112,9 +119,10 @@ TEST_CASE("ucl: integer: emit", "[ucl]") TEST_CASE("ucl: integer: parse and emit", "[ucl]") { auto ucl = nihil::ucl::parse("int = 42;"); + REQUIRE(ucl); auto output = std::string(); - emit(ucl, nihil::ucl::emitter::configuration, + emit(*ucl, nihil::ucl::emitter::configuration, std::back_inserter(output)); REQUIRE(output == "int = 42;\n"); |
