blob: c0234985b32a5aa85de69dd8e21d12aaa4730152 (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
|
/*
* This source code is released into the public domain.
*/
#include <string>
#include <catch2/catch_test_macros.hpp>
import nihil.ucl;
TEST_CASE("ucl: boolean: construct", "[ucl]")
{
auto obj = nihil::ucl::boolean(true);
REQUIRE(object_cast<nihil::ucl::boolean>(obj).value() == true);
}
TEST_CASE("ucl: boolean: compare", "[ucl]")
{
auto b = nihil::ucl::boolean(true);
REQUIRE(b == nihil::ucl::boolean(true));
REQUIRE(b == true);
REQUIRE(b != nihil::ucl::boolean(false));
REQUIRE(b != 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<nihil::ucl::boolean>(*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");
}
|