From 757e5d60be862e8d22dd7f5cce2bb0087ac7fd21 Mon Sep 17 00:00:00 2001 From: ToruNiina Date: Wed, 4 Sep 2019 13:36:42 +0900 Subject: [PATCH] test: add flag for toml-head features to tests --- tests/test_lex_floating.cpp | 17 +++++++++++++++++ tests/test_parse_floating.cpp | 15 +++++++++++++++ 2 files changed, 32 insertions(+) diff --git a/tests/test_lex_floating.cpp b/tests/test_lex_floating.cpp index ed6e79f..9c5c809 100644 --- a/tests/test_lex_floating.cpp +++ b/tests/test_lex_floating.cpp @@ -51,12 +51,18 @@ BOOST_AUTO_TEST_CASE(test_exponential_valid) TOML11_TEST_LEX_ACCEPT(lex_float, "123E-10", "123E-10"); TOML11_TEST_LEX_ACCEPT(lex_float, "1_2_3E-10", "1_2_3E-10"); TOML11_TEST_LEX_ACCEPT(lex_float, "1_2_3E-1_0", "1_2_3E-1_0"); + +#ifdef TOML11_USE_UNRELEASED_TOML_FEATURES + BOOST_TEST_MESSAGE("testing an unreleased toml feature: leading zeroes in float exponent part"); + // toml-lang/toml master permits leading 0s in exp part (unreleased) TOML11_TEST_LEX_ACCEPT(lex_float, "1_2_3E-01", "1_2_3E-01"); TOML11_TEST_LEX_ACCEPT(lex_float, "1_2_3E-0_1", "1_2_3E-0_1"); +#endif } BOOST_AUTO_TEST_CASE(test_exponential_invalid) { + // accept partially TOML11_TEST_LEX_ACCEPT(lex_float, "1e1E0", "1e1"); TOML11_TEST_LEX_ACCEPT(lex_float, "1E1e0", "1E1"); } @@ -66,15 +72,26 @@ BOOST_AUTO_TEST_CASE(test_both_valid) TOML11_TEST_LEX_ACCEPT(lex_float, "6.02e23", "6.02e23"); TOML11_TEST_LEX_ACCEPT(lex_float, "6.02e+23", "6.02e+23"); TOML11_TEST_LEX_ACCEPT(lex_float, "1.112_650_06e-17", "1.112_650_06e-17"); + +#ifdef TOML11_USE_UNRELEASED_TOML_FEATURES + BOOST_TEST_MESSAGE("testing an unreleased toml feature: leading zeroes in float exponent part"); + // toml-lang/toml master permits leading 0s in exp part (unreleased) TOML11_TEST_LEX_ACCEPT(lex_float, "1.0e-07", "1.0e-07"); +#endif } BOOST_AUTO_TEST_CASE(test_both_invalid) { TOML11_TEST_LEX_REJECT(lex_float, "01e1.0"); + // accept partially TOML11_TEST_LEX_ACCEPT(lex_float, "1e1.0", "1e1"); + +#ifdef TOML11_USE_UNRELEASED_TOML_FEATURES + BOOST_TEST_MESSAGE("testing an unreleased toml feature: leading zeroes in float exponent part"); + // toml-lang/toml master permits leading 0s in exp part (unreleased) TOML11_TEST_LEX_ACCEPT(lex_float, "1.0e_01", "1.0"); TOML11_TEST_LEX_ACCEPT(lex_float, "1.0e0__1", "1.0e0"); +#endif } BOOST_AUTO_TEST_CASE(test_special_floating_point) diff --git a/tests/test_parse_floating.cpp b/tests/test_parse_floating.cpp index 6d10f75..6b0c680 100644 --- a/tests/test_parse_floating.cpp +++ b/tests/test_parse_floating.cpp @@ -68,8 +68,13 @@ BOOST_AUTO_TEST_CASE(test_exponential) TOML11_TEST_PARSE_EQUAL(parse_floating, "1_2_3E-1_0", 123e-10); TOML11_TEST_PARSE_EQUAL(parse_floating, "+0e0", 0.0); TOML11_TEST_PARSE_EQUAL(parse_floating, "-0e0", -0.0); + +#ifdef TOML11_USE_UNRELEASED_TOML_FEATURES + BOOST_TEST_MESSAGE("testing an unreleased toml feature: leading zeroes in float exponent part"); + // toml-lang/toml master permits leading 0s in exp part (unreleased) TOML11_TEST_PARSE_EQUAL(parse_floating, "1_2_3E-01", 123e-1); TOML11_TEST_PARSE_EQUAL(parse_floating, "1_2_3E-0_1", 123e-1); +#endif } BOOST_AUTO_TEST_CASE(test_exponential_value) @@ -92,8 +97,13 @@ BOOST_AUTO_TEST_CASE(test_exponential_value) TOML11_TEST_PARSE_EQUAL_VALUE(parse_value, "1_2_3E-1_0", value(123e-10)); TOML11_TEST_PARSE_EQUAL_VALUE(parse_value, "+0e0", value( 0.0)); TOML11_TEST_PARSE_EQUAL_VALUE(parse_value, "-0e0", value(-0.0)); + +#ifdef TOML11_USE_UNRELEASED_TOML_FEATURES + BOOST_TEST_MESSAGE("testing an unreleased toml feature: leading zeroes in float exponent part"); + // toml-lang/toml master permits leading 0s in exp part (unreleased) TOML11_TEST_PARSE_EQUAL_VALUE(parse_value, "1_2_3E-01", value(123e-1)); TOML11_TEST_PARSE_EQUAL_VALUE(parse_value, "1_2_3E-0_1", value(123e-1)); +#endif } BOOST_AUTO_TEST_CASE(test_fe) { @@ -106,7 +116,12 @@ BOOST_AUTO_TEST_CASE(test_fe_vaule) TOML11_TEST_PARSE_EQUAL_VALUE(parse_value, "6.02e23", value(6.02e23)); TOML11_TEST_PARSE_EQUAL_VALUE(parse_value, "6.02e+23", value(6.02e23)); TOML11_TEST_PARSE_EQUAL_VALUE(parse_value, "1.112_650_06e-17", value(1.11265006e-17)); + +#ifdef TOML11_USE_UNRELEASED_TOML_FEATURES + BOOST_TEST_MESSAGE("testing an unreleased toml feature: leading zeroes in float exponent part"); + // toml-lang/toml master permits leading 0s in exp part (unreleased) TOML11_TEST_PARSE_EQUAL_VALUE(parse_value, "3.141_5e-01", value(3.1415e-1)); +#endif } BOOST_AUTO_TEST_CASE(test_inf)