mirror of
https://github.com/ToruNiina/toml11.git
synced 2025-09-17 09:08:08 +08:00
test: update test codes to v4
This commit is contained in:
@@ -1,19 +1,44 @@
|
||||
#include <toml/parser.hpp>
|
||||
#define DOCTEST_CONFIG_IMPLEMENT_WITH_MAIN
|
||||
#include "doctest.h"
|
||||
|
||||
#include "unit_test.hpp"
|
||||
#include "test_parse_aux.hpp"
|
||||
#include "utility.hpp"
|
||||
|
||||
using namespace toml;
|
||||
using namespace detail;
|
||||
#include <toml11/parser.hpp>
|
||||
#include <toml11/types.hpp>
|
||||
|
||||
BOOST_AUTO_TEST_CASE(test_boolean)
|
||||
TEST_CASE("testing valid boolean")
|
||||
{
|
||||
TOML11_TEST_PARSE_EQUAL(parse_boolean, "true", true);
|
||||
TOML11_TEST_PARSE_EQUAL(parse_boolean, "false", false);
|
||||
const toml::detail::context<toml::type_config> 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);
|
||||
}
|
||||
}
|
||||
|
||||
BOOST_AUTO_TEST_CASE(test_boolean_value)
|
||||
TEST_CASE("testing invalid boolean")
|
||||
{
|
||||
TOML11_TEST_PARSE_EQUAL_VALUE(parse_value<toml::value>, "true", toml::value( true));
|
||||
TOML11_TEST_PARSE_EQUAL_VALUE(parse_value<toml::value>, "false", toml::value(false));
|
||||
using namespace toml::detail;
|
||||
|
||||
const context<toml::type_config> ctx(toml::spec::v(1,0,0));
|
||||
|
||||
toml11_test_parse_failure(parse_boolean<toml::type_config>, "True", ctx);
|
||||
toml11_test_parse_failure(parse_boolean<toml::type_config>, "TRUE", ctx);
|
||||
toml11_test_parse_failure(parse_boolean<toml::type_config>, "False", ctx);
|
||||
toml11_test_parse_failure(parse_boolean<toml::type_config>, "FALSE", ctx);
|
||||
}
|
||||
|
Reference in New Issue
Block a user