Add Value bool conversion to C++

This commit is contained in:
Simon Hausmann 2021-03-17 14:15:13 +01:00
parent a34d6e6563
commit 831bf58baa
3 changed files with 26 additions and 2 deletions

View file

@ -59,4 +59,15 @@ SCENARIO("Value API")
REQUIRE(number_opt.has_value());
REQUIRE(number_opt.value() == number);
}
SECTION("Construct a bool")
{
REQUIRE(!value.to_bool().has_value());
value = Value(true);
REQUIRE(value.type() == Value::Type::Bool);
auto bool_opt = value.to_bool();
REQUIRE(bool_opt.has_value());
REQUIRE(bool_opt.value() == true);
}
}