test: update test codes to v4

This commit is contained in:
ToruNiina
2024-06-15 19:14:06 +09:00
parent 7c123ab378
commit c47ff10a64
69 changed files with 6792 additions and 8535 deletions

View File

@@ -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);
}