aboutsummaryrefslogtreecommitdiffstats
path: root/nihil.ucl/tests/parse.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/parse.cc
parent1db86c401df11423c945634d8b2a483e97afa878 (diff)
downloadnihil-90aa957ca9b7c217af7569009d1675e0f3ff8e9b.tar.gz
nihil-90aa957ca9b7c217af7569009d1675e0f3ff8e9b.tar.bz2
ucl, config: use monadic error handling more
Diffstat (limited to 'nihil.ucl/tests/parse.cc')
-rw-r--r--nihil.ucl/tests/parse.cc14
1 files changed, 10 insertions, 4 deletions
diff --git a/nihil.ucl/tests/parse.cc b/nihil.ucl/tests/parse.cc
index 3cf5742..c56974e 100644
--- a/nihil.ucl/tests/parse.cc
+++ b/nihil.ucl/tests/parse.cc
@@ -15,13 +15,18 @@ TEST_CASE("ucl parse: iterate array", "[ucl]")
using namespace std::literals;
using namespace nihil::ucl;
- auto obj = parse("value = [1, 42, 666];"sv);
+ auto err = parse("value = [1, 42, 666];"sv);
+ REQUIRE(err);
+
+ auto obj = *err;
auto arr = obj["value"];
REQUIRE(arr.key() == "value");
- auto vec = std::vector(std::from_range,
- object_cast<array<integer>>(arr));
+ auto ints = object_cast<array<integer>>(arr);
+ REQUIRE(ints);
+
+ auto vec = std::vector(std::from_range, *ints);
REQUIRE(vec.size() == 3);
REQUIRE(vec[0] == 1);
@@ -36,8 +41,9 @@ TEST_CASE("ucl parse: iterate hash", "[ucl]")
auto input = "int = 42; bool = true; str = \"test\";"sv;
auto obj = parse(input);
+ REQUIRE(obj);
- for (auto &&[key, value] : obj) {
+ for (auto &&[key, value] : *obj) {
REQUIRE(key == value.key());
if (key == "int")