/* * This source code is released into the public domain. */ #include #include import nihil.ucl; TEST_CASE("ucl: boolean: construct", "[ucl]") { auto b = nihil::ucl::boolean(true); REQUIRE(b == true); } TEST_CASE("ucl: boolean: default construct", "[ucl]") { auto b = nihil::ucl::boolean(); REQUIRE(b == false); } TEST_CASE("ucl: boolean: operator==", "[ucl]") { auto b = nihil::ucl::boolean(true); REQUIRE(b == true); REQUIRE(b == nihil::ucl::boolean(true)); REQUIRE(b != false); REQUIRE(b != nihil::ucl::boolean(false)); } TEST_CASE("ucl: boolean: operator<=>", "[ucl]") { auto b = nihil::ucl::boolean(false); REQUIRE(b < true); REQUIRE(b < nihil::ucl::boolean(true)); REQUIRE(b >= false); REQUIRE(b >= nihil::ucl::boolean(false)); } TEST_CASE("ucl: boolean: parse", "[ucl]") { using namespace std::literals; auto input = "value = true"sv; auto obj = nihil::ucl::parse(input); auto v = obj.lookup("value"); REQUIRE(v); REQUIRE(v->key() == "value"); REQUIRE(object_cast(*v).value() == true); } TEST_CASE("ucl: boolean: emit", "[ucl]") { auto ucl = nihil::ucl::parse("bool = true;"); auto output = std::string(); emit(ucl, nihil::ucl::emitter::configuration, std::back_inserter(output)); REQUIRE(output == "bool = true;\n"); }