#define DOCTEST_CONFIG_IMPLEMENT_WITH_MAIN #include "doctest.h" #include "utility.hpp" #include #include TEST_CASE("testing valid boolean") { const toml::detail::context ctx(toml::spec::v(1,0,0)); { auto loc = toml::detail::make_temporary_location("true"); const auto res = toml::detail::parse_boolean(loc, ctx); REQUIRE_UNARY(res.is_ok()); const auto val = res.unwrap(); REQUIRE_UNARY(val.is_boolean()); CHECK_EQ(val.as_boolean(), true); } { auto loc = toml::detail::make_temporary_location("false"); const auto res = toml::detail::parse_boolean(loc, ctx); REQUIRE_UNARY(res.is_ok()); const auto val = res.unwrap(); REQUIRE_UNARY(val.is_boolean()); CHECK_EQ(val.as_boolean(), false); } } TEST_CASE("testing invalid boolean") { using namespace toml::detail; const context ctx(toml::spec::v(1,0,0)); toml11_test_parse_failure(parse_boolean, "True", ctx); toml11_test_parse_failure(parse_boolean, "TRUE", ctx); toml11_test_parse_failure(parse_boolean, "False", ctx); toml11_test_parse_failure(parse_boolean, "FALSE", ctx); }