From 8f31ec8aed7f014d82599006c799f421e6eb83aa Mon Sep 17 00:00:00 2001 From: Mark Gillard Date: Sun, 29 Jan 2023 17:49:41 +0200 Subject: [PATCH] fixed #187 also: - fixed #188 - fixed #189 - updated conformance tests - version bump --- CHANGELOG.md | 7 +- include/toml++/impl/parser.inl | 36 +- include/toml++/impl/preprocessor.h | 2 +- include/toml++/impl/version.h | 2 +- include/toml++/toml.h | 11 +- tests/conformance_burntsushi_invalid.cpp | 1396 +++++- tests/conformance_burntsushi_valid.cpp | 5810 +++++++++++++++------- tests/conformance_iarna_invalid.cpp | 285 +- tests/conformance_iarna_valid.cpp | 3301 ++++++------ tests/user_feedback.cpp | 11 + toml.hpp | 46 +- tools/generate_conformance_tests.py | 9 + 12 files changed, 7216 insertions(+), 3700 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index d46bb9d..849e47e 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -21,13 +21,18 @@ template: --> -## Unreleased +## v3.3.0 + +[Released](https://github.com/marzer/tomlplusplus/releases/tag/v3.3.0) 2023-01-29 #### Fixes: - fixed null pointer dereference in parser when exceptions are disabled (#169) (@ncaklovic) - fixed spurious warnings in MSVC 19.34 - fixed `toml::parse_file()` on windows for non-ASCII paths +- fixed a spurious table redefinition error (#187) (@jorisvr) +- fixed UB edge-case in integer parsing (#188) (@jorisvr) +- fixed some build issues with Apple-flavoured Clang (#189) (@eddelbuettel) #### Additions: diff --git a/include/toml++/impl/parser.inl b/include/toml++/impl/parser.inl index f780cd8..27de2b0 100644 --- a/include/toml++/impl/parser.inl +++ b/include/toml++/impl/parser.inl @@ -2262,14 +2262,21 @@ TOML_IMPL_NAMESPACE_START } // range check - if TOML_UNLIKELY(result > static_cast((std::numeric_limits::max)()) + (sign < 0 ? 1ull : 0ull)) + static constexpr auto i64_max = static_cast((std::numeric_limits::max)()); + if TOML_UNLIKELY(result > i64_max + (sign < 0 ? 1u : 0u)) set_error_and_return_default("'"sv, traits::full_prefix, std::string_view{ digits, length }, "' is not representable in 64 bits"sv); if constexpr (traits::is_signed) + { + // avoid signed multiply UB when parsing INT64_MIN + if TOML_UNLIKELY(sign < 0 && result == i64_max + 1u) + return (std::numeric_limits::min)(); + return static_cast(result) * sign; + } else return static_cast(result); } @@ -3252,13 +3259,28 @@ TOML_IMPL_NAMESPACE_START else if (auto tbl = matching_node.as_table(); !is_arr && tbl && !implicit_tables.empty()) { - if (auto found = impl::find(implicit_tables.begin(), implicit_tables.end(), tbl); - found && (tbl->empty() || tbl->is_homogeneous())) + if (auto found = impl::find(implicit_tables.begin(), implicit_tables.end(), tbl); found) { - implicit_tables.erase(implicit_tables.cbegin() + (found - implicit_tables.data())); - tbl->source_.begin = header_begin_pos; - tbl->source_.end = header_end_pos; - return tbl; + bool ok = true; + if (!tbl->empty()) + { + for (auto& [_, child] : *tbl) + { + if (!child.is_table() && !child.is_array_of_tables()) + { + ok = false; + break; + } + } + } + + if (ok) + { + implicit_tables.erase(implicit_tables.cbegin() + (found - implicit_tables.data())); + tbl->source_.begin = header_begin_pos; + tbl->source_.end = header_end_pos; + return tbl; + } } } diff --git a/include/toml++/impl/preprocessor.h b/include/toml++/impl/preprocessor.h index a2d8e43..85dc08b 100644 --- a/include/toml++/impl/preprocessor.h +++ b/include/toml++/impl/preprocessor.h @@ -515,7 +515,7 @@ __pragma(warning(push)) \ static_assert(true) -#if TOML_HAS_INCLUDE() +#if TOML_HAS_INCLUDE() #pragma warning(push, 0) #include #pragma warning(pop) diff --git a/include/toml++/impl/version.h b/include/toml++/impl/version.h index 1157b95..d03d9b9 100644 --- a/include/toml++/impl/version.h +++ b/include/toml++/impl/version.h @@ -5,7 +5,7 @@ #pragma once #define TOML_LIB_MAJOR 3 -#define TOML_LIB_MINOR 2 +#define TOML_LIB_MINOR 3 #define TOML_LIB_PATCH 0 #define TOML_LANG_MAJOR 1 diff --git a/include/toml++/toml.h b/include/toml++/toml.h index 22ddf59..b76d6d1 100644 --- a/include/toml++/toml.h +++ b/include/toml++/toml.h @@ -7,9 +7,6 @@ #define INCLUDE_TOMLPLUSPLUS_H // old guard name used pre-v3 -//# Note: these would be included transitively as with any normal C++ project but -//# they're listed explicitly here because this file is used as the source for generate_single_header.py. - #include "impl/preprocessor.h" TOML_PUSH_WARNINGS; @@ -24,12 +21,12 @@ TOML_DISABLE_SUGGEST_ATTR_WARNINGS; #pragma warning(disable : 4251) // dll exports for std lib types #endif #elif TOML_CLANG -#pragma clang diagnostic ignored "-Wheader-hygiene" +TOML_PRAGMA_CLANG(diagnostic ignored "-Wheader-hygiene") #if TOML_CLANG >= 12 -#pragma clang diagnostic ignored "-Wc++20-extensions" +TOML_PRAGMA_CLANG(diagnostic ignored "-Wc++20-extensions") #endif -#if TOML_CLANG == 13 && !defined(__APPLE__) -#pragma clang diagnostic ignored "-Wreserved-identifier" +#if TOML_CLANG == 13 +TOML_PRAGMA_CLANG(diagnostic ignored "-Wreserved-identifier") #endif #endif diff --git a/tests/conformance_burntsushi_invalid.cpp b/tests/conformance_burntsushi_invalid.cpp index e25086d..2428b14 100644 --- a/tests/conformance_burntsushi_invalid.cpp +++ b/tests/conformance_burntsushi_invalid.cpp @@ -129,6 +129,9 @@ no-secs = 1987-07-05T17:45Z)"sv; #endif // !TOML_LANG_UNRELEASED + static constexpr auto encoding_bad_codepoint = + "\x23\x20\x49\x6E\x76\x61\x6C\x69\x64\x20\x63\x6F\x64\x65\x70\x6F\x69\x6E\x74\x20\x55\x2B\x44\x38\x30" + "\x30\x20\x3A\x20\xED\xA0\x80\x0A"sv; static constexpr auto encoding_bad_utf8_at_end = "\x23\x20\x54\x68\x65\x72\x65\x20\x69\x73\x20\x61\x20\x30\x78\x64\x61\x20\x61\x74\x20\x61\x66\x74\x65" "\x72\x20\x74\x68\x65\x20\x71\x75\x6F\x74\x65\x73\x2C\x20\x61\x6E\x64\x20\x6E\x6F\x20\x45\x4F\x4C\x20" @@ -141,6 +144,18 @@ no-secs = 1987-07-05T17:45Z)"sv; "\x61\x75\x73\x65\x20\x69\x74\x27\x73\x20\x74\x68\x65\x20\x65\x6E\x64\x20\x6F\x66\x20\x74\x68\x65\x20" "\x66\x69\x6C\x65\x2E\x0A\x78\x20\x3D\x20\x22\x22\x22\x22\x22\x22\xDA"sv; static constexpr auto encoding_bad_utf8_in_comment = "\x23\x20\xC3\x0A"sv; + static constexpr auto encoding_bad_utf8_in_multiline_literal = + "\x23\x20\x54\x68\x65\x20\x66\x6F\x6C\x6C\x6F\x77\x69\x6E\x67\x20\x6C\x69\x6E\x65\x20\x63\x6F\x6E\x74" + "\x61\x69\x6E\x73\x20\x61\x6E\x20\x69\x6E\x76\x61\x6C\x69\x64\x20\x55\x54\x46\x2D\x38\x20\x73\x65\x71" + "\x75\x65\x6E\x63\x65\x2E\x0A\x62\x61\x64\x20\x3D\x20\x27\x27\x27\xC3\x27\x27\x27\x0A"sv; + static constexpr auto encoding_bad_utf8_in_multiline = + "\x23\x20\x54\x68\x65\x20\x66\x6F\x6C\x6C\x6F\x77\x69\x6E\x67\x20\x6C\x69\x6E\x65\x20\x63\x6F\x6E\x74" + "\x61\x69\x6E\x73\x20\x61\x6E\x20\x69\x6E\x76\x61\x6C\x69\x64\x20\x55\x54\x46\x2D\x38\x20\x73\x65\x71" + "\x75\x65\x6E\x63\x65\x2E\x0A\x62\x61\x64\x20\x3D\x20\x22\x22\x22\xC3\x22\x22\x22\x0A"sv; + static constexpr auto encoding_bad_utf8_in_string_literal = + "\x23\x20\x54\x68\x65\x20\x66\x6F\x6C\x6C\x6F\x77\x69\x6E\x67\x20\x6C\x69\x6E\x65\x20\x63\x6F\x6E\x74" + "\x61\x69\x6E\x73\x20\x61\x6E\x20\x69\x6E\x76\x61\x6C\x69\x64\x20\x55\x54\x46\x2D\x38\x20\x73\x65\x71" + "\x75\x65\x6E\x63\x65\x2E\x0A\x62\x61\x64\x20\x3D\x20\x27\xC3\x27\x0A"sv; static constexpr auto encoding_bad_utf8_in_string = "\x23\x20\x54\x68\x65\x20\x66\x6F\x6C\x6C\x6F\x77\x69\x6E\x67\x20\x6C\x69\x6E\x65\x20\x63\x6F\x6E\x74" "\x61\x69\x6E\x73\x20\x61\x6E\x20\x69\x6E\x76\x61\x6C\x69\x64\x20\x55\x54\x46\x2D\x38\x20\x73\x65\x71" @@ -164,6 +179,7 @@ no-secs = 1987-07-05T17:45Z)"sv; static constexpr auto float_exp_point_1 = R"(exp-point-1 = 1e2.3)"sv; static constexpr auto float_exp_point_2 = R"(exp-point-2 = 1.e2)"sv; static constexpr auto float_exp_trailing_us = R"(exp-trailing-us = 1e_23_)"sv; + static constexpr auto float_inf_capital = R"(v = Inf)"sv; static constexpr auto float_inf_incomplete_1 = R"(inf-incomplete-1 = in)"sv; static constexpr auto float_inf_incomplete_2 = R"(inf-incomplete-2 = +in)"sv; static constexpr auto float_inf_incomplete_3 = R"(inf-incomplete-3 = -in)"sv; @@ -175,6 +191,7 @@ no-secs = 1987-07-05T17:45Z)"sv; static constexpr auto float_leading_zero_neg = R"(leading-zero-neg = -03.14)"sv; static constexpr auto float_leading_zero_plus = R"(leading-zero-plus = +03.14)"sv; static constexpr auto float_leading_zero = R"(leading-zero = 03.14)"sv; + static constexpr auto float_nan_capital = R"(v = NaN)"sv; static constexpr auto float_nan_incomplete_1 = R"(nan-incomplete-1 = na)"sv; static constexpr auto float_nan_incomplete_2 = R"(nan-incomplete-2 = +na)"sv; static constexpr auto float_nan_incomplete_3 = R"(nan-incomplete-3 = -na)"sv; @@ -190,15 +207,19 @@ trailing-us-exp2 = 1.2_e2)"sv; static constexpr auto float_us_after_point = R"(us-after-point = 1._2)"sv; static constexpr auto float_us_before_point = R"(us-before-point = 1_.2)"sv; - static constexpr auto inline_table_add = R"(a={} + static constexpr auto inline_table_add = R"(a={} # Inline tables are immutable and can't be extended [a.b])"sv; - static constexpr auto inline_table_double_comma = R"(t = {x=3,,y=4})"sv; - static constexpr auto inline_table_duplicate_key = R"(# Duplicate keys within an inline table are invalid + static constexpr auto inline_table_bad_key_syntax = R"(tbl = { a = 1, [b] })"sv; + static constexpr auto inline_table_dotted_key_conflict = R"(tbl = { a.b = "a_b", a.b.c = "a_b_c" })"sv; + static constexpr auto inline_table_double_comma = R"(t = {x=3,,y=4})"sv; + static constexpr auto inline_table_duplicate_key = R"(# Duplicate keys within an inline table are invalid a={b=1, b=2})"sv; - static constexpr auto inline_table_empty = R"(t = {,})"sv; - static constexpr auto inline_table_no_comma = R"(t = {x = 3 y = 4})"sv; - static constexpr auto inline_table_overwrite = R"(a.b=0 + static constexpr auto inline_table_empty = R"(t = {,})"sv; + static constexpr auto inline_table_nested_key_conflict = + R"(tbl = { fruit = { apple.color = "red" }, fruit.apple.texture = { smooth = true } })"sv; + static constexpr auto inline_table_no_comma = R"(t = {x = 3 y = 4})"sv; + static constexpr auto inline_table_overwrite = R"(a.b=0 # Since table "a" is already defined, it can't be replaced by an inline table. a={})"sv; @@ -306,12 +327,60 @@ key""" = 1)"sv; #endif // !TOML_LANG_UNRELEASED && UNICODE_LITERALS_OK + static constexpr auto spec_inline_table_2_0 = R"([product] +type = { name = "Nail" } +type.edible = false # INVALID)"sv; + static constexpr auto spec_inline_table_3_0 = R"([product] +type.name = "Nail" +type = { edible = false } # INVALID)"sv; + static constexpr auto spec_key_value_pair_1 = R"(key = # INVALID)"sv; + static constexpr auto spec_keys_2 = R"(= "no key name" # INVALID +"" = "blank" # VALID but discouraged +'' = 'blank' # VALID but discouraged)"sv; + static constexpr auto spec_string_4_0 = R"(str4 = """Here are two quotation marks: "". Simple enough.""" +str5 = """Here are three quotation marks: """.""" # INVALID +str5 = """Here are three quotation marks: ""\".""" +str6 = """Here are fifteen quotation marks: ""\"""\"""\"""\"""\".""" + +# "This," she said, "is just a pointless statement." +str7 = """"This," she said, "is just a pointless statement."""")"sv; + static constexpr auto spec_string_7_0 = R"(quot15 = '''Here are fifteen quotation marks: """""""""""""""''' + +apos15 = '''Here are fifteen apostrophes: '''''''''''''''''' # INVALID +apos15 = "Here are fifteen apostrophes: '''''''''''''''" + +# 'That,' she said, 'is still pointless.' +str = ''''That,' she said, 'is still pointless.'''')"sv; + static constexpr auto spec_table_9_0 = R"([fruit] +apple.color = "red" +apple.taste.sweet = true + +[fruit.apple] # INVALID +# [fruit.apple.taste] # INVALID + +[fruit.apple.texture] # you can add sub-tables +smooth = true)"sv; + static constexpr auto spec_table_9_1 = R"([fruit] +apple.color = "red" +apple.taste.sweet = true + +# [fruit.apple] # INVALID +[fruit.apple.taste] # INVALID + +[fruit.apple.texture] # you can add sub-tables +smooth = true)"sv; + static constexpr auto string_bad_byte_escape = R"(naughty = "\xAg")"sv; static constexpr auto string_bad_codepoint = R"(invalid-codepoint = "This string contains a non scalar unicode codepoint \uD801")"sv; static constexpr auto string_bad_concat = R"(no_concat = "first" "second")"sv; static constexpr auto string_bad_escape_1 = R"(invalid-escape = "This string has a bad \a escape character.")"sv; static constexpr auto string_bad_escape_2 = R"(invalid-escape = "This string has a bad \ escape character.")"sv; + static constexpr auto string_bad_hex_esc_1 = R"(bad-hex-esc-1 = "\x0g")"sv; + static constexpr auto string_bad_hex_esc_2 = R"(bad-hex-esc-2 = "\xG0")"sv; + static constexpr auto string_bad_hex_esc_3 = R"(bad-hex-esc-3 = "\x")"sv; + static constexpr auto string_bad_hex_esc_4 = R"(bad-hex-esc-4 = "\x 50")"sv; + static constexpr auto string_bad_hex_esc_5 = R"(bad-hex-esc-5 = "\x 50")"sv; static constexpr auto string_bad_multiline = R"(multi = "first line second line")"sv; static constexpr auto string_bad_slash_escape = @@ -353,7 +422,11 @@ k = """t\ """)"sv; #endif // !TOML_LANG_UNRELEASED - static constexpr auto table_append_with_dotted_keys_1 = R"(# First a.b.c defines a table: a.b.c = {z=9} + static constexpr auto table_append_to_array_with_dotted_keys = R"([[a.b]] + +[a] +b.y = 2)"sv; + static constexpr auto table_append_with_dotted_keys_1 = R"(# First a.b.c defines a table: a.b.c = {z=9} # # Then we define a.b.c.t = "str" to add a str to the above table, making it: # @@ -398,6 +471,10 @@ name = "Glory Days" name = "Born in the USA")"sv; static constexpr auto table_array_missing_bracket = R"([[albums] name = "Born to Run")"sv; + static constexpr auto table_duplicate_key_dotted_array = R"([fruit] +apple.color = "red" + +[[fruit.apple]])"sv; static constexpr auto table_duplicate_key_dotted_table = R"([fruit] apple.color = "red" @@ -445,493 +522,1318 @@ answer = 42)"sv; TEST_CASE("conformance - burntsushi/invalid") { - parsing_should_fail(FILE_LINE_ARGS, array_double_comma_1); // array-double-comma-1 + SECTION("array-double-comma-1") + { + parsing_should_fail(FILE_LINE_ARGS, array_double_comma_1); // array-double-comma-1 + } - parsing_should_fail(FILE_LINE_ARGS, array_double_comma_2); // array-double-comma-2 + SECTION("array-double-comma-2") + { + parsing_should_fail(FILE_LINE_ARGS, array_double_comma_2); // array-double-comma-2 + } - parsing_should_fail(FILE_LINE_ARGS, array_extending_table); // array-extending-table + SECTION("array-extending-table") + { + parsing_should_fail(FILE_LINE_ARGS, array_extending_table); // array-extending-table + } - parsing_should_fail(FILE_LINE_ARGS, array_missing_separator); // array-missing-separator + SECTION("array-missing-separator") + { + parsing_should_fail(FILE_LINE_ARGS, array_missing_separator); // array-missing-separator + } - parsing_should_fail(FILE_LINE_ARGS, array_no_close_2); // array-no-close-2 + SECTION("array-no-close-2") + { + parsing_should_fail(FILE_LINE_ARGS, array_no_close_2); // array-no-close-2 + } - parsing_should_fail(FILE_LINE_ARGS, array_no_close_table_2); // array-no-close-table-2 + SECTION("array-no-close-table-2") + { + parsing_should_fail(FILE_LINE_ARGS, array_no_close_table_2); // array-no-close-table-2 + } - parsing_should_fail(FILE_LINE_ARGS, array_no_close_table); // array-no-close-table + SECTION("array-no-close-table") + { + parsing_should_fail(FILE_LINE_ARGS, array_no_close_table); // array-no-close-table + } - parsing_should_fail(FILE_LINE_ARGS, array_no_close); // array-no-close + SECTION("array-no-close") + { + parsing_should_fail(FILE_LINE_ARGS, array_no_close); // array-no-close + } - parsing_should_fail(FILE_LINE_ARGS, array_tables_1); // array-tables-1 + SECTION("array-tables-1") + { + parsing_should_fail(FILE_LINE_ARGS, array_tables_1); // array-tables-1 + } - parsing_should_fail(FILE_LINE_ARGS, array_tables_2); // array-tables-2 + SECTION("array-tables-2") + { + parsing_should_fail(FILE_LINE_ARGS, array_tables_2); // array-tables-2 + } - parsing_should_fail(FILE_LINE_ARGS, array_text_after_array_entries); // array-text-after-array-entries + SECTION("array-text-after-array-entries") + { + parsing_should_fail(FILE_LINE_ARGS, array_text_after_array_entries); // array-text-after-array-entries + } - parsing_should_fail(FILE_LINE_ARGS, array_text_before_array_separator); // array-text-before-array-separator + SECTION("array-text-before-array-separator") + { + parsing_should_fail(FILE_LINE_ARGS, array_text_before_array_separator); // array-text-before-array-separator + } - parsing_should_fail(FILE_LINE_ARGS, array_text_in_array); // array-text-in-array + SECTION("array-text-in-array") + { + parsing_should_fail(FILE_LINE_ARGS, array_text_in_array); // array-text-in-array + } - parsing_should_fail(FILE_LINE_ARGS, bool_almost_false_with_extra); // bool-almost-false-with-extra + SECTION("bool-almost-false-with-extra") + { + parsing_should_fail(FILE_LINE_ARGS, bool_almost_false_with_extra); // bool-almost-false-with-extra + } - parsing_should_fail(FILE_LINE_ARGS, bool_almost_false); // bool-almost-false + SECTION("bool-almost-false") + { + parsing_should_fail(FILE_LINE_ARGS, bool_almost_false); // bool-almost-false + } - parsing_should_fail(FILE_LINE_ARGS, bool_almost_true_with_extra); // bool-almost-true-with-extra + SECTION("bool-almost-true-with-extra") + { + parsing_should_fail(FILE_LINE_ARGS, bool_almost_true_with_extra); // bool-almost-true-with-extra + } - parsing_should_fail(FILE_LINE_ARGS, bool_almost_true); // bool-almost-true + SECTION("bool-almost-true") + { + parsing_should_fail(FILE_LINE_ARGS, bool_almost_true); // bool-almost-true + } - parsing_should_fail(FILE_LINE_ARGS, bool_just_f); // bool-just-f + SECTION("bool-just-f") + { + parsing_should_fail(FILE_LINE_ARGS, bool_just_f); // bool-just-f + } - parsing_should_fail(FILE_LINE_ARGS, bool_just_t); // bool-just-t + SECTION("bool-just-t") + { + parsing_should_fail(FILE_LINE_ARGS, bool_just_t); // bool-just-t + } - parsing_should_fail(FILE_LINE_ARGS, bool_mixed_case); // bool-mixed-case + SECTION("bool-mixed-case") + { + parsing_should_fail(FILE_LINE_ARGS, bool_mixed_case); // bool-mixed-case + } - parsing_should_fail(FILE_LINE_ARGS, bool_starting_same_false); // bool-starting-same-false + SECTION("bool-starting-same-false") + { + parsing_should_fail(FILE_LINE_ARGS, bool_starting_same_false); // bool-starting-same-false + } - parsing_should_fail(FILE_LINE_ARGS, bool_starting_same_true); // bool-starting-same-true + SECTION("bool-starting-same-true") + { + parsing_should_fail(FILE_LINE_ARGS, bool_starting_same_true); // bool-starting-same-true + } - parsing_should_fail(FILE_LINE_ARGS, bool_wrong_case_false); // bool-wrong-case-false + SECTION("bool-wrong-case-false") + { + parsing_should_fail(FILE_LINE_ARGS, bool_wrong_case_false); // bool-wrong-case-false + } - parsing_should_fail(FILE_LINE_ARGS, bool_wrong_case_true); // bool-wrong-case-true + SECTION("bool-wrong-case-true") + { + parsing_should_fail(FILE_LINE_ARGS, bool_wrong_case_true); // bool-wrong-case-true + } - parsing_should_fail(FILE_LINE_ARGS, control_bare_cr); // control-bare-cr + SECTION("control-bare-cr") + { + parsing_should_fail(FILE_LINE_ARGS, control_bare_cr); // control-bare-cr + } - parsing_should_fail(FILE_LINE_ARGS, control_bare_formfeed); // control-bare-formfeed + SECTION("control-bare-formfeed") + { + parsing_should_fail(FILE_LINE_ARGS, control_bare_formfeed); // control-bare-formfeed + } - parsing_should_fail(FILE_LINE_ARGS, control_bare_null); // control-bare-null + SECTION("control-bare-null") + { + parsing_should_fail(FILE_LINE_ARGS, control_bare_null); // control-bare-null + } - parsing_should_fail(FILE_LINE_ARGS, control_bare_vertical_tab); // control-bare-vertical-tab + SECTION("control-bare-vertical-tab") + { + parsing_should_fail(FILE_LINE_ARGS, control_bare_vertical_tab); // control-bare-vertical-tab + } - parsing_should_fail(FILE_LINE_ARGS, control_comment_cr); // control-comment-cr + SECTION("control-comment-cr") + { + parsing_should_fail(FILE_LINE_ARGS, control_comment_cr); // control-comment-cr + } - parsing_should_fail(FILE_LINE_ARGS, control_comment_del); // control-comment-del + SECTION("control-comment-del") + { + parsing_should_fail(FILE_LINE_ARGS, control_comment_del); // control-comment-del + } - parsing_should_fail(FILE_LINE_ARGS, control_comment_lf); // control-comment-lf + SECTION("control-comment-lf") + { + parsing_should_fail(FILE_LINE_ARGS, control_comment_lf); // control-comment-lf + } - parsing_should_fail(FILE_LINE_ARGS, control_comment_null); // control-comment-null + SECTION("control-comment-null") + { + parsing_should_fail(FILE_LINE_ARGS, control_comment_null); // control-comment-null + } - parsing_should_fail(FILE_LINE_ARGS, control_comment_us); // control-comment-us + SECTION("control-comment-us") + { + parsing_should_fail(FILE_LINE_ARGS, control_comment_us); // control-comment-us + } - parsing_should_fail(FILE_LINE_ARGS, control_multi_del); // control-multi-del + SECTION("control-multi-del") + { + parsing_should_fail(FILE_LINE_ARGS, control_multi_del); // control-multi-del + } - parsing_should_fail(FILE_LINE_ARGS, control_multi_lf); // control-multi-lf + SECTION("control-multi-lf") + { + parsing_should_fail(FILE_LINE_ARGS, control_multi_lf); // control-multi-lf + } - parsing_should_fail(FILE_LINE_ARGS, control_multi_null); // control-multi-null + SECTION("control-multi-null") + { + parsing_should_fail(FILE_LINE_ARGS, control_multi_null); // control-multi-null + } - parsing_should_fail(FILE_LINE_ARGS, control_multi_us); // control-multi-us + SECTION("control-multi-us") + { + parsing_should_fail(FILE_LINE_ARGS, control_multi_us); // control-multi-us + } - parsing_should_fail(FILE_LINE_ARGS, control_rawmulti_del); // control-rawmulti-del + SECTION("control-rawmulti-del") + { + parsing_should_fail(FILE_LINE_ARGS, control_rawmulti_del); // control-rawmulti-del + } - parsing_should_fail(FILE_LINE_ARGS, control_rawmulti_lf); // control-rawmulti-lf + SECTION("control-rawmulti-lf") + { + parsing_should_fail(FILE_LINE_ARGS, control_rawmulti_lf); // control-rawmulti-lf + } - parsing_should_fail(FILE_LINE_ARGS, control_rawmulti_null); // control-rawmulti-null + SECTION("control-rawmulti-null") + { + parsing_should_fail(FILE_LINE_ARGS, control_rawmulti_null); // control-rawmulti-null + } - parsing_should_fail(FILE_LINE_ARGS, control_rawmulti_us); // control-rawmulti-us + SECTION("control-rawmulti-us") + { + parsing_should_fail(FILE_LINE_ARGS, control_rawmulti_us); // control-rawmulti-us + } - parsing_should_fail(FILE_LINE_ARGS, control_rawstring_del); // control-rawstring-del + SECTION("control-rawstring-del") + { + parsing_should_fail(FILE_LINE_ARGS, control_rawstring_del); // control-rawstring-del + } - parsing_should_fail(FILE_LINE_ARGS, control_rawstring_lf); // control-rawstring-lf + SECTION("control-rawstring-lf") + { + parsing_should_fail(FILE_LINE_ARGS, control_rawstring_lf); // control-rawstring-lf + } - parsing_should_fail(FILE_LINE_ARGS, control_rawstring_null); // control-rawstring-null + SECTION("control-rawstring-null") + { + parsing_should_fail(FILE_LINE_ARGS, control_rawstring_null); // control-rawstring-null + } - parsing_should_fail(FILE_LINE_ARGS, control_rawstring_us); // control-rawstring-us + SECTION("control-rawstring-us") + { + parsing_should_fail(FILE_LINE_ARGS, control_rawstring_us); // control-rawstring-us + } - parsing_should_fail(FILE_LINE_ARGS, control_string_bs); // control-string-bs + SECTION("control-string-bs") + { + parsing_should_fail(FILE_LINE_ARGS, control_string_bs); // control-string-bs + } - parsing_should_fail(FILE_LINE_ARGS, control_string_del); // control-string-del + SECTION("control-string-del") + { + parsing_should_fail(FILE_LINE_ARGS, control_string_del); // control-string-del + } - parsing_should_fail(FILE_LINE_ARGS, control_string_lf); // control-string-lf + SECTION("control-string-lf") + { + parsing_should_fail(FILE_LINE_ARGS, control_string_lf); // control-string-lf + } - parsing_should_fail(FILE_LINE_ARGS, control_string_null); // control-string-null + SECTION("control-string-null") + { + parsing_should_fail(FILE_LINE_ARGS, control_string_null); // control-string-null + } - parsing_should_fail(FILE_LINE_ARGS, control_string_us); // control-string-us + SECTION("control-string-us") + { + parsing_should_fail(FILE_LINE_ARGS, control_string_us); // control-string-us + } - parsing_should_fail(FILE_LINE_ARGS, datetime_hour_over); // datetime-hour-over + SECTION("datetime-hour-over") + { + parsing_should_fail(FILE_LINE_ARGS, datetime_hour_over); // datetime-hour-over + } - parsing_should_fail(FILE_LINE_ARGS, datetime_mday_over); // datetime-mday-over + SECTION("datetime-mday-over") + { + parsing_should_fail(FILE_LINE_ARGS, datetime_mday_over); // datetime-mday-over + } - parsing_should_fail(FILE_LINE_ARGS, datetime_mday_under); // datetime-mday-under + SECTION("datetime-mday-under") + { + parsing_should_fail(FILE_LINE_ARGS, datetime_mday_under); // datetime-mday-under + } - parsing_should_fail(FILE_LINE_ARGS, datetime_minute_over); // datetime-minute-over + SECTION("datetime-minute-over") + { + parsing_should_fail(FILE_LINE_ARGS, datetime_minute_over); // datetime-minute-over + } - parsing_should_fail(FILE_LINE_ARGS, datetime_month_over); // datetime-month-over + SECTION("datetime-month-over") + { + parsing_should_fail(FILE_LINE_ARGS, datetime_month_over); // datetime-month-over + } - parsing_should_fail(FILE_LINE_ARGS, datetime_month_under); // datetime-month-under + SECTION("datetime-month-under") + { + parsing_should_fail(FILE_LINE_ARGS, datetime_month_under); // datetime-month-under + } - parsing_should_fail(FILE_LINE_ARGS, datetime_no_leads_with_milli); // datetime-no-leads-with-milli + SECTION("datetime-no-leads-with-milli") + { + parsing_should_fail(FILE_LINE_ARGS, datetime_no_leads_with_milli); // datetime-no-leads-with-milli + } - parsing_should_fail(FILE_LINE_ARGS, datetime_no_leads); // datetime-no-leads + SECTION("datetime-no-leads") + { + parsing_should_fail(FILE_LINE_ARGS, datetime_no_leads); // datetime-no-leads + } - parsing_should_fail(FILE_LINE_ARGS, datetime_no_t); // datetime-no-t + SECTION("datetime-no-t") + { + parsing_should_fail(FILE_LINE_ARGS, datetime_no_t); // datetime-no-t + } - parsing_should_fail(FILE_LINE_ARGS, datetime_second_over); // datetime-second-over + SECTION("datetime-second-over") + { + parsing_should_fail(FILE_LINE_ARGS, datetime_second_over); // datetime-second-over + } - parsing_should_fail(FILE_LINE_ARGS, datetime_time_no_leads_2); // datetime-time-no-leads-2 + SECTION("datetime-time-no-leads-2") + { + parsing_should_fail(FILE_LINE_ARGS, datetime_time_no_leads_2); // datetime-time-no-leads-2 + } - parsing_should_fail(FILE_LINE_ARGS, datetime_time_no_leads); // datetime-time-no-leads + SECTION("datetime-time-no-leads") + { + parsing_should_fail(FILE_LINE_ARGS, datetime_time_no_leads); // datetime-time-no-leads + } - parsing_should_fail(FILE_LINE_ARGS, datetime_trailing_t); // datetime-trailing-t + SECTION("datetime-trailing-t") + { + parsing_should_fail(FILE_LINE_ARGS, datetime_trailing_t); // datetime-trailing-t + } #if !TOML_LANG_UNRELEASED - parsing_should_fail(FILE_LINE_ARGS, datetime_no_secs); // datetime-no-secs + SECTION("datetime-no-secs") + { + parsing_should_fail(FILE_LINE_ARGS, datetime_no_secs); // datetime-no-secs + } #endif // !TOML_LANG_UNRELEASED - parsing_should_fail(FILE_LINE_ARGS, encoding_bad_utf8_at_end); // encoding-bad-utf8-at-end + SECTION("encoding-bad-codepoint") + { + parsing_should_fail(FILE_LINE_ARGS, encoding_bad_codepoint); // encoding-bad-codepoint + } - parsing_should_fail(FILE_LINE_ARGS, encoding_bad_utf8_in_comment); // encoding-bad-utf8-in-comment + SECTION("encoding-bad-utf8-at-end") + { + parsing_should_fail(FILE_LINE_ARGS, encoding_bad_utf8_at_end); // encoding-bad-utf8-at-end + } - parsing_should_fail(FILE_LINE_ARGS, encoding_bad_utf8_in_string); // encoding-bad-utf8-in-string + SECTION("encoding-bad-utf8-in-comment") + { + parsing_should_fail(FILE_LINE_ARGS, encoding_bad_utf8_in_comment); // encoding-bad-utf8-in-comment + } - parsing_should_fail(FILE_LINE_ARGS, encoding_bom_not_at_start_1); // encoding-bom-not-at-start-1 + SECTION("encoding-bad-utf8-in-multiline-literal") + { + parsing_should_fail(FILE_LINE_ARGS, + encoding_bad_utf8_in_multiline_literal); // encoding-bad-utf8-in-multiline-literal + } - parsing_should_fail(FILE_LINE_ARGS, encoding_bom_not_at_start_2); // encoding-bom-not-at-start-2 + SECTION("encoding-bad-utf8-in-multiline") + { + parsing_should_fail(FILE_LINE_ARGS, encoding_bad_utf8_in_multiline); // encoding-bad-utf8-in-multiline + } - parsing_should_fail(FILE_LINE_ARGS, encoding_utf16_bom); // encoding-utf16-bom + SECTION("encoding-bad-utf8-in-string-literal") + { + parsing_should_fail(FILE_LINE_ARGS, encoding_bad_utf8_in_string_literal); // encoding-bad-utf8-in-string-literal + } - parsing_should_fail(FILE_LINE_ARGS, encoding_utf16); // encoding-utf16 + SECTION("encoding-bad-utf8-in-string") + { + parsing_should_fail(FILE_LINE_ARGS, encoding_bad_utf8_in_string); // encoding-bad-utf8-in-string + } - parsing_should_fail(FILE_LINE_ARGS, float_double_point_1); // float-double-point-1 + SECTION("encoding-bom-not-at-start-1") + { + parsing_should_fail(FILE_LINE_ARGS, encoding_bom_not_at_start_1); // encoding-bom-not-at-start-1 + } - parsing_should_fail(FILE_LINE_ARGS, float_double_point_2); // float-double-point-2 + SECTION("encoding-bom-not-at-start-2") + { + parsing_should_fail(FILE_LINE_ARGS, encoding_bom_not_at_start_2); // encoding-bom-not-at-start-2 + } - parsing_should_fail(FILE_LINE_ARGS, float_exp_double_e_1); // float-exp-double-e-1 + SECTION("encoding-utf16-bom") + { + parsing_should_fail(FILE_LINE_ARGS, encoding_utf16_bom); // encoding-utf16-bom + } - parsing_should_fail(FILE_LINE_ARGS, float_exp_double_e_2); // float-exp-double-e-2 + SECTION("encoding-utf16") + { + parsing_should_fail(FILE_LINE_ARGS, encoding_utf16); // encoding-utf16 + } - parsing_should_fail(FILE_LINE_ARGS, float_exp_double_us); // float-exp-double-us + SECTION("float-double-point-1") + { + parsing_should_fail(FILE_LINE_ARGS, float_double_point_1); // float-double-point-1 + } - parsing_should_fail(FILE_LINE_ARGS, float_exp_leading_us); // float-exp-leading-us + SECTION("float-double-point-2") + { + parsing_should_fail(FILE_LINE_ARGS, float_double_point_2); // float-double-point-2 + } - parsing_should_fail(FILE_LINE_ARGS, float_exp_point_1); // float-exp-point-1 + SECTION("float-exp-double-e-1") + { + parsing_should_fail(FILE_LINE_ARGS, float_exp_double_e_1); // float-exp-double-e-1 + } - parsing_should_fail(FILE_LINE_ARGS, float_exp_point_2); // float-exp-point-2 + SECTION("float-exp-double-e-2") + { + parsing_should_fail(FILE_LINE_ARGS, float_exp_double_e_2); // float-exp-double-e-2 + } - parsing_should_fail(FILE_LINE_ARGS, float_exp_trailing_us); // float-exp-trailing-us + SECTION("float-exp-double-us") + { + parsing_should_fail(FILE_LINE_ARGS, float_exp_double_us); // float-exp-double-us + } - parsing_should_fail(FILE_LINE_ARGS, float_inf_incomplete_1); // float-inf-incomplete-1 + SECTION("float-exp-leading-us") + { + parsing_should_fail(FILE_LINE_ARGS, float_exp_leading_us); // float-exp-leading-us + } - parsing_should_fail(FILE_LINE_ARGS, float_inf_incomplete_2); // float-inf-incomplete-2 + SECTION("float-exp-point-1") + { + parsing_should_fail(FILE_LINE_ARGS, float_exp_point_1); // float-exp-point-1 + } - parsing_should_fail(FILE_LINE_ARGS, float_inf_incomplete_3); // float-inf-incomplete-3 + SECTION("float-exp-point-2") + { + parsing_should_fail(FILE_LINE_ARGS, float_exp_point_2); // float-exp-point-2 + } - parsing_should_fail(FILE_LINE_ARGS, float_inf_underscore); // float-inf_underscore + SECTION("float-exp-trailing-us") + { + parsing_should_fail(FILE_LINE_ARGS, float_exp_trailing_us); // float-exp-trailing-us + } - parsing_should_fail(FILE_LINE_ARGS, float_leading_point_neg); // float-leading-point-neg + SECTION("float-inf-capital") + { + parsing_should_fail(FILE_LINE_ARGS, float_inf_capital); // float-inf-capital + } - parsing_should_fail(FILE_LINE_ARGS, float_leading_point_plus); // float-leading-point-plus + SECTION("float-inf-incomplete-1") + { + parsing_should_fail(FILE_LINE_ARGS, float_inf_incomplete_1); // float-inf-incomplete-1 + } - parsing_should_fail(FILE_LINE_ARGS, float_leading_point); // float-leading-point + SECTION("float-inf-incomplete-2") + { + parsing_should_fail(FILE_LINE_ARGS, float_inf_incomplete_2); // float-inf-incomplete-2 + } - parsing_should_fail(FILE_LINE_ARGS, float_leading_us); // float-leading-us + SECTION("float-inf-incomplete-3") + { + parsing_should_fail(FILE_LINE_ARGS, float_inf_incomplete_3); // float-inf-incomplete-3 + } - parsing_should_fail(FILE_LINE_ARGS, float_leading_zero_neg); // float-leading-zero-neg + SECTION("float-inf_underscore") + { + parsing_should_fail(FILE_LINE_ARGS, float_inf_underscore); // float-inf_underscore + } - parsing_should_fail(FILE_LINE_ARGS, float_leading_zero_plus); // float-leading-zero-plus + SECTION("float-leading-point-neg") + { + parsing_should_fail(FILE_LINE_ARGS, float_leading_point_neg); // float-leading-point-neg + } - parsing_should_fail(FILE_LINE_ARGS, float_leading_zero); // float-leading-zero + SECTION("float-leading-point-plus") + { + parsing_should_fail(FILE_LINE_ARGS, float_leading_point_plus); // float-leading-point-plus + } - parsing_should_fail(FILE_LINE_ARGS, float_nan_incomplete_1); // float-nan-incomplete-1 + SECTION("float-leading-point") + { + parsing_should_fail(FILE_LINE_ARGS, float_leading_point); // float-leading-point + } - parsing_should_fail(FILE_LINE_ARGS, float_nan_incomplete_2); // float-nan-incomplete-2 + SECTION("float-leading-us") + { + parsing_should_fail(FILE_LINE_ARGS, float_leading_us); // float-leading-us + } - parsing_should_fail(FILE_LINE_ARGS, float_nan_incomplete_3); // float-nan-incomplete-3 + SECTION("float-leading-zero-neg") + { + parsing_should_fail(FILE_LINE_ARGS, float_leading_zero_neg); // float-leading-zero-neg + } - parsing_should_fail(FILE_LINE_ARGS, float_nan_underscore); // float-nan_underscore + SECTION("float-leading-zero-plus") + { + parsing_should_fail(FILE_LINE_ARGS, float_leading_zero_plus); // float-leading-zero-plus + } - parsing_should_fail(FILE_LINE_ARGS, float_trailing_point_min); // float-trailing-point-min + SECTION("float-leading-zero") + { + parsing_should_fail(FILE_LINE_ARGS, float_leading_zero); // float-leading-zero + } - parsing_should_fail(FILE_LINE_ARGS, float_trailing_point_plus); // float-trailing-point-plus + SECTION("float-nan-capital") + { + parsing_should_fail(FILE_LINE_ARGS, float_nan_capital); // float-nan-capital + } - parsing_should_fail(FILE_LINE_ARGS, float_trailing_point); // float-trailing-point + SECTION("float-nan-incomplete-1") + { + parsing_should_fail(FILE_LINE_ARGS, float_nan_incomplete_1); // float-nan-incomplete-1 + } - parsing_should_fail(FILE_LINE_ARGS, float_trailing_us_exp); // float-trailing-us-exp + SECTION("float-nan-incomplete-2") + { + parsing_should_fail(FILE_LINE_ARGS, float_nan_incomplete_2); // float-nan-incomplete-2 + } - parsing_should_fail(FILE_LINE_ARGS, float_trailing_us); // float-trailing-us + SECTION("float-nan-incomplete-3") + { + parsing_should_fail(FILE_LINE_ARGS, float_nan_incomplete_3); // float-nan-incomplete-3 + } - parsing_should_fail(FILE_LINE_ARGS, float_us_after_point); // float-us-after-point + SECTION("float-nan_underscore") + { + parsing_should_fail(FILE_LINE_ARGS, float_nan_underscore); // float-nan_underscore + } - parsing_should_fail(FILE_LINE_ARGS, float_us_before_point); // float-us-before-point + SECTION("float-trailing-point-min") + { + parsing_should_fail(FILE_LINE_ARGS, float_trailing_point_min); // float-trailing-point-min + } - parsing_should_fail(FILE_LINE_ARGS, inline_table_add); // inline-table-add + SECTION("float-trailing-point-plus") + { + parsing_should_fail(FILE_LINE_ARGS, float_trailing_point_plus); // float-trailing-point-plus + } - parsing_should_fail(FILE_LINE_ARGS, inline_table_double_comma); // inline-table-double-comma + SECTION("float-trailing-point") + { + parsing_should_fail(FILE_LINE_ARGS, float_trailing_point); // float-trailing-point + } - parsing_should_fail(FILE_LINE_ARGS, inline_table_duplicate_key); // inline-table-duplicate-key + SECTION("float-trailing-us-exp") + { + parsing_should_fail(FILE_LINE_ARGS, float_trailing_us_exp); // float-trailing-us-exp + } - parsing_should_fail(FILE_LINE_ARGS, inline_table_empty); // inline-table-empty + SECTION("float-trailing-us") + { + parsing_should_fail(FILE_LINE_ARGS, float_trailing_us); // float-trailing-us + } - parsing_should_fail(FILE_LINE_ARGS, inline_table_no_comma); // inline-table-no-comma + SECTION("float-us-after-point") + { + parsing_should_fail(FILE_LINE_ARGS, float_us_after_point); // float-us-after-point + } - parsing_should_fail(FILE_LINE_ARGS, inline_table_overwrite); // inline-table-overwrite + SECTION("float-us-before-point") + { + parsing_should_fail(FILE_LINE_ARGS, float_us_before_point); // float-us-before-point + } + + SECTION("inline-table-add") + { + parsing_should_fail(FILE_LINE_ARGS, inline_table_add); // inline-table-add + } + + SECTION("inline-table-bad-key-syntax") + { + parsing_should_fail(FILE_LINE_ARGS, inline_table_bad_key_syntax); // inline-table-bad-key-syntax + } + + SECTION("inline-table-dotted-key-conflict") + { + parsing_should_fail(FILE_LINE_ARGS, inline_table_dotted_key_conflict); // inline-table-dotted-key-conflict + } + + SECTION("inline-table-double-comma") + { + parsing_should_fail(FILE_LINE_ARGS, inline_table_double_comma); // inline-table-double-comma + } + + SECTION("inline-table-duplicate-key") + { + parsing_should_fail(FILE_LINE_ARGS, inline_table_duplicate_key); // inline-table-duplicate-key + } + + SECTION("inline-table-empty") + { + parsing_should_fail(FILE_LINE_ARGS, inline_table_empty); // inline-table-empty + } + + SECTION("inline-table-nested_key_conflict") + { + parsing_should_fail(FILE_LINE_ARGS, inline_table_nested_key_conflict); // inline-table-nested_key_conflict + } + + SECTION("inline-table-no-comma") + { + parsing_should_fail(FILE_LINE_ARGS, inline_table_no_comma); // inline-table-no-comma + } + + SECTION("inline-table-overwrite") + { + parsing_should_fail(FILE_LINE_ARGS, inline_table_overwrite); // inline-table-overwrite + } #if !TOML_LANG_UNRELEASED - parsing_should_fail(FILE_LINE_ARGS, inline_table_linebreak_1); // inline-table-linebreak-1 + SECTION("inline-table-linebreak-1") + { + parsing_should_fail(FILE_LINE_ARGS, inline_table_linebreak_1); // inline-table-linebreak-1 + } - parsing_should_fail(FILE_LINE_ARGS, inline_table_linebreak_2); // inline-table-linebreak-2 + SECTION("inline-table-linebreak-2") + { + parsing_should_fail(FILE_LINE_ARGS, inline_table_linebreak_2); // inline-table-linebreak-2 + } - parsing_should_fail(FILE_LINE_ARGS, inline_table_linebreak_3); // inline-table-linebreak-3 + SECTION("inline-table-linebreak-3") + { + parsing_should_fail(FILE_LINE_ARGS, inline_table_linebreak_3); // inline-table-linebreak-3 + } - parsing_should_fail(FILE_LINE_ARGS, inline_table_linebreak_4); // inline-table-linebreak-4 + SECTION("inline-table-linebreak-4") + { + parsing_should_fail(FILE_LINE_ARGS, inline_table_linebreak_4); // inline-table-linebreak-4 + } - parsing_should_fail(FILE_LINE_ARGS, inline_table_trailing_comma); // inline-table-trailing-comma + SECTION("inline-table-trailing-comma") + { + parsing_should_fail(FILE_LINE_ARGS, inline_table_trailing_comma); // inline-table-trailing-comma + } #endif // !TOML_LANG_UNRELEASED - parsing_should_fail(FILE_LINE_ARGS, integer_capital_bin); // integer-capital-bin + SECTION("integer-capital-bin") + { + parsing_should_fail(FILE_LINE_ARGS, integer_capital_bin); // integer-capital-bin + } - parsing_should_fail(FILE_LINE_ARGS, integer_capital_hex); // integer-capital-hex + SECTION("integer-capital-hex") + { + parsing_should_fail(FILE_LINE_ARGS, integer_capital_hex); // integer-capital-hex + } - parsing_should_fail(FILE_LINE_ARGS, integer_capital_oct); // integer-capital-oct + SECTION("integer-capital-oct") + { + parsing_should_fail(FILE_LINE_ARGS, integer_capital_oct); // integer-capital-oct + } - parsing_should_fail(FILE_LINE_ARGS, integer_double_sign_nex); // integer-double-sign-nex + SECTION("integer-double-sign-nex") + { + parsing_should_fail(FILE_LINE_ARGS, integer_double_sign_nex); // integer-double-sign-nex + } - parsing_should_fail(FILE_LINE_ARGS, integer_double_sign_plus); // integer-double-sign-plus + SECTION("integer-double-sign-plus") + { + parsing_should_fail(FILE_LINE_ARGS, integer_double_sign_plus); // integer-double-sign-plus + } - parsing_should_fail(FILE_LINE_ARGS, integer_double_us); // integer-double-us + SECTION("integer-double-us") + { + parsing_should_fail(FILE_LINE_ARGS, integer_double_us); // integer-double-us + } - parsing_should_fail(FILE_LINE_ARGS, integer_incomplete_bin); // integer-incomplete-bin + SECTION("integer-incomplete-bin") + { + parsing_should_fail(FILE_LINE_ARGS, integer_incomplete_bin); // integer-incomplete-bin + } - parsing_should_fail(FILE_LINE_ARGS, integer_incomplete_hex); // integer-incomplete-hex + SECTION("integer-incomplete-hex") + { + parsing_should_fail(FILE_LINE_ARGS, integer_incomplete_hex); // integer-incomplete-hex + } - parsing_should_fail(FILE_LINE_ARGS, integer_incomplete_oct); // integer-incomplete-oct + SECTION("integer-incomplete-oct") + { + parsing_should_fail(FILE_LINE_ARGS, integer_incomplete_oct); // integer-incomplete-oct + } - parsing_should_fail(FILE_LINE_ARGS, integer_invalid_bin); // integer-invalid-bin + SECTION("integer-invalid-bin") + { + parsing_should_fail(FILE_LINE_ARGS, integer_invalid_bin); // integer-invalid-bin + } - parsing_should_fail(FILE_LINE_ARGS, integer_invalid_hex); // integer-invalid-hex + SECTION("integer-invalid-hex") + { + parsing_should_fail(FILE_LINE_ARGS, integer_invalid_hex); // integer-invalid-hex + } - parsing_should_fail(FILE_LINE_ARGS, integer_invalid_oct); // integer-invalid-oct + SECTION("integer-invalid-oct") + { + parsing_should_fail(FILE_LINE_ARGS, integer_invalid_oct); // integer-invalid-oct + } - parsing_should_fail(FILE_LINE_ARGS, integer_leading_us_bin); // integer-leading-us-bin + SECTION("integer-leading-us-bin") + { + parsing_should_fail(FILE_LINE_ARGS, integer_leading_us_bin); // integer-leading-us-bin + } - parsing_should_fail(FILE_LINE_ARGS, integer_leading_us_hex); // integer-leading-us-hex + SECTION("integer-leading-us-hex") + { + parsing_should_fail(FILE_LINE_ARGS, integer_leading_us_hex); // integer-leading-us-hex + } - parsing_should_fail(FILE_LINE_ARGS, integer_leading_us_oct); // integer-leading-us-oct + SECTION("integer-leading-us-oct") + { + parsing_should_fail(FILE_LINE_ARGS, integer_leading_us_oct); // integer-leading-us-oct + } - parsing_should_fail(FILE_LINE_ARGS, integer_leading_us); // integer-leading-us + SECTION("integer-leading-us") + { + parsing_should_fail(FILE_LINE_ARGS, integer_leading_us); // integer-leading-us + } - parsing_should_fail(FILE_LINE_ARGS, integer_leading_zero_1); // integer-leading-zero-1 + SECTION("integer-leading-zero-1") + { + parsing_should_fail(FILE_LINE_ARGS, integer_leading_zero_1); // integer-leading-zero-1 + } - parsing_should_fail(FILE_LINE_ARGS, integer_leading_zero_2); // integer-leading-zero-2 + SECTION("integer-leading-zero-2") + { + parsing_should_fail(FILE_LINE_ARGS, integer_leading_zero_2); // integer-leading-zero-2 + } - parsing_should_fail(FILE_LINE_ARGS, integer_leading_zero_3); // integer-leading-zero-3 + SECTION("integer-leading-zero-3") + { + parsing_should_fail(FILE_LINE_ARGS, integer_leading_zero_3); // integer-leading-zero-3 + } - parsing_should_fail(FILE_LINE_ARGS, integer_leading_zero_sign_1); // integer-leading-zero-sign-1 + SECTION("integer-leading-zero-sign-1") + { + parsing_should_fail(FILE_LINE_ARGS, integer_leading_zero_sign_1); // integer-leading-zero-sign-1 + } - parsing_should_fail(FILE_LINE_ARGS, integer_leading_zero_sign_2); // integer-leading-zero-sign-2 + SECTION("integer-leading-zero-sign-2") + { + parsing_should_fail(FILE_LINE_ARGS, integer_leading_zero_sign_2); // integer-leading-zero-sign-2 + } - parsing_should_fail(FILE_LINE_ARGS, integer_leading_zero_sign_3); // integer-leading-zero-sign-3 + SECTION("integer-leading-zero-sign-3") + { + parsing_should_fail(FILE_LINE_ARGS, integer_leading_zero_sign_3); // integer-leading-zero-sign-3 + } - parsing_should_fail(FILE_LINE_ARGS, integer_negative_bin); // integer-negative-bin + SECTION("integer-negative-bin") + { + parsing_should_fail(FILE_LINE_ARGS, integer_negative_bin); // integer-negative-bin + } - parsing_should_fail(FILE_LINE_ARGS, integer_negative_hex); // integer-negative-hex + SECTION("integer-negative-hex") + { + parsing_should_fail(FILE_LINE_ARGS, integer_negative_hex); // integer-negative-hex + } - parsing_should_fail(FILE_LINE_ARGS, integer_negative_oct); // integer-negative-oct + SECTION("integer-negative-oct") + { + parsing_should_fail(FILE_LINE_ARGS, integer_negative_oct); // integer-negative-oct + } - parsing_should_fail(FILE_LINE_ARGS, integer_positive_bin); // integer-positive-bin + SECTION("integer-positive-bin") + { + parsing_should_fail(FILE_LINE_ARGS, integer_positive_bin); // integer-positive-bin + } - parsing_should_fail(FILE_LINE_ARGS, integer_positive_hex); // integer-positive-hex + SECTION("integer-positive-hex") + { + parsing_should_fail(FILE_LINE_ARGS, integer_positive_hex); // integer-positive-hex + } - parsing_should_fail(FILE_LINE_ARGS, integer_positive_oct); // integer-positive-oct + SECTION("integer-positive-oct") + { + parsing_should_fail(FILE_LINE_ARGS, integer_positive_oct); // integer-positive-oct + } - parsing_should_fail(FILE_LINE_ARGS, integer_text_after_integer); // integer-text-after-integer + SECTION("integer-text-after-integer") + { + parsing_should_fail(FILE_LINE_ARGS, integer_text_after_integer); // integer-text-after-integer + } - parsing_should_fail(FILE_LINE_ARGS, integer_trailing_us_bin); // integer-trailing-us-bin + SECTION("integer-trailing-us-bin") + { + parsing_should_fail(FILE_LINE_ARGS, integer_trailing_us_bin); // integer-trailing-us-bin + } - parsing_should_fail(FILE_LINE_ARGS, integer_trailing_us_hex); // integer-trailing-us-hex + SECTION("integer-trailing-us-hex") + { + parsing_should_fail(FILE_LINE_ARGS, integer_trailing_us_hex); // integer-trailing-us-hex + } - parsing_should_fail(FILE_LINE_ARGS, integer_trailing_us_oct); // integer-trailing-us-oct + SECTION("integer-trailing-us-oct") + { + parsing_should_fail(FILE_LINE_ARGS, integer_trailing_us_oct); // integer-trailing-us-oct + } - parsing_should_fail(FILE_LINE_ARGS, integer_trailing_us); // integer-trailing-us + SECTION("integer-trailing-us") + { + parsing_should_fail(FILE_LINE_ARGS, integer_trailing_us); // integer-trailing-us + } - parsing_should_fail(FILE_LINE_ARGS, integer_us_after_bin); // integer-us-after-bin + SECTION("integer-us-after-bin") + { + parsing_should_fail(FILE_LINE_ARGS, integer_us_after_bin); // integer-us-after-bin + } - parsing_should_fail(FILE_LINE_ARGS, integer_us_after_hex); // integer-us-after-hex + SECTION("integer-us-after-hex") + { + parsing_should_fail(FILE_LINE_ARGS, integer_us_after_hex); // integer-us-after-hex + } - parsing_should_fail(FILE_LINE_ARGS, integer_us_after_oct); // integer-us-after-oct + SECTION("integer-us-after-oct") + { + parsing_should_fail(FILE_LINE_ARGS, integer_us_after_oct); // integer-us-after-oct + } - parsing_should_fail(FILE_LINE_ARGS, key_after_array); // key-after-array + SECTION("key-after-array") + { + parsing_should_fail(FILE_LINE_ARGS, key_after_array); // key-after-array + } - parsing_should_fail(FILE_LINE_ARGS, key_after_table); // key-after-table + SECTION("key-after-table") + { + parsing_should_fail(FILE_LINE_ARGS, key_after_table); // key-after-table + } - parsing_should_fail(FILE_LINE_ARGS, key_after_value); // key-after-value + SECTION("key-after-value") + { + parsing_should_fail(FILE_LINE_ARGS, key_after_value); // key-after-value + } - parsing_should_fail(FILE_LINE_ARGS, key_bare_invalid_character); // key-bare-invalid-character + SECTION("key-bare-invalid-character") + { + parsing_should_fail(FILE_LINE_ARGS, key_bare_invalid_character); // key-bare-invalid-character + } - parsing_should_fail(FILE_LINE_ARGS, key_dotted_redefine_table); // key-dotted-redefine-table + SECTION("key-dotted-redefine-table") + { + parsing_should_fail(FILE_LINE_ARGS, key_dotted_redefine_table); // key-dotted-redefine-table + } - parsing_should_fail(FILE_LINE_ARGS, key_duplicate_keys); // key-duplicate-keys + SECTION("key-duplicate-keys") + { + parsing_should_fail(FILE_LINE_ARGS, key_duplicate_keys); // key-duplicate-keys + } - parsing_should_fail(FILE_LINE_ARGS, key_duplicate); // key-duplicate + SECTION("key-duplicate") + { + parsing_should_fail(FILE_LINE_ARGS, key_duplicate); // key-duplicate + } - parsing_should_fail(FILE_LINE_ARGS, key_empty); // key-empty + SECTION("key-empty") + { + parsing_should_fail(FILE_LINE_ARGS, key_empty); // key-empty + } - parsing_should_fail(FILE_LINE_ARGS, key_escape); // key-escape + SECTION("key-escape") + { + parsing_should_fail(FILE_LINE_ARGS, key_escape); // key-escape + } - parsing_should_fail(FILE_LINE_ARGS, key_hash); // key-hash + SECTION("key-hash") + { + parsing_should_fail(FILE_LINE_ARGS, key_hash); // key-hash + } - parsing_should_fail(FILE_LINE_ARGS, key_multiline); // key-multiline + SECTION("key-multiline") + { + parsing_should_fail(FILE_LINE_ARGS, key_multiline); // key-multiline + } - parsing_should_fail(FILE_LINE_ARGS, key_newline); // key-newline + SECTION("key-newline") + { + parsing_should_fail(FILE_LINE_ARGS, key_newline); // key-newline + } - parsing_should_fail(FILE_LINE_ARGS, key_no_eol); // key-no-eol + SECTION("key-no-eol") + { + parsing_should_fail(FILE_LINE_ARGS, key_no_eol); // key-no-eol + } - parsing_should_fail(FILE_LINE_ARGS, key_open_bracket); // key-open-bracket + SECTION("key-open-bracket") + { + parsing_should_fail(FILE_LINE_ARGS, key_open_bracket); // key-open-bracket + } - parsing_should_fail(FILE_LINE_ARGS, key_partial_quoted); // key-partial-quoted + SECTION("key-partial-quoted") + { + parsing_should_fail(FILE_LINE_ARGS, key_partial_quoted); // key-partial-quoted + } - parsing_should_fail(FILE_LINE_ARGS, key_quoted_unclosed_1); // key-quoted-unclosed-1 + SECTION("key-quoted-unclosed-1") + { + parsing_should_fail(FILE_LINE_ARGS, key_quoted_unclosed_1); // key-quoted-unclosed-1 + } - parsing_should_fail(FILE_LINE_ARGS, key_quoted_unclosed_2); // key-quoted-unclosed-2 + SECTION("key-quoted-unclosed-2") + { + parsing_should_fail(FILE_LINE_ARGS, key_quoted_unclosed_2); // key-quoted-unclosed-2 + } - parsing_should_fail(FILE_LINE_ARGS, key_single_open_bracket); // key-single-open-bracket + SECTION("key-single-open-bracket") + { + parsing_should_fail(FILE_LINE_ARGS, key_single_open_bracket); // key-single-open-bracket + } - parsing_should_fail(FILE_LINE_ARGS, key_space); // key-space + SECTION("key-space") + { + parsing_should_fail(FILE_LINE_ARGS, key_space); // key-space + } - parsing_should_fail(FILE_LINE_ARGS, key_start_bracket); // key-start-bracket + SECTION("key-start-bracket") + { + parsing_should_fail(FILE_LINE_ARGS, key_start_bracket); // key-start-bracket + } - parsing_should_fail(FILE_LINE_ARGS, key_start_dot); // key-start-dot + SECTION("key-start-dot") + { + parsing_should_fail(FILE_LINE_ARGS, key_start_dot); // key-start-dot + } - parsing_should_fail(FILE_LINE_ARGS, key_two_equals); // key-two-equals + SECTION("key-two-equals") + { + parsing_should_fail(FILE_LINE_ARGS, key_two_equals); // key-two-equals + } - parsing_should_fail(FILE_LINE_ARGS, key_two_equals2); // key-two-equals2 + SECTION("key-two-equals2") + { + parsing_should_fail(FILE_LINE_ARGS, key_two_equals2); // key-two-equals2 + } - parsing_should_fail(FILE_LINE_ARGS, key_two_equals3); // key-two-equals3 + SECTION("key-two-equals3") + { + parsing_should_fail(FILE_LINE_ARGS, key_two_equals3); // key-two-equals3 + } - parsing_should_fail(FILE_LINE_ARGS, key_without_value_1); // key-without-value-1 + SECTION("key-without-value-1") + { + parsing_should_fail(FILE_LINE_ARGS, key_without_value_1); // key-without-value-1 + } - parsing_should_fail(FILE_LINE_ARGS, key_without_value_2); // key-without-value-2 + SECTION("key-without-value-2") + { + parsing_should_fail(FILE_LINE_ARGS, key_without_value_2); // key-without-value-2 + } - parsing_should_fail(FILE_LINE_ARGS, key_without_value_3); // key-without-value-3 + SECTION("key-without-value-3") + { + parsing_should_fail(FILE_LINE_ARGS, key_without_value_3); // key-without-value-3 + } - parsing_should_fail(FILE_LINE_ARGS, key_without_value_4); // key-without-value-4 + SECTION("key-without-value-4") + { + parsing_should_fail(FILE_LINE_ARGS, key_without_value_4); // key-without-value-4 + } #if !TOML_LANG_UNRELEASED && UNICODE_LITERALS_OK - parsing_should_fail(FILE_LINE_ARGS, key_special_character); // key-special-character + SECTION("key-special-character") + { + parsing_should_fail(FILE_LINE_ARGS, key_special_character); // key-special-character + } #endif // !TOML_LANG_UNRELEASED && UNICODE_LITERALS_OK - parsing_should_fail(FILE_LINE_ARGS, string_bad_byte_escape); // string-bad-byte-escape + SECTION("spec-inline-table-2-0") + { + parsing_should_fail(FILE_LINE_ARGS, spec_inline_table_2_0); // spec-inline-table-2-0 + } - parsing_should_fail(FILE_LINE_ARGS, string_bad_codepoint); // string-bad-codepoint + SECTION("spec-inline-table-3-0") + { + parsing_should_fail(FILE_LINE_ARGS, spec_inline_table_3_0); // spec-inline-table-3-0 + } - parsing_should_fail(FILE_LINE_ARGS, string_bad_concat); // string-bad-concat + SECTION("spec-key-value-pair-1") + { + parsing_should_fail(FILE_LINE_ARGS, spec_key_value_pair_1); // spec-key-value-pair-1 + } - parsing_should_fail(FILE_LINE_ARGS, string_bad_escape_1); // string-bad-escape-1 + SECTION("spec-keys-2") + { + parsing_should_fail(FILE_LINE_ARGS, spec_keys_2); // spec-keys-2 + } - parsing_should_fail(FILE_LINE_ARGS, string_bad_escape_2); // string-bad-escape-2 + SECTION("spec-string-4-0") + { + parsing_should_fail(FILE_LINE_ARGS, spec_string_4_0); // spec-string-4-0 + } - parsing_should_fail(FILE_LINE_ARGS, string_bad_multiline); // string-bad-multiline + SECTION("spec-string-7-0") + { + parsing_should_fail(FILE_LINE_ARGS, spec_string_7_0); // spec-string-7-0 + } - parsing_should_fail(FILE_LINE_ARGS, string_bad_slash_escape); // string-bad-slash-escape + SECTION("spec-table-9-0") + { + parsing_should_fail(FILE_LINE_ARGS, spec_table_9_0); // spec-table-9-0 + } - parsing_should_fail(FILE_LINE_ARGS, string_bad_uni_esc_1); // string-bad-uni-esc-1 + SECTION("spec-table-9-1") + { + parsing_should_fail(FILE_LINE_ARGS, spec_table_9_1); // spec-table-9-1 + } - parsing_should_fail(FILE_LINE_ARGS, string_bad_uni_esc_2); // string-bad-uni-esc-2 + SECTION("string-bad-byte-escape") + { + parsing_should_fail(FILE_LINE_ARGS, string_bad_byte_escape); // string-bad-byte-escape + } - parsing_should_fail(FILE_LINE_ARGS, string_bad_uni_esc_3); // string-bad-uni-esc-3 + SECTION("string-bad-codepoint") + { + parsing_should_fail(FILE_LINE_ARGS, string_bad_codepoint); // string-bad-codepoint + } - parsing_should_fail(FILE_LINE_ARGS, string_bad_uni_esc_4); // string-bad-uni-esc-4 + SECTION("string-bad-concat") + { + parsing_should_fail(FILE_LINE_ARGS, string_bad_concat); // string-bad-concat + } - parsing_should_fail(FILE_LINE_ARGS, string_bad_uni_esc_5); // string-bad-uni-esc-5 + SECTION("string-bad-escape-1") + { + parsing_should_fail(FILE_LINE_ARGS, string_bad_escape_1); // string-bad-escape-1 + } - parsing_should_fail( - FILE_LINE_ARGS, - string_basic_multiline_out_of_range_unicode_escape_1); // string-basic-multiline-out-of-range-unicode-escape-1 + SECTION("string-bad-escape-2") + { + parsing_should_fail(FILE_LINE_ARGS, string_bad_escape_2); // string-bad-escape-2 + } - parsing_should_fail( - FILE_LINE_ARGS, - string_basic_multiline_out_of_range_unicode_escape_2); // string-basic-multiline-out-of-range-unicode-escape-2 + SECTION("string-bad-hex-esc-1") + { + parsing_should_fail(FILE_LINE_ARGS, string_bad_hex_esc_1); // string-bad-hex-esc-1 + } - parsing_should_fail(FILE_LINE_ARGS, string_basic_multiline_quotes); // string-basic-multiline-quotes + SECTION("string-bad-hex-esc-2") + { + parsing_should_fail(FILE_LINE_ARGS, string_bad_hex_esc_2); // string-bad-hex-esc-2 + } - parsing_should_fail(FILE_LINE_ARGS, string_basic_multiline_unknown_escape); // string-basic-multiline-unknown-escape + SECTION("string-bad-hex-esc-3") + { + parsing_should_fail(FILE_LINE_ARGS, string_bad_hex_esc_3); // string-bad-hex-esc-3 + } - parsing_should_fail(FILE_LINE_ARGS, - string_basic_out_of_range_unicode_escape_1); // string-basic-out-of-range-unicode-escape-1 + SECTION("string-bad-hex-esc-4") + { + parsing_should_fail(FILE_LINE_ARGS, string_bad_hex_esc_4); // string-bad-hex-esc-4 + } - parsing_should_fail(FILE_LINE_ARGS, - string_basic_out_of_range_unicode_escape_2); // string-basic-out-of-range-unicode-escape-2 + SECTION("string-bad-hex-esc-5") + { + parsing_should_fail(FILE_LINE_ARGS, string_bad_hex_esc_5); // string-bad-hex-esc-5 + } - parsing_should_fail(FILE_LINE_ARGS, string_basic_unknown_escape); // string-basic-unknown-escape + SECTION("string-bad-multiline") + { + parsing_should_fail(FILE_LINE_ARGS, string_bad_multiline); // string-bad-multiline + } - parsing_should_fail(FILE_LINE_ARGS, string_literal_multiline_quotes_1); // string-literal-multiline-quotes-1 + SECTION("string-bad-slash-escape") + { + parsing_should_fail(FILE_LINE_ARGS, string_bad_slash_escape); // string-bad-slash-escape + } - parsing_should_fail(FILE_LINE_ARGS, string_literal_multiline_quotes_2); // string-literal-multiline-quotes-2 + SECTION("string-bad-uni-esc-1") + { + parsing_should_fail(FILE_LINE_ARGS, string_bad_uni_esc_1); // string-bad-uni-esc-1 + } - parsing_should_fail(FILE_LINE_ARGS, string_missing_quotes); // string-missing-quotes + SECTION("string-bad-uni-esc-2") + { + parsing_should_fail(FILE_LINE_ARGS, string_bad_uni_esc_2); // string-bad-uni-esc-2 + } - parsing_should_fail(FILE_LINE_ARGS, string_multiline_bad_escape_1); // string-multiline-bad-escape-1 + SECTION("string-bad-uni-esc-3") + { + parsing_should_fail(FILE_LINE_ARGS, string_bad_uni_esc_3); // string-bad-uni-esc-3 + } - parsing_should_fail(FILE_LINE_ARGS, string_multiline_bad_escape_2); // string-multiline-bad-escape-2 + SECTION("string-bad-uni-esc-4") + { + parsing_should_fail(FILE_LINE_ARGS, string_bad_uni_esc_4); // string-bad-uni-esc-4 + } - parsing_should_fail(FILE_LINE_ARGS, string_multiline_bad_escape_3); // string-multiline-bad-escape-3 + SECTION("string-bad-uni-esc-5") + { + parsing_should_fail(FILE_LINE_ARGS, string_bad_uni_esc_5); // string-bad-uni-esc-5 + } - parsing_should_fail(FILE_LINE_ARGS, string_multiline_escape_space); // string-multiline-escape-space + SECTION("string-basic-multiline-out-of-range-unicode-escape-1") + { + parsing_should_fail( + FILE_LINE_ARGS, + string_basic_multiline_out_of_range_unicode_escape_1); // string-basic-multiline-out-of-range-unicode-escape-1 + } - parsing_should_fail(FILE_LINE_ARGS, string_multiline_no_close_2); // string-multiline-no-close-2 + SECTION("string-basic-multiline-out-of-range-unicode-escape-2") + { + parsing_should_fail( + FILE_LINE_ARGS, + string_basic_multiline_out_of_range_unicode_escape_2); // string-basic-multiline-out-of-range-unicode-escape-2 + } - parsing_should_fail(FILE_LINE_ARGS, string_multiline_no_close); // string-multiline-no-close + SECTION("string-basic-multiline-quotes") + { + parsing_should_fail(FILE_LINE_ARGS, string_basic_multiline_quotes); // string-basic-multiline-quotes + } - parsing_should_fail(FILE_LINE_ARGS, string_multiline_quotes_1); // string-multiline-quotes-1 + SECTION("string-basic-multiline-unknown-escape") + { + parsing_should_fail(FILE_LINE_ARGS, + string_basic_multiline_unknown_escape); // string-basic-multiline-unknown-escape + } - parsing_should_fail(FILE_LINE_ARGS, string_no_close); // string-no-close + SECTION("string-basic-out-of-range-unicode-escape-1") + { + parsing_should_fail(FILE_LINE_ARGS, + string_basic_out_of_range_unicode_escape_1); // string-basic-out-of-range-unicode-escape-1 + } - parsing_should_fail(FILE_LINE_ARGS, string_text_after_string); // string-text-after-string + SECTION("string-basic-out-of-range-unicode-escape-2") + { + parsing_should_fail(FILE_LINE_ARGS, + string_basic_out_of_range_unicode_escape_2); // string-basic-out-of-range-unicode-escape-2 + } - parsing_should_fail(FILE_LINE_ARGS, string_wrong_close); // string-wrong-close + SECTION("string-basic-unknown-escape") + { + parsing_should_fail(FILE_LINE_ARGS, string_basic_unknown_escape); // string-basic-unknown-escape + } + + SECTION("string-literal-multiline-quotes-1") + { + parsing_should_fail(FILE_LINE_ARGS, string_literal_multiline_quotes_1); // string-literal-multiline-quotes-1 + } + + SECTION("string-literal-multiline-quotes-2") + { + parsing_should_fail(FILE_LINE_ARGS, string_literal_multiline_quotes_2); // string-literal-multiline-quotes-2 + } + + SECTION("string-missing-quotes") + { + parsing_should_fail(FILE_LINE_ARGS, string_missing_quotes); // string-missing-quotes + } + + SECTION("string-multiline-bad-escape-1") + { + parsing_should_fail(FILE_LINE_ARGS, string_multiline_bad_escape_1); // string-multiline-bad-escape-1 + } + + SECTION("string-multiline-bad-escape-2") + { + parsing_should_fail(FILE_LINE_ARGS, string_multiline_bad_escape_2); // string-multiline-bad-escape-2 + } + + SECTION("string-multiline-bad-escape-3") + { + parsing_should_fail(FILE_LINE_ARGS, string_multiline_bad_escape_3); // string-multiline-bad-escape-3 + } + + SECTION("string-multiline-escape-space") + { + parsing_should_fail(FILE_LINE_ARGS, string_multiline_escape_space); // string-multiline-escape-space + } + + SECTION("string-multiline-no-close-2") + { + parsing_should_fail(FILE_LINE_ARGS, string_multiline_no_close_2); // string-multiline-no-close-2 + } + + SECTION("string-multiline-no-close") + { + parsing_should_fail(FILE_LINE_ARGS, string_multiline_no_close); // string-multiline-no-close + } + + SECTION("string-multiline-quotes-1") + { + parsing_should_fail(FILE_LINE_ARGS, string_multiline_quotes_1); // string-multiline-quotes-1 + } + + SECTION("string-no-close") + { + parsing_should_fail(FILE_LINE_ARGS, string_no_close); // string-no-close + } + + SECTION("string-text-after-string") + { + parsing_should_fail(FILE_LINE_ARGS, string_text_after_string); // string-text-after-string + } + + SECTION("string-wrong-close") + { + parsing_should_fail(FILE_LINE_ARGS, string_wrong_close); // string-wrong-close + } #if !TOML_LANG_UNRELEASED - parsing_should_fail(FILE_LINE_ARGS, string_basic_byte_escapes); // string-basic-byte-escapes + SECTION("string-basic-byte-escapes") + { + parsing_should_fail(FILE_LINE_ARGS, string_basic_byte_escapes); // string-basic-byte-escapes + } #endif // !TOML_LANG_UNRELEASED - parsing_should_fail(FILE_LINE_ARGS, table_append_with_dotted_keys_1); // table-append-with-dotted-keys-1 + SECTION("table-append-to-array-with-dotted-keys") + { + parsing_should_fail(FILE_LINE_ARGS, + table_append_to_array_with_dotted_keys); // table-append-to-array-with-dotted-keys + } - parsing_should_fail(FILE_LINE_ARGS, table_append_with_dotted_keys_2); // table-append-with-dotted-keys-2 + SECTION("table-append-with-dotted-keys-1") + { + parsing_should_fail(FILE_LINE_ARGS, table_append_with_dotted_keys_1); // table-append-with-dotted-keys-1 + } - parsing_should_fail(FILE_LINE_ARGS, table_array_empty); // table-array-empty + SECTION("table-append-with-dotted-keys-2") + { + parsing_should_fail(FILE_LINE_ARGS, table_append_with_dotted_keys_2); // table-append-with-dotted-keys-2 + } - parsing_should_fail(FILE_LINE_ARGS, table_array_implicit); // table-array-implicit + SECTION("table-array-empty") + { + parsing_should_fail(FILE_LINE_ARGS, table_array_empty); // table-array-empty + } - parsing_should_fail(FILE_LINE_ARGS, table_array_missing_bracket); // table-array-missing-bracket + SECTION("table-array-implicit") + { + parsing_should_fail(FILE_LINE_ARGS, table_array_implicit); // table-array-implicit + } - parsing_should_fail(FILE_LINE_ARGS, table_duplicate_key_dotted_table); // table-duplicate-key-dotted-table + SECTION("table-array-missing-bracket") + { + parsing_should_fail(FILE_LINE_ARGS, table_array_missing_bracket); // table-array-missing-bracket + } - parsing_should_fail(FILE_LINE_ARGS, table_duplicate_key_dotted_table2); // table-duplicate-key-dotted-table2 + SECTION("table-duplicate-key-dotted-array") + { + parsing_should_fail(FILE_LINE_ARGS, table_duplicate_key_dotted_array); // table-duplicate-key-dotted-array + } - parsing_should_fail(FILE_LINE_ARGS, table_duplicate_key_table); // table-duplicate-key-table + SECTION("table-duplicate-key-dotted-table") + { + parsing_should_fail(FILE_LINE_ARGS, table_duplicate_key_dotted_table); // table-duplicate-key-dotted-table + } - parsing_should_fail(FILE_LINE_ARGS, table_duplicate_table_array); // table-duplicate-table-array + SECTION("table-duplicate-key-dotted-table2") + { + parsing_should_fail(FILE_LINE_ARGS, table_duplicate_key_dotted_table2); // table-duplicate-key-dotted-table2 + } - parsing_should_fail(FILE_LINE_ARGS, table_duplicate_table_array2); // table-duplicate-table-array2 + SECTION("table-duplicate-key-table") + { + parsing_should_fail(FILE_LINE_ARGS, table_duplicate_key_table); // table-duplicate-key-table + } - parsing_should_fail(FILE_LINE_ARGS, table_duplicate); // table-duplicate + SECTION("table-duplicate-table-array") + { + parsing_should_fail(FILE_LINE_ARGS, table_duplicate_table_array); // table-duplicate-table-array + } - parsing_should_fail(FILE_LINE_ARGS, table_empty_implicit_table); // table-empty-implicit-table + SECTION("table-duplicate-table-array2") + { + parsing_should_fail(FILE_LINE_ARGS, table_duplicate_table_array2); // table-duplicate-table-array2 + } - parsing_should_fail(FILE_LINE_ARGS, table_empty); // table-empty + SECTION("table-duplicate") + { + parsing_should_fail(FILE_LINE_ARGS, table_duplicate); // table-duplicate + } - parsing_should_fail(FILE_LINE_ARGS, table_equals_sign); // table-equals-sign + SECTION("table-empty-implicit-table") + { + parsing_should_fail(FILE_LINE_ARGS, table_empty_implicit_table); // table-empty-implicit-table + } - parsing_should_fail(FILE_LINE_ARGS, table_llbrace); // table-llbrace + SECTION("table-empty") + { + parsing_should_fail(FILE_LINE_ARGS, table_empty); // table-empty + } - parsing_should_fail(FILE_LINE_ARGS, table_nested_brackets_close); // table-nested-brackets-close + SECTION("table-equals-sign") + { + parsing_should_fail(FILE_LINE_ARGS, table_equals_sign); // table-equals-sign + } - parsing_should_fail(FILE_LINE_ARGS, table_nested_brackets_open); // table-nested-brackets-open + SECTION("table-llbrace") + { + parsing_should_fail(FILE_LINE_ARGS, table_llbrace); // table-llbrace + } - parsing_should_fail(FILE_LINE_ARGS, table_quoted_no_close); // table-quoted-no-close + SECTION("table-nested-brackets-close") + { + parsing_should_fail(FILE_LINE_ARGS, table_nested_brackets_close); // table-nested-brackets-close + } - parsing_should_fail(FILE_LINE_ARGS, table_redefine); // table-redefine + SECTION("table-nested-brackets-open") + { + parsing_should_fail(FILE_LINE_ARGS, table_nested_brackets_open); // table-nested-brackets-open + } - parsing_should_fail(FILE_LINE_ARGS, table_rrbrace); // table-rrbrace + SECTION("table-quoted-no-close") + { + parsing_should_fail(FILE_LINE_ARGS, table_quoted_no_close); // table-quoted-no-close + } - parsing_should_fail(FILE_LINE_ARGS, table_text_after_table); // table-text-after-table + SECTION("table-redefine") + { + parsing_should_fail(FILE_LINE_ARGS, table_redefine); // table-redefine + } - parsing_should_fail(FILE_LINE_ARGS, table_whitespace); // table-whitespace + SECTION("table-rrbrace") + { + parsing_should_fail(FILE_LINE_ARGS, table_rrbrace); // table-rrbrace + } - parsing_should_fail(FILE_LINE_ARGS, table_with_pound); // table-with-pound + SECTION("table-text-after-table") + { + parsing_should_fail(FILE_LINE_ARGS, table_text_after_table); // table-text-after-table + } + + SECTION("table-whitespace") + { + parsing_should_fail(FILE_LINE_ARGS, table_whitespace); // table-whitespace + } + + SECTION("table-with-pound") + { + parsing_should_fail(FILE_LINE_ARGS, table_with_pound); // table-with-pound + } } diff --git a/tests/conformance_burntsushi_valid.cpp b/tests/conformance_burntsushi_valid.cpp index 31ee8b4..b4e16da 100644 --- a/tests/conformance_burntsushi_valid.cpp +++ b/tests/conformance_burntsushi_valid.cpp @@ -125,6 +125,12 @@ arr5 = [[[[#["#"], ] tbl1 = { "#" = '}#'}#}})"sv; +#if UNICODE_LITERALS_OK + + static constexpr auto comment_nonascii = R"(# ~ € ÿ ퟿  ￿ 𐀀 􏿿)"sv; + +#endif // UNICODE_LITERALS_OK + static constexpr auto datetime_datetime = R"(space = 1987-07-05 17:45:00Z lower = 1987-07-05t17:45:00z)"sv; static constexpr auto datetime_local_date = R"(bestdayever = 1987-07-05)"sv; @@ -142,6 +148,16 @@ pdt = 1987-07-05T17:45:56-05:00 nzst = 1987-07-05T17:45:56+12:00 nzdt = 1987-07-05T17:45:56+13:00 # DST)"sv; +#if TOML_LANG_UNRELEASED + + static constexpr auto datetime_no_seconds = R"(# Seconds are optional in date-time and time. +without-seconds-1 = 13:37 +without-seconds-2 = 1979-05-27 07:32Z +without-seconds-3 = 1979-05-27 07:32-07:00 +without-seconds-4 = 1979-05-27T07:32)"sv; + +#endif // TOML_LANG_UNRELEASED + static constexpr auto empty_file = R"()"sv; static constexpr auto example = R"(best-day-ever = 1987-07-05T17:45:00Z @@ -257,6 +273,35 @@ T = {a.b=2})"sv; #endif // !TOML_MSVC +#if TOML_LANG_UNRELEASED + + static constexpr auto inline_table_newline = R"(# TOML 1.1 supports newlines in inline tables and trailing commas. + +trailing-comma-1 = { + c = 1, +} +trailing-comma-2 = { c = 1, } + +tbl-1 = { + hello = "world", + 1 = 2, + arr = [1, + 2, + 3, + ], + tbl = { + k = 1, + } +} + +tbl-2 = { + k = """ + Hello + """ +})"sv; + +#endif // TOML_LANG_UNRELEASED + static constexpr auto integer_integer = R"(answer = 42 posanswer = +42 neganswer = -42 @@ -316,9 +361,20 @@ M = "latin letter M")"sv; quote = true ["a.b"."\u00c0"])"sv; + static constexpr auto key_quoted_unicode = R"( +"\u0000" = "null" +'\u0000' = "different key" +"\u0008 \u000c \U00000041 \u007f \u0080 \u00ff \ud7ff \ue000 \uffff \U00010000 \U0010ffff" = "escaped key" + +"~ € ÿ ퟿  ￿ 𐀀 􏿿" = "basic key" +'l ~ € ÿ ퟿  ￿ 𐀀 􏿿' = "literal key")"sv; #endif // UNICODE_LITERALS_OK + static constexpr auto key_dotted_empty = R"(''.x = "empty.x" +x."" = "x.empty" +[a] +"".'' = "empty.empty")"sv; static constexpr auto key_dotted = R"(# Note: this file contains literal tab characters. name.first = "Arthur" @@ -380,11 +436,288 @@ true = 1 inf = 100000000 nan = "ceci n'est pas un nombre")"sv; +#if TOML_LANG_UNRELEASED && UNICODE_LITERALS_OK + + static constexpr auto key_unicode = R"(# TOML 1.1 supports Unicode for bare keys. + +€ = 'Euro' +😂 = "rofl" +a‍b = "zwj" +ÅÅ = "U+00C5 U+0041 U+030A" + +[中文] +中文 = {中文 = "Chinese language"} + +[[tiếng-Việt]] +tiəŋ˧˦.viət̚˧˨ʔ = "north" + +[[tiếng-Việt]] +tiəŋ˦˧˥.viək̚˨˩ʔ = "central")"sv; + +#endif // TOML_LANG_UNRELEASED && UNICODE_LITERALS_OK + static constexpr auto newline_crlf = "os = \"DOS\"\r\n" "newline = \"crlf\""sv; static constexpr auto newline_lf = R"(os = "unix" newline = "lf")"sv; + static constexpr auto spec_array_0 = R"(integers = [ 1, 2, 3 ] +colors = [ "red", "yellow", "green" ] +nested_arrays_of_ints = [ [ 1, 2 ], [3, 4, 5] ] +nested_mixed_array = [ [ 1, 2 ], ["a", "b", "c"] ] +string_array = [ "all", 'strings', """are the same""", '''type''' ] + +# Mixed-type arrays are allowed +numbers = [ 0.1, 0.2, 0.5, 1, 2, 5 ] +contributors = [ + "Foo Bar ", + { name = "Baz Qux", email = "bazqux@example.com", url = "https://example.com/bazqux" } +])"sv; + static constexpr auto spec_array_1 = R"(integers2 = [ + 1, 2, 3 +] + +integers3 = [ + 1, + 2, # this is ok +])"sv; + static constexpr auto spec_array_of_tables_0 = R"([[products]] +name = "Hammer" +sku = 738594937 + +[[products]] # empty table within the array + +[[products]] +name = "Nail" +sku = 284758393 + +color = "gray")"sv; + static constexpr auto spec_array_of_tables_1 = R"([[fruits]] +name = "apple" + +[fruits.physical] # subtable +color = "red" +shape = "round" + +[[fruits.varieties]] # nested array of tables +name = "red delicious" + +[[fruits.varieties]] +name = "granny smith" + + +[[fruits]] +name = "banana" + +[[fruits.varieties]] +name = "plantain")"sv; + static constexpr auto spec_array_of_tables_2 = R"(points = [ { x = 1, y = 2, z = 3 }, + { x = 7, y = 8, z = 9 }, + { x = 2, y = 4, z = 8 } ])"sv; + static constexpr auto spec_boolean_0 = R"(bool1 = true +bool2 = false)"sv; + static constexpr auto spec_comment_0 = R"(# This is a full-line comment +key = "value" # This is a comment at the end of a line +another = "# This is not a comment")"sv; + static constexpr auto spec_float_0 = R"(# fractional +flt1 = +1.0 +flt2 = 3.1415 +flt3 = -0.01 + +# exponent +flt4 = 5e+22 +flt5 = 1e06 +flt6 = -2E-2 + +# both +flt7 = 6.626e-34)"sv; + static constexpr auto spec_float_1 = R"(flt8 = 224_617.445_991_228)"sv; + static constexpr auto spec_float_2 = R"(# infinity +sf1 = inf # positive infinity +sf2 = +inf # positive infinity +sf3 = -inf # negative infinity + +# not a number +sf4 = nan # actual sNaN/qNaN encoding is implementation-specific +sf5 = +nan # same as `nan` +sf6 = -nan # valid, actual encoding is implementation-specific)"sv; + static constexpr auto spec_inline_table_0 = R"(name = { first = "Tom", last = "Preston-Werner" } +point = { x = 1, y = 2 } +animal = { type.name = "pug" })"sv; + static constexpr auto spec_inline_table_1 = R"([name] +first = "Tom" +last = "Preston-Werner" + +[point] +x = 1 +y = 2 + +[animal] +type.name = "pug")"sv; + static constexpr auto spec_inline_table_2 = R"([product] +type = { name = "Nail" } +# type.edible = false # INVALID)"sv; + static constexpr auto spec_inline_table_3 = R"([product] +type.name = "Nail" +# type = { edible = false } # INVALID)"sv; + static constexpr auto spec_integer_0 = R"(int1 = +99 +int2 = 42 +int3 = 0 +int4 = -17)"sv; + static constexpr auto spec_integer_1 = R"(int5 = 1_000 +int6 = 5_349_221 +int7 = 53_49_221 # Indian number system grouping +int8 = 1_2_3_4_5 # VALID but discouraged)"sv; + static constexpr auto spec_integer_2 = R"(# hexadecimal with prefix `0x` +hex1 = 0xDEADBEEF +hex2 = 0xdeadbeef +hex3 = 0xdead_beef + +# octal with prefix `0o` +oct1 = 0o01234567 +oct2 = 0o755 # useful for Unix file permissions + +# binary with prefix `0b` +bin1 = 0b11010110)"sv; + static constexpr auto spec_key_value_pair_0 = R"(key = "value")"sv; + static constexpr auto spec_keys_0 = R"(key = "value" +bare_key = "value" +bare-key = "value" +1234 = "value")"sv; + static constexpr auto spec_keys_3 = R"(name = "Orange" +physical.color = "orange" +physical.shape = "round" +site."google.com" = true)"sv; + static constexpr auto spec_keys_4 = R"(fruit.name = "banana" # this is best practice +fruit. color = "yellow" # same as fruit.color +fruit . flavor = "banana" # same as fruit.flavor)"sv; + static constexpr auto spec_keys_5 = R"(# VALID BUT DISCOURAGED + +apple.type = "fruit" +orange.type = "fruit" + +apple.skin = "thin" +orange.skin = "thick" + +apple.color = "red" +orange.color = "orange")"sv; + static constexpr auto spec_keys_6 = R"(# RECOMMENDED + +apple.type = "fruit" +apple.skin = "thin" +apple.color = "red" + +orange.type = "fruit" +orange.skin = "thick" +orange.color = "orange")"sv; + static constexpr auto spec_keys_7 = R"(3.14159 = "pi")"sv; + static constexpr auto spec_local_date_0 = R"(ld1 = 1979-05-27)"sv; + static constexpr auto spec_local_date_time_0 = R"(ldt1 = 1979-05-27T07:32:00 +ldt2 = 1979-05-27T00:32:00.999999)"sv; + static constexpr auto spec_local_time_0 = R"(lt1 = 07:32:00 +lt2 = 00:32:00.999999)"sv; + static constexpr auto spec_offset_date_time_0 = R"(odt1 = 1979-05-27T07:32:00Z +odt2 = 1979-05-27T00:32:00-07:00 +odt3 = 1979-05-27T00:32:00.999999-07:00)"sv; + static constexpr auto spec_offset_date_time_1 = R"(odt4 = 1979-05-27 07:32:00Z)"sv; + static constexpr auto spec_string_1 = R"(str1 = """ +Roses are red +Violets are blue""")"sv; + static constexpr auto spec_string_2 = + R"(# On a Unix system, the above multi-line string will most likely be the same as: +str2 = "Roses are red\nViolets are blue" + +# On a Windows system, it will most likely be equivalent to: +str3 = "Roses are red\r\nViolets are blue")"sv; + static constexpr auto spec_string_3 = R"(# The following strings are byte-for-byte equivalent: +str1 = "The quick brown fox jumps over the lazy dog." + +str2 = """ +The quick brown \ + + + fox jumps over \ + the lazy dog.""" + +str3 = """\ + The quick brown \ + fox jumps over \ + the lazy dog.\ + """)"sv; + static constexpr auto spec_string_4 = R"(str4 = """Here are two quotation marks: "". Simple enough.""" +# str5 = """Here are three quotation marks: """.""" # INVALID +str5 = """Here are three quotation marks: ""\".""" +str6 = """Here are fifteen quotation marks: ""\"""\"""\"""\"""\".""" + +# "This," she said, "is just a pointless statement." +str7 = """"This," she said, "is just a pointless statement."""")"sv; + static constexpr auto spec_string_5 = R"(# What you see is what you get. +winpath = 'C:\Users\nodejs\templates' +winpath2 = '\\ServerX\admin$\system32\' +quoted = 'Tom "Dubs" Preston-Werner' +regex = '<\i\c*\s*>')"sv; + static constexpr auto spec_string_6 = R"(regex2 = '''I [dw]on't need \d{2} apples''' +lines = ''' +The first newline is +trimmed in raw strings. + All other whitespace + is preserved. +''')"sv; + static constexpr auto spec_string_7 = R"(quot15 = '''Here are fifteen quotation marks: """""""""""""""''' + +# apos15 = '''Here are fifteen apostrophes: '''''''''''''''''' # INVALID +apos15 = "Here are fifteen apostrophes: '''''''''''''''" + +# 'That,' she said, 'is still pointless.' +str = ''''That,' she said, 'is still pointless.'''')"sv; + static constexpr auto spec_table_0 = R"([table])"sv; + static constexpr auto spec_table_1 = R"([table-1] +key1 = "some string" +key2 = 123 + +[table-2] +key1 = "another string" +key2 = 456)"sv; + static constexpr auto spec_table_2 = R"([dog."tater.man"] +type.name = "pug")"sv; + static constexpr auto spec_table_4 = R"(# [x] you +# [x.y] don't +# [x.y.z] need these +[x.y.z.w] # for this to work + +[x] # defining a super-table afterward is ok)"sv; + static constexpr auto spec_table_5 = R"(# VALID BUT DISCOURAGED +[fruit.apple] +[animal] +[fruit.orange])"sv; + static constexpr auto spec_table_6 = R"(# RECOMMENDED +[fruit.apple] +[fruit.orange] +[animal])"sv; + static constexpr auto spec_table_7 = R"(# Top-level table begins. +name = "Fido" +breed = "pug" + +# Top-level table ends. +[owner] +name = "Regina Dogman" +member_since = 1999-08-04)"sv; + static constexpr auto spec_table_8 = R"(fruit.apple.color = "red" +# Defines a table named fruit +# Defines a table named fruit.apple + +fruit.apple.taste.sweet = true +# Defines a table named fruit.apple.taste +# fruit and fruit.apple were already created)"sv; + static constexpr auto spec_table_9 = R"([fruit] +apple.color = "red" +apple.taste.sweet = true + +# [fruit.apple] # INVALID +# [fruit.apple.taste] # INVALID + +[fruit.apple.texture] # you can add sub-tables +smooth = true)"sv; static constexpr auto spec_example_1_compact = R"(#Useless spaces eliminated. title="TOML Example" [owner] @@ -442,6 +775,22 @@ hosts = [ "omega" ])"sv; +#if UNICODE_LITERALS_OK + + static constexpr auto spec_keys_1 = R"("127.0.0.1" = "value" +"character encoding" = "value" +"ʎǝʞ" = "value" +'key2' = "value" +'quoted "value"' = "value")"sv; + static constexpr auto spec_string_0 = + R"(str = "I'm a string. \"You can quote me\". Name\tJos\u00E9\nLocation\tSF.")"sv; + static constexpr auto spec_table_3 = R"([a.b.c] # this is best practice +[ d.e.f ] # same as [d.e.f] +[ g . h . i ] # same as [g.h.i] +[ j . "ʞ" . 'l' ] # same as [j."ʞ".'l'])"sv; + +#endif // UNICODE_LITERALS_OK + static constexpr auto string_double_quote_escape = R"(test = "\"one\"")"sv; static constexpr auto string_empty = R"(answer = "")"sv; static constexpr auto string_escaped_escape = R"(answer = "\\x64")"sv; @@ -555,9 +904,14 @@ This string has ' a quote character and more than one newline -in it.''')"sv; +in it.''' + +# Tab character in literal string does not need to be escaped +multiline_with_tab = '''First line + Followed by a tab''')"sv; static constexpr auto string_raw = R"(backspace = 'This string has a \b backspace character.' tab = 'This string has a \t tab character.' +unescaped_tab = 'This string has an unescaped tab character.' newline = 'This string has a \n new line character.' formfeed = 'This string has a \f form feed character.' carriage = 'This string has a \r carriage return character.' @@ -590,15 +944,52 @@ lit_multiline_not_unicode = ''' \u007f''' lit_multiline_end = '''There is no escape\''')"sv; + static constexpr auto string_quoted_unicode = R"( +escaped_string = "\u0000 \u0008 \u000c \U00000041 \u007f \u0080 \u00ff \ud7ff \ue000 \uffff \U00010000 \U0010ffff" +not_escaped_string = '\u0000 \u0008 \u000c \U00000041 \u007f \u0080 \u00ff \ud7ff \ue000 \uffff \U00010000 \U0010ffff' + +basic_string = "~ € ÿ ퟿  ￿ 𐀀 􏿿" +literal_string = '~ € ÿ ퟿  ￿ 𐀀 􏿿')"sv; static constexpr auto string_unicode_escape = R"(answer4 = "\u03B4" answer8 = "\U000003B4")"sv; static constexpr auto string_unicode_literal = R"(answer = "δ")"sv; #endif // UNICODE_LITERALS_OK - static constexpr auto table_array_implicit = R"([[albums.songs]] +#if TOML_LANG_UNRELEASED && UNICODE_LITERALS_OK + + static constexpr auto string_hex_escape = R"(# \x for the first 255 codepoints + +whitespace = "\x20 \x09 \x1b \x0d\x0a" +bs = "\x7f" +nul = "\x00" +hello = "\x68\x65\x6c\x6c\x6f\x0a" +higher-than-127 = "S\xf8rmirb\xe6ren" + +multiline = """ +\x20 \x09 \x1b \x0d\x0a +\x7f +\x00 +\x68\x65\x6c\x6c\x6f\x0a +\x53\xF8\x72\x6D\x69\x72\x62\xE6\x72\x65\x6E +""" + +# Not inside literals. +literal = '\x20 \x09 \x0d\x0a' +multiline-literal = ''' +\x20 \x09 \x0d\x0a +''')"sv; + +#endif // TOML_LANG_UNRELEASED && UNICODE_LITERALS_OK + + static constexpr auto table_array_implicit_and_explicit_after = R"([[a.b]] +x = 1 + +[a] +y = 2)"sv; + static constexpr auto table_array_implicit = R"([[albums.songs]] name = "Glory Days")"sv; - static constexpr auto table_array_many = R"([[people]] + static constexpr auto table_array_many = R"([[people]] first_name = "Bruce" last_name = "Springsteen" @@ -609,7 +1000,7 @@ last_name = "Clapton" [[people]] first_name = "Bob" last_name = "Seger")"sv; - static constexpr auto table_array_nest = R"([[albums]] + static constexpr auto table_array_nest = R"([[albums]] name = "Born to Run" [[albums.songs]] @@ -626,39 +1017,61 @@ name = "Born in the USA" [[albums.songs]] name = "Dancing in the Dark")"sv; - static constexpr auto table_array_one = R"([[people]] + static constexpr auto table_array_one = R"([[people]] first_name = "Bruce" last_name = "Springsteen")"sv; - static constexpr auto table_array_table_array = R"([[a]] + static constexpr auto table_array_table_array = R"([[a]] [[a.b]] [a.b.c] d = "val0" [[a.b]] [a.b.c] d = "val1")"sv; - static constexpr auto table_empty = R"([a])"sv; - static constexpr auto table_keyword = R"([true] + static constexpr auto table_array_within_dotted = R"([fruit] +apple.color = "red" + +[[fruit.apple.seeds]] +size = 2)"sv; + static constexpr auto table_empty_name = R"([''] +x = 1 + +["".a] +x = 2 + +[a.''] +x = 3)"sv; + static constexpr auto table_empty = R"([a])"sv; + static constexpr auto table_keyword = R"([true] [false] [inf] [nan])"sv; - static constexpr auto table_no_eol = R"([table])"sv; - static constexpr auto table_sub_empty = R"([a] + static constexpr auto table_no_eol = R"([table])"sv; + static constexpr auto table_sub_empty = R"([a] [a.b])"sv; - static constexpr auto table_whitespace = R"(["valid key"])"sv; - static constexpr auto table_with_literal_string = R"(['a'] + static constexpr auto table_sub = R"([a] +key = 1 + +# a.extend is a key inside the "a" table. +[a.extend] +key = 2 + +[a.extend.more] +key = 3)"sv; + static constexpr auto table_whitespace = R"(["valid key"])"sv; + static constexpr auto table_with_literal_string = R"(['a'] [a.'"b"'] [a.'"b"'.c] answer = 42 )"sv; - static constexpr auto table_with_pound = R"(["key#group"] + static constexpr auto table_with_pound = R"(["key#group"] answer = 42)"sv; - static constexpr auto table_with_single_quotes = R"(['a'] + static constexpr auto table_with_single_quotes = R"(['a'] [a.'b'] [a.'b'.c] answer = 42 )"sv; - static constexpr auto table_without_super = R"(# [x] you + static constexpr auto table_without_super = R"(# [x] you # [x.y] don't # [x.y.z] need these [x.y.z.w] # for this to work @@ -681,1995 +1094,3598 @@ answer = 42 )"sv; TEST_CASE("conformance - burntsushi/valid") { - parsing_should_succeed(FILE_LINE_ARGS, - array_array, - [](toml::table&& tbl) // array-array - { - const auto expected = toml::table{ - { R"(comments)"sv, - toml::array{ - 1, - 2, - } }, - { R"(dates)"sv, - toml::array{ - toml::date_time{ { 1987, 7, 5 }, { 17, 45 }, { 0, 0 } }, - toml::date_time{ { 1979, 5, 27 }, { 7, 32 }, { 0, 0 } }, - toml::date_time{ { 2006, 6, 1 }, { 11, 0 }, { 0, 0 } }, - } }, - { R"(floats)"sv, - toml::array{ - 1.1, - 2.1, - 3.1, - } }, - { R"(ints)"sv, - toml::array{ - 1, - 2, - 3, - } }, - { R"(strings)"sv, - toml::array{ - R"(a)"sv, - R"(b)"sv, - R"(c)"sv, - } }, - }; - REQUIRE(tbl == expected); - }); - - parsing_should_succeed(FILE_LINE_ARGS, - array_bool, - [](toml::table&& tbl) // array-bool - { - const auto expected = toml::table{ - { R"(a)"sv, - toml::array{ - true, - false, - } }, - }; - REQUIRE(tbl == expected); - }); - - parsing_should_succeed(FILE_LINE_ARGS, - array_empty, - [](toml::table&& tbl) // array-empty - { - const auto expected = toml::table{ - { R"(thevoid)"sv, - toml::array{ - toml::inserter{ toml::array{ - toml::inserter{ toml::array{ - toml::inserter{ toml::array{ - toml::inserter{ toml::array{} }, - } }, - } }, - } }, - } }, - }; - REQUIRE(tbl == expected); - }); - - parsing_should_succeed(FILE_LINE_ARGS, - array_hetergeneous, - [](toml::table&& tbl) // array-hetergeneous - { - const auto expected = toml::table{ - { R"(mixed)"sv, - toml::array{ + SECTION("array-array") + { + parsing_should_succeed(FILE_LINE_ARGS, + array_array, + [](toml::table&& tbl) // array-array + { + const auto expected = toml::table{ + { R"(comments)"sv, toml::array{ 1, 2, - }, + } }, + { R"(dates)"sv, toml::array{ - R"(a)"sv, - R"(b)"sv, - }, + toml::date_time{ { 1987, 7, 5 }, { 17, 45 }, { 0, 0 } }, + toml::date_time{ { 1979, 5, 27 }, { 7, 32 }, { 0, 0 } }, + toml::date_time{ { 2006, 6, 1 }, { 11, 0 }, { 0, 0 } }, + } }, + { R"(floats)"sv, toml::array{ 1.1, 2.1, - }, - } }, - }; - REQUIRE(tbl == expected); - }); - - parsing_should_succeed(FILE_LINE_ARGS, - array_mixed_int_array, - [](toml::table&& tbl) // array-mixed-int-array - { - const auto expected = toml::table{ - { R"(arrays-and-ints)"sv, - toml::array{ - 1, + 3.1, + } }, + { R"(ints)"sv, toml::array{ - R"(Arrays are not integers.)"sv, - }, - } }, - }; - REQUIRE(tbl == expected); - }); + 1, + 2, + 3, + } }, + { R"(strings)"sv, + toml::array{ + R"(a)"sv, + R"(b)"sv, + R"(c)"sv, + } }, + }; + REQUIRE(tbl == expected); + }); + } - parsing_should_succeed(FILE_LINE_ARGS, - array_mixed_int_float, - [](toml::table&& tbl) // array-mixed-int-float - { - const auto expected = toml::table{ - { R"(ints-and-floats)"sv, - toml::array{ - 1, - 1.1, - } }, - }; - REQUIRE(tbl == expected); - }); + SECTION("array-bool") + { + parsing_should_succeed(FILE_LINE_ARGS, + array_bool, + [](toml::table&& tbl) // array-bool + { + const auto expected = toml::table{ + { R"(a)"sv, + toml::array{ + true, + false, + } }, + }; + REQUIRE(tbl == expected); + }); + } - parsing_should_succeed(FILE_LINE_ARGS, - array_mixed_int_string, - [](toml::table&& tbl) // array-mixed-int-string - { - const auto expected = toml::table{ - { R"(strings-and-ints)"sv, - toml::array{ - R"(hi)"sv, - 42, - } }, - }; - REQUIRE(tbl == expected); - }); + SECTION("array-empty") + { + parsing_should_succeed(FILE_LINE_ARGS, + array_empty, + [](toml::table&& tbl) // array-empty + { + const auto expected = toml::table{ + { R"(thevoid)"sv, + toml::array{ + toml::inserter{ toml::array{ + toml::inserter{ toml::array{ + toml::inserter{ toml::array{ + toml::inserter{ toml::array{} }, + } }, + } }, + } }, + } }, + }; + REQUIRE(tbl == expected); + }); + } - parsing_should_succeed(FILE_LINE_ARGS, - array_mixed_string_table, - [](toml::table&& tbl) // array-mixed-string-table - { - const auto expected = toml::table{ - { R"(contributors)"sv, - toml::array{ - R"(Foo Bar )"sv, - toml::table{ - { R"(email)"sv, R"(bazqux@example.com)"sv }, - { R"(name)"sv, R"(Baz Qux)"sv }, - { R"(url)"sv, R"(https://example.com/bazqux)"sv }, - }, - } }, - { R"(mixed)"sv, - toml::array{ - toml::table{ - { R"(k)"sv, R"(a)"sv }, - }, - R"(b)"sv, - 1, - } }, - }; - REQUIRE(tbl == expected); - }); + SECTION("array-hetergeneous") + { + parsing_should_succeed(FILE_LINE_ARGS, + array_hetergeneous, + [](toml::table&& tbl) // array-hetergeneous + { + const auto expected = toml::table{ + { R"(mixed)"sv, + toml::array{ + toml::array{ + 1, + 2, + }, + toml::array{ + R"(a)"sv, + R"(b)"sv, + }, + toml::array{ + 1.1, + 2.1, + }, + } }, + }; + REQUIRE(tbl == expected); + }); + } - parsing_should_succeed(FILE_LINE_ARGS, - array_nested_double, - [](toml::table&& tbl) // array-nested-double - { - const auto expected = toml::table{ - { R"(nest)"sv, - toml::array{ - toml::inserter{ toml::array{ + SECTION("array-mixed-int-array") + { + parsing_should_succeed(FILE_LINE_ARGS, + array_mixed_int_array, + [](toml::table&& tbl) // array-mixed-int-array + { + const auto expected = toml::table{ + { R"(arrays-and-ints)"sv, + toml::array{ + 1, + toml::array{ + R"(Arrays are not integers.)"sv, + }, + } }, + }; + REQUIRE(tbl == expected); + }); + } + + SECTION("array-mixed-int-float") + { + parsing_should_succeed(FILE_LINE_ARGS, + array_mixed_int_float, + [](toml::table&& tbl) // array-mixed-int-float + { + const auto expected = toml::table{ + { R"(ints-and-floats)"sv, + toml::array{ + 1, + 1.1, + } }, + }; + REQUIRE(tbl == expected); + }); + } + + SECTION("array-mixed-int-string") + { + parsing_should_succeed(FILE_LINE_ARGS, + array_mixed_int_string, + [](toml::table&& tbl) // array-mixed-int-string + { + const auto expected = toml::table{ + { R"(strings-and-ints)"sv, + toml::array{ + R"(hi)"sv, + 42, + } }, + }; + REQUIRE(tbl == expected); + }); + } + + SECTION("array-mixed-string-table") + { + parsing_should_succeed(FILE_LINE_ARGS, + array_mixed_string_table, + [](toml::table&& tbl) // array-mixed-string-table + { + const auto expected = toml::table{ + { R"(contributors)"sv, + toml::array{ + R"(Foo Bar )"sv, + toml::table{ + { R"(email)"sv, R"(bazqux@example.com)"sv }, + { R"(name)"sv, R"(Baz Qux)"sv }, + { R"(url)"sv, R"(https://example.com/bazqux)"sv }, + }, + } }, + { R"(mixed)"sv, + toml::array{ + toml::table{ + { R"(k)"sv, R"(a)"sv }, + }, + R"(b)"sv, + 1, + } }, + }; + REQUIRE(tbl == expected); + }); + } + + SECTION("array-nested-double") + { + parsing_should_succeed(FILE_LINE_ARGS, + array_nested_double, + [](toml::table&& tbl) // array-nested-double + { + const auto expected = toml::table{ + { R"(nest)"sv, + toml::array{ + toml::inserter{ toml::array{ + toml::array{ + R"(a)"sv, + }, + toml::array{ + 1, + 2, + toml::array{ + 3, + }, + }, + } }, + } }, + }; + REQUIRE(tbl == expected); + }); + } + + SECTION("array-nested-inline-table") + { + parsing_should_succeed(FILE_LINE_ARGS, + array_nested_inline_table, + [](toml::table&& tbl) // array-nested-inline-table + { + const auto expected = toml::table{ + { R"(a)"sv, + toml::array{ + toml::table{ + { R"(b)"sv, toml::table{} }, + }, + } }, + }; + REQUIRE(tbl == expected); + }); + } + + SECTION("array-nested") + { + parsing_should_succeed(FILE_LINE_ARGS, + array_nested, + [](toml::table&& tbl) // array-nested + { + const auto expected = toml::table{ + { R"(nest)"sv, + toml::array{ toml::array{ R"(a)"sv, }, toml::array{ - 1, - 2, - toml::array{ - 3, - }, + R"(b)"sv, }, } }, - } }, - }; - REQUIRE(tbl == expected); - }); + }; + REQUIRE(tbl == expected); + }); + } - parsing_should_succeed(FILE_LINE_ARGS, - array_nested_inline_table, - [](toml::table&& tbl) // array-nested-inline-table - { - const auto expected = toml::table{ - { R"(a)"sv, - toml::array{ - toml::table{ - { R"(b)"sv, toml::table{} }, - }, - } }, - }; - REQUIRE(tbl == expected); - }); - - parsing_should_succeed(FILE_LINE_ARGS, - array_nested, - [](toml::table&& tbl) // array-nested - { - const auto expected = toml::table{ - { R"(nest)"sv, - toml::array{ + SECTION("array-nospaces") + { + parsing_should_succeed(FILE_LINE_ARGS, + array_nospaces, + [](toml::table&& tbl) // array-nospaces + { + const auto expected = toml::table{ + { R"(ints)"sv, toml::array{ - R"(a)"sv, - }, + 1, + 2, + 3, + } }, + }; + REQUIRE(tbl == expected); + }); + } + + SECTION("array-string-quote-comma-2") + { + parsing_should_succeed(FILE_LINE_ARGS, + array_string_quote_comma_2, + [](toml::table&& tbl) // array-string-quote-comma-2 + { + const auto expected = toml::table{ + { R"(title)"sv, toml::array{ - R"(b)"sv, - }, - } }, - }; - REQUIRE(tbl == expected); - }); + R"( ", )"sv, + } }, + }; + REQUIRE(tbl == expected); + }); + } - parsing_should_succeed(FILE_LINE_ARGS, - array_nospaces, - [](toml::table&& tbl) // array-nospaces - { - const auto expected = toml::table{ - { R"(ints)"sv, - toml::array{ - 1, - 2, - 3, - } }, - }; - REQUIRE(tbl == expected); - }); + SECTION("array-string-quote-comma") + { + parsing_should_succeed(FILE_LINE_ARGS, + array_string_quote_comma, + [](toml::table&& tbl) // array-string-quote-comma + { + const auto expected = toml::table{ + { R"(title)"sv, + toml::array{ + R"(Client: "XXXX", Job: XXXX)"sv, + R"(Code: XXXX)"sv, + } }, + }; + REQUIRE(tbl == expected); + }); + } - parsing_should_succeed(FILE_LINE_ARGS, - array_string_quote_comma_2, - [](toml::table&& tbl) // array-string-quote-comma-2 - { - const auto expected = toml::table{ - { R"(title)"sv, - toml::array{ - R"( ", )"sv, - } }, - }; - REQUIRE(tbl == expected); - }); + SECTION("array-string-with-comma") + { + parsing_should_succeed(FILE_LINE_ARGS, + array_string_with_comma, + [](toml::table&& tbl) // array-string-with-comma + { + const auto expected = toml::table{ + { R"(title)"sv, + toml::array{ + R"(Client: XXXX, Job: XXXX)"sv, + R"(Code: XXXX)"sv, + } }, + }; + REQUIRE(tbl == expected); + }); + } - parsing_should_succeed(FILE_LINE_ARGS, - array_string_quote_comma, - [](toml::table&& tbl) // array-string-quote-comma - { - const auto expected = toml::table{ - { R"(title)"sv, - toml::array{ - R"(Client: "XXXX", Job: XXXX)"sv, - R"(Code: XXXX)"sv, - } }, - }; - REQUIRE(tbl == expected); - }); + SECTION("array-strings") + { + parsing_should_succeed(FILE_LINE_ARGS, + array_strings, + [](toml::table&& tbl) // array-strings + { + const auto expected = toml::table{ + { R"(string_array)"sv, + toml::array{ + R"(all)"sv, + R"(strings)"sv, + R"(are the same)"sv, + R"(type)"sv, + } }, + }; + REQUIRE(tbl == expected); + }); + } - parsing_should_succeed(FILE_LINE_ARGS, - array_string_with_comma, - [](toml::table&& tbl) // array-string-with-comma - { - const auto expected = toml::table{ - { R"(title)"sv, - toml::array{ - R"(Client: XXXX, Job: XXXX)"sv, - R"(Code: XXXX)"sv, - } }, - }; - REQUIRE(tbl == expected); - }); + SECTION("array-table-array-string-backslash") + { + parsing_should_succeed(FILE_LINE_ARGS, + array_table_array_string_backslash, + [](toml::table&& tbl) // array-table-array-string-backslash + { + const auto expected = toml::table{ + { R"(foo)"sv, + toml::array{ + toml::table{ + { R"(bar)"sv, R"("{{baz}}")"sv }, + }, + } }, + }; + REQUIRE(tbl == expected); + }); + } - parsing_should_succeed(FILE_LINE_ARGS, - array_strings, - [](toml::table&& tbl) // array-strings - { - const auto expected = toml::table{ - { R"(string_array)"sv, - toml::array{ - R"(all)"sv, - R"(strings)"sv, - R"(are the same)"sv, - R"(type)"sv, - } }, - }; - REQUIRE(tbl == expected); - }); + SECTION("bool-bool") + { + parsing_should_succeed(FILE_LINE_ARGS, + bool_bool, + [](toml::table&& tbl) // bool-bool + { + const auto expected = toml::table{ + { R"(f)"sv, false }, + { R"(t)"sv, true }, + }; + REQUIRE(tbl == expected); + }); + } - parsing_should_succeed(FILE_LINE_ARGS, - array_table_array_string_backslash, - [](toml::table&& tbl) // array-table-array-string-backslash - { - const auto expected = toml::table{ - { R"(foo)"sv, - toml::array{ + SECTION("comment-at-eof") + { + parsing_should_succeed(FILE_LINE_ARGS, + comment_at_eof, + [](toml::table&& tbl) // comment-at-eof + { + const auto expected = toml::table{ + { R"(key)"sv, R"(value)"sv }, + }; + REQUIRE(tbl == expected); + }); + } + + SECTION("comment-at-eof2") + { + parsing_should_succeed(FILE_LINE_ARGS, + comment_at_eof2, + [](toml::table&& tbl) // comment-at-eof2 + { + const auto expected = toml::table{ + { R"(key)"sv, R"(value)"sv }, + }; + REQUIRE(tbl == expected); + }); + } + + SECTION("comment-everywhere") + { + parsing_should_succeed( + FILE_LINE_ARGS, + comment_everywhere, + [](toml::table&& tbl) // comment-everywhere + { + const auto expected = toml::table{ + { R"(group)"sv, + toml::table{ + { R"(answer)"sv, 42 }, + { R"(dt)"sv, toml::date_time{ { 1979, 5, 27 }, { 7, 32, 12 }, { -7, 0 } } }, + { R"(d)"sv, toml::date{ 1979, 5, 27 } }, + { R"(more)"sv, + toml::array{ + 42, + 42, + } }, + } }, + }; + REQUIRE(tbl == expected); + }); + } + + SECTION("comment-noeol") + { + parsing_should_succeed(FILE_LINE_ARGS, + comment_noeol, + [](toml::table&& tbl) // comment-noeol + { + const auto expected = toml::table{}; + REQUIRE(tbl == expected); + }); + } + + SECTION("comment-tricky") + { + parsing_should_succeed(FILE_LINE_ARGS, + comment_tricky, + [](toml::table&& tbl) // comment-tricky + { + const auto expected = toml::table{ + { R"(hash#tag)"sv, toml::table{ - { R"(bar)"sv, R"("{{baz}}")"sv }, - }, - } }, - }; - REQUIRE(tbl == expected); - }); - - parsing_should_succeed(FILE_LINE_ARGS, - bool_bool, - [](toml::table&& tbl) // bool-bool - { - const auto expected = toml::table{ - { R"(f)"sv, false }, - { R"(t)"sv, true }, - }; - REQUIRE(tbl == expected); - }); - - parsing_should_succeed(FILE_LINE_ARGS, - comment_at_eof, - [](toml::table&& tbl) // comment-at-eof - { - const auto expected = toml::table{ - { R"(key)"sv, R"(value)"sv }, - }; - REQUIRE(tbl == expected); - }); - - parsing_should_succeed(FILE_LINE_ARGS, - comment_at_eof2, - [](toml::table&& tbl) // comment-at-eof2 - { - const auto expected = toml::table{ - { R"(key)"sv, R"(value)"sv }, - }; - REQUIRE(tbl == expected); - }); - - parsing_should_succeed(FILE_LINE_ARGS, - comment_everywhere, - [](toml::table&& tbl) // comment-everywhere - { - const auto expected = toml::table{ - { R"(group)"sv, - toml::table{ - { R"(answer)"sv, 42 }, - { R"(dt)"sv, toml::date_time{ { 1979, 5, 27 }, { 7, 32, 12 }, { -7, 0 } } }, - { R"(d)"sv, toml::date{ 1979, 5, 27 } }, - { R"(more)"sv, - toml::array{ - 42, - 42, - } }, - } }, - }; - REQUIRE(tbl == expected); - }); - - parsing_should_succeed(FILE_LINE_ARGS, - comment_noeol, - [](toml::table&& tbl) // comment-noeol - { - const auto expected = toml::table{}; - REQUIRE(tbl == expected); - }); - - parsing_should_succeed(FILE_LINE_ARGS, - comment_tricky, - [](toml::table&& tbl) // comment-tricky - { - const auto expected = toml::table{ - { R"(hash#tag)"sv, - toml::table{ - { R"(#!)"sv, R"(hash bang)"sv }, - { R"(arr3)"sv, - toml::array{ - R"(#)"sv, - R"(#)"sv, - R"(###)"sv, - } }, - { R"(arr4)"sv, - toml::array{ - 1, - 2, - 3, - 4, - } }, - { R"(arr5)"sv, - toml::array{ - toml::inserter{ toml::array{ + { R"(#!)"sv, R"(hash bang)"sv }, + { R"(arr3)"sv, + toml::array{ + R"(#)"sv, + R"(#)"sv, + R"(###)"sv, + } }, + { R"(arr4)"sv, + toml::array{ + 1, + 2, + 3, + 4, + } }, + { R"(arr5)"sv, + toml::array{ toml::inserter{ toml::array{ toml::inserter{ toml::array{ toml::inserter{ toml::array{ - R"(#)"sv, + toml::inserter{ toml::array{ + R"(#)"sv, + } }, } }, } }, } }, } }, - } }, - { R"(tbl1)"sv, - toml::table{ - { R"(#)"sv, R"(}#)"sv }, - } }, - } }, - { R"(section)"sv, - toml::table{ - { R"(8)"sv, R"(eight)"sv }, - { R"(eleven)"sv, 11.1 }, - { R"(five)"sv, 5.5 }, - { R"(four)"sv, R"(# no comment + { R"(tbl1)"sv, + toml::table{ + { R"(#)"sv, R"(}#)"sv }, + } }, + } }, + { R"(section)"sv, + toml::table{ + { R"(8)"sv, R"(eight)"sv }, + { R"(eleven)"sv, 11.1 }, + { R"(five)"sv, 5.5 }, + { R"(four)"sv, R"(# no comment # nor this #also not comment)"sv }, - { R"(one)"sv, R"(11)"sv }, - { R"(six)"sv, 6 }, - { R"(ten)"sv, 1000.0 }, - { R"(three)"sv, R"(#)"sv }, - { R"(two)"sv, R"(22#)"sv }, - } }, - }; - REQUIRE(tbl == expected); - }); - - parsing_should_succeed(FILE_LINE_ARGS, - datetime_datetime, - [](toml::table&& tbl) // datetime-datetime - { - const auto expected = toml::table{ - { R"(lower)"sv, toml::date_time{ { 1987, 7, 5 }, { 17, 45 }, { 0, 0 } } }, - { R"(space)"sv, toml::date_time{ { 1987, 7, 5 }, { 17, 45 }, { 0, 0 } } }, - }; - REQUIRE(tbl == expected); - }); - - parsing_should_succeed(FILE_LINE_ARGS, - datetime_local_date, - [](toml::table&& tbl) // datetime-local-date - { - const auto expected = toml::table{ - { R"(bestdayever)"sv, toml::date{ 1987, 7, 5 } }, - }; - REQUIRE(tbl == expected); - }); - - parsing_should_succeed(FILE_LINE_ARGS, - datetime_local_time, - [](toml::table&& tbl) // datetime-local-time - { - const auto expected = toml::table{ - { R"(besttimeever)"sv, toml::time{ 17, 45 } }, - { R"(milliseconds)"sv, toml::time{ 10, 32, 0, 555000000 } }, - }; - REQUIRE(tbl == expected); - }); - - parsing_should_succeed(FILE_LINE_ARGS, - datetime_local, - [](toml::table&& tbl) // datetime-local - { - const auto expected = toml::table{ - { R"(local)"sv, toml::date_time{ { 1987, 7, 5 }, { 17, 45 } } }, - { R"(milli)"sv, toml::date_time{ { 1977, 12, 21 }, { 10, 32, 0, 555000000 } } }, - { R"(space)"sv, toml::date_time{ { 1987, 7, 5 }, { 17, 45 } } }, - }; - REQUIRE(tbl == expected); - }); - - parsing_should_succeed( - FILE_LINE_ARGS, - datetime_milliseconds, - [](toml::table&& tbl) // datetime-milliseconds - { - const auto expected = toml::table{ - { R"(utc1)"sv, toml::date_time{ { 1987, 7, 5 }, { 17, 45, 56, 123400000 }, { 0, 0 } } }, - { R"(utc2)"sv, toml::date_time{ { 1987, 7, 5 }, { 17, 45, 56, 600000000 }, { 0, 0 } } }, - { R"(wita1)"sv, toml::date_time{ { 1987, 7, 5 }, { 17, 45, 56, 123400000 }, { 8, 0 } } }, - { R"(wita2)"sv, toml::date_time{ { 1987, 7, 5 }, { 17, 45, 56, 600000000 }, { 8, 0 } } }, - }; - REQUIRE(tbl == expected); - }); - - parsing_should_succeed(FILE_LINE_ARGS, - datetime_timezone, - [](toml::table&& tbl) // datetime-timezone - { - const auto expected = toml::table{ - { R"(nzdt)"sv, toml::date_time{ { 1987, 7, 5 }, { 17, 45, 56 }, { 13, 0 } } }, - { R"(nzst)"sv, toml::date_time{ { 1987, 7, 5 }, { 17, 45, 56 }, { 12, 0 } } }, - { R"(pdt)"sv, toml::date_time{ { 1987, 7, 5 }, { 17, 45, 56 }, { -5, 0 } } }, - { R"(utc)"sv, toml::date_time{ { 1987, 7, 5 }, { 17, 45, 56 }, { 0, 0 } } }, - }; - REQUIRE(tbl == expected); - }); - - parsing_should_succeed(FILE_LINE_ARGS, - empty_file, - [](toml::table&& tbl) // empty-file - { - const auto expected = toml::table{}; - REQUIRE(tbl == expected); - }); - - parsing_should_succeed(FILE_LINE_ARGS, - example, - [](toml::table&& tbl) // example - { - const auto expected = toml::table{ - { R"(best-day-ever)"sv, toml::date_time{ { 1987, 7, 5 }, { 17, 45 }, { 0, 0 } } }, - { R"(numtheory)"sv, - toml::table{ - { R"(boring)"sv, false }, - { R"(perfection)"sv, - toml::array{ - 6, - 28, - 496, - } }, - } }, - }; - REQUIRE(tbl == expected); - }); - - parsing_should_succeed(FILE_LINE_ARGS, - float_exponent, - [](toml::table&& tbl) // float-exponent - { - const auto expected = toml::table{ - { R"(lower)"sv, 300.0 }, { R"(minustenth)"sv, -0.1 }, { R"(neg)"sv, 0.03 }, - { R"(pointlower)"sv, 310.0 }, { R"(pointupper)"sv, 310.0 }, { R"(pos)"sv, 300.0 }, - { R"(upper)"sv, 300.0 }, { R"(zero)"sv, 3.0 }, - }; - REQUIRE(tbl == expected); - }); - - parsing_should_succeed(FILE_LINE_ARGS, - float_float, - [](toml::table&& tbl) // float-float - { - const auto expected = toml::table{ - { R"(negpi)"sv, -3.14 }, - { R"(pi)"sv, 3.14 }, - { R"(pospi)"sv, 3.14 }, - { R"(zero-intpart)"sv, 0.123 }, - }; - REQUIRE(tbl == expected); - }); - - parsing_should_succeed(FILE_LINE_ARGS, - float_inf_and_nan, - [](toml::table&& tbl) // float-inf-and-nan - { - const auto expected = toml::table{ - { R"(infinity)"sv, std::numeric_limits::infinity() }, - { R"(infinity_neg)"sv, -std::numeric_limits::infinity() }, - { R"(infinity_plus)"sv, std::numeric_limits::infinity() }, - { R"(nan)"sv, std::numeric_limits::quiet_NaN() }, - { R"(nan_neg)"sv, std::numeric_limits::quiet_NaN() }, - { R"(nan_plus)"sv, std::numeric_limits::quiet_NaN() }, - }; - REQUIRE(tbl == expected); - }); - - parsing_should_succeed(FILE_LINE_ARGS, - float_long, - [](toml::table&& tbl) // float-long - { - const auto expected = toml::table{ - { R"(longpi)"sv, 3.141592653589793 }, - { R"(neglongpi)"sv, -3.141592653589793 }, - }; - REQUIRE(tbl == expected); - }); - - parsing_should_succeed(FILE_LINE_ARGS, - float_underscore, - [](toml::table&& tbl) // float-underscore - { - const auto expected = toml::table{ - { R"(after)"sv, 3141.5927 }, - { R"(before)"sv, 3141.5927 }, - { R"(exponent)"sv, 300000000000000.0 }, - }; - REQUIRE(tbl == expected); - }); - - parsing_should_succeed(FILE_LINE_ARGS, - float_zero, - [](toml::table&& tbl) // float-zero - { - const auto expected = toml::table{ - { R"(zero)"sv, 0.0 }, - { R"(signed-pos)"sv, 0.0 }, - { R"(signed-neg)"sv, 0.0 }, - { R"(exponent)"sv, 0.0 }, - { R"(exponent-two-0)"sv, 0.0 }, - { R"(exponent-signed-pos)"sv, 0.0 }, - { R"(exponent-signed-neg)"sv, 0.0 }, - }; - REQUIRE(tbl == expected); - }); - - parsing_should_succeed(FILE_LINE_ARGS, - implicit_and_explicit_after, - [](toml::table&& tbl) // implicit-and-explicit-after - { - const auto expected = toml::table{ - { R"(a)"sv, - toml::table{ - { R"(b)"sv, - toml::table{ - { R"(c)"sv, - toml::table{ - { R"(answer)"sv, 42 }, - } }, - } }, - { R"(better)"sv, 43 }, - } }, - }; - REQUIRE(tbl == expected); - }); - - parsing_should_succeed(FILE_LINE_ARGS, - implicit_and_explicit_before, - [](toml::table&& tbl) // implicit-and-explicit-before - { - const auto expected = toml::table{ - { R"(a)"sv, - toml::table{ - { R"(b)"sv, - toml::table{ - { R"(c)"sv, - toml::table{ - { R"(answer)"sv, 42 }, - } }, - } }, - { R"(better)"sv, 43 }, - } }, - }; - REQUIRE(tbl == expected); - }); - - parsing_should_succeed(FILE_LINE_ARGS, - implicit_groups, - [](toml::table&& tbl) // implicit-groups - { - const auto expected = toml::table{ - { R"(a)"sv, - toml::table{ - { R"(b)"sv, - toml::table{ - { R"(c)"sv, - toml::table{ - { R"(answer)"sv, 42 }, - } }, - } }, - } }, - }; - REQUIRE(tbl == expected); - }); - - parsing_should_succeed(FILE_LINE_ARGS, - inline_table_array, - [](toml::table&& tbl) // inline-table-array - { - const auto expected = toml::table{ - { R"(people)"sv, - toml::array{ - toml::table{ - { R"(first_name)"sv, R"(Bruce)"sv }, - { R"(last_name)"sv, R"(Springsteen)"sv }, - }, - toml::table{ - { R"(first_name)"sv, R"(Eric)"sv }, - { R"(last_name)"sv, R"(Clapton)"sv }, - }, - toml::table{ - { R"(first_name)"sv, R"(Bob)"sv }, - { R"(last_name)"sv, R"(Seger)"sv }, - }, - } }, - }; - REQUIRE(tbl == expected); - }); - - parsing_should_succeed(FILE_LINE_ARGS, - inline_table_bool, - [](toml::table&& tbl) // inline-table-bool - { - const auto expected = toml::table{ - { R"(a)"sv, - toml::table{ - { R"(a)"sv, true }, - { R"(b)"sv, false }, - } }, - }; - REQUIRE(tbl == expected); - }); - - parsing_should_succeed(FILE_LINE_ARGS, - inline_table_empty, - [](toml::table&& tbl) // inline-table-empty - { - const auto expected = toml::table{ - { R"(empty1)"sv, toml::table{} }, - { R"(empty2)"sv, toml::table{} }, - { R"(empty_in_array)"sv, - toml::array{ - toml::table{ - { R"(not_empty)"sv, 1 }, - }, - toml::table{}, - } }, - { R"(empty_in_array2)"sv, - toml::array{ - toml::table{}, - toml::table{ - { R"(not_empty)"sv, 1 }, - }, - } }, - { R"(many_empty)"sv, - toml::array{ - toml::table{}, - toml::table{}, - toml::table{}, - } }, - { R"(nested_empty)"sv, - toml::table{ - { R"(empty)"sv, toml::table{} }, - } }, - }; - REQUIRE(tbl == expected); - }); - - parsing_should_succeed(FILE_LINE_ARGS, - inline_table_end_in_bool, - [](toml::table&& tbl) // inline-table-end-in-bool - { - const auto expected = toml::table{ - { R"(black)"sv, - toml::table{ - { R"(allow_prereleases)"sv, true }, - { R"(python)"sv, R"(>3.6)"sv }, - { R"(version)"sv, R"(>=18.9b0)"sv }, - } }, - }; - REQUIRE(tbl == expected); - }); - - parsing_should_succeed(FILE_LINE_ARGS, - inline_table_inline_table, - [](toml::table&& tbl) // inline-table-inline-table - { - const auto expected = toml::table{ - { R"(name)"sv, - toml::table{ - { R"(first)"sv, R"(Tom)"sv }, - { R"(last)"sv, R"(Preston-Werner)"sv }, - } }, - { R"(point)"sv, - toml::table{ - { R"(x)"sv, 1 }, - { R"(y)"sv, 2 }, - } }, - { R"(simple)"sv, - toml::table{ - { R"(a)"sv, 1 }, - } }, - { R"(str-key)"sv, - toml::table{ - { R"(a)"sv, 1 }, - } }, - { R"(table-array)"sv, - toml::array{ - toml::table{ - { R"(a)"sv, 1 }, - }, - toml::table{ - { R"(b)"sv, 2 }, - }, - } }, - }; - REQUIRE(tbl == expected); - }); - - parsing_should_succeed(FILE_LINE_ARGS, - inline_table_multiline, - [](toml::table&& tbl) // inline-table-multiline - { - const auto expected = toml::table{ - { R"(tbl_multiline)"sv, - toml::table{ - { R"(a)"sv, 1 }, - { R"(b)"sv, R"(multiline -)"sv }, - { R"(c)"sv, R"(and yet -another line)"sv }, - { R"(d)"sv, 4 }, - } }, - }; - REQUIRE(tbl == expected); - }); - - parsing_should_succeed(FILE_LINE_ARGS, - inline_table_nest, - [](toml::table&& tbl) // inline-table-nest - { - const auto expected = toml::table{ - { R"(arr_arr_tbl_empty)"sv, - toml::array{ - toml::inserter{ toml::array{ - toml::table{}, + { R"(one)"sv, R"(11)"sv }, + { R"(six)"sv, 6 }, + { R"(ten)"sv, 1000.0 }, + { R"(three)"sv, R"(#)"sv }, + { R"(two)"sv, R"(22#)"sv }, } }, - } }, - { R"(arr_arr_tbl_val)"sv, - toml::array{ - toml::inserter{ toml::array{ - toml::table{ - { R"(one)"sv, 1 }, - }, - } }, - } }, - { R"(arr_arr_tbls)"sv, - toml::array{ - toml::inserter{ toml::array{ - toml::table{ - { R"(one)"sv, 1 }, - }, - toml::table{ - { R"(two)"sv, 2 }, - }, - } }, - } }, - { R"(arr_tbl_tbl)"sv, - toml::array{ - toml::table{ - { R"(tbl)"sv, - toml::table{ - { R"(one)"sv, 1 }, - } }, - }, - } }, - { R"(tbl_arr_tbl)"sv, - toml::table{ - { R"(arr_tbl)"sv, - toml::array{ - toml::table{ - { R"(one)"sv, 1 }, - }, - } }, - } }, - { R"(tbl_tbl_empty)"sv, - toml::table{ - { R"(tbl_0)"sv, toml::table{} }, - } }, - { R"(tbl_tbl_val)"sv, - toml::table{ - { R"(tbl_1)"sv, - toml::table{ - { R"(one)"sv, 1 }, - } }, - } }, - }; - REQUIRE(tbl == expected); - }); - -#if !TOML_MSVC - - parsing_should_succeed(FILE_LINE_ARGS, - inline_table_key_dotted, - [](toml::table&& tbl) // inline-table-key-dotted - { - const auto expected = toml::table{ - { R"(a)"sv, - toml::table{ - { R"(a)"sv, - toml::table{ - { R"(b)"sv, 1 }, - } }, - } }, - { R"(arr)"sv, - toml::array{ - toml::table{ - { R"(T)"sv, - toml::table{ - { R"(a)"sv, - toml::table{ - { R"(b)"sv, 1 }, - } }, - } }, - { R"(t)"sv, - toml::table{ - { R"(a)"sv, - toml::table{ - { R"(b)"sv, 1 }, - } }, - } }, - }, - toml::table{ - { R"(T)"sv, - toml::table{ - { R"(a)"sv, - toml::table{ - { R"(b)"sv, 2 }, - } }, - } }, - { R"(t)"sv, - toml::table{ - { R"(a)"sv, - toml::table{ - { R"(b)"sv, 2 }, - } }, - } }, - }, - } }, - { R"(b)"sv, - toml::table{ - { R"(a)"sv, - toml::table{ - { R"(b)"sv, 1 }, - } }, - } }, - { R"(c)"sv, - toml::table{ - { R"(a)"sv, - toml::table{ - { R"(b)"sv, 1 }, - } }, - } }, - { R"(d)"sv, - toml::table{ - { R"(a)"sv, - toml::table{ - { R"(b)"sv, 1 }, - } }, - } }, - { R"(e)"sv, - toml::table{ - { R"(a)"sv, - toml::table{ - { R"(b)"sv, 1 }, - } }, - } }, - { R"(inline)"sv, - toml::table{ - { R"(a)"sv, - toml::table{ - { R"(b)"sv, 42 }, - } }, - } }, - { R"(many)"sv, - toml::table{ - { R"(dots)"sv, - toml::table{ - { R"(here)"sv, - toml::table{ - { R"(dot)"sv, - toml::table{ - { R"(dot)"sv, - toml::table{ - { R"(dot)"sv, - toml::table{ - { R"(a)"sv, - toml::table{ - { R"(b)"sv, - toml::table{ - { R"(c)"sv, 1 }, - { R"(d)"sv, 2 }, - } }, - } }, - } }, - } }, - } }, - } }, - } }, - } }, - { R"(tbl)"sv, - toml::table{ - { R"(a)"sv, - toml::table{ - { R"(b)"sv, - toml::table{ - { R"(c)"sv, - toml::table{ - { R"(d)"sv, - toml::table{ - { R"(e)"sv, 1 }, - } }, - } }, - } }, - } }, - { R"(x)"sv, - toml::table{ - { R"(a)"sv, - toml::table{ - { R"(b)"sv, - toml::table{ - { R"(c)"sv, - toml::table{ - { R"(d)"sv, - toml::table{ - { R"(e)"sv, 1 }, - } }, - } }, - } }, - } }, - } }, - } }, - }; - REQUIRE(tbl == expected); - }); - -#endif // !TOML_MSVC - - parsing_should_succeed(FILE_LINE_ARGS, - integer_integer, - [](toml::table&& tbl) // integer-integer - { - const auto expected = toml::table{ - { R"(answer)"sv, 42 }, - { R"(neganswer)"sv, -42 }, - { R"(posanswer)"sv, 42 }, - { R"(zero)"sv, 0 }, - }; - REQUIRE(tbl == expected); - }); - - parsing_should_succeed( - FILE_LINE_ARGS, - integer_literals, - [](toml::table&& tbl) // integer-literals - { - const auto expected = toml::table{ - { R"(bin1)"sv, 214 }, { R"(bin2)"sv, 5 }, { R"(hex1)"sv, 3735928559 }, - { R"(hex2)"sv, 3735928559 }, { R"(hex3)"sv, 3735928559 }, { R"(hex4)"sv, 2439 }, - { R"(oct1)"sv, 342391 }, { R"(oct2)"sv, 493 }, { R"(oct3)"sv, 501 }, - }; - REQUIRE(tbl == expected); - }); - - parsing_should_succeed(FILE_LINE_ARGS, - integer_long, - [](toml::table&& tbl) // integer-long - { - const auto expected = toml::table{ - { R"(int64-max)"sv, std::numeric_limits::max() }, - { R"(int64-max-neg)"sv, std::numeric_limits::min() }, - }; - REQUIRE(tbl == expected); - }); - - parsing_should_succeed(FILE_LINE_ARGS, - integer_underscore, - [](toml::table&& tbl) // integer-underscore - { - const auto expected = toml::table{ - { R"(kilo)"sv, 1000 }, - { R"(x)"sv, 1111 }, - }; - REQUIRE(tbl == expected); - }); - - parsing_should_succeed(FILE_LINE_ARGS, - integer_zero, - [](toml::table&& tbl) // integer-zero - { - const auto expected = toml::table{ - { R"(a2)"sv, 0 }, { R"(a3)"sv, 0 }, { R"(b1)"sv, 0 }, { R"(b2)"sv, 0 }, - { R"(b3)"sv, 0 }, { R"(d1)"sv, 0 }, { R"(d2)"sv, 0 }, { R"(d3)"sv, 0 }, - { R"(h1)"sv, 0 }, { R"(h2)"sv, 0 }, { R"(h3)"sv, 0 }, { R"(o1)"sv, 0 }, - }; - REQUIRE(tbl == expected); - }); + }; + REQUIRE(tbl == expected); + }); + } #if UNICODE_LITERALS_OK - parsing_should_succeed(FILE_LINE_ARGS, - key_case_sensitive, - [](toml::table&& tbl) // key-case-sensitive - { - const auto expected = toml::table{ - { R"(Section)"sv, - toml::table{ - { R"(M)"sv, R"(latin letter M)"sv }, - { R"(name)"sv, R"(different section!!)"sv }, - { R"(Μ)"sv, R"(greek capital letter MU)"sv }, - { R"(μ)"sv, R"(greek small letter mu)"sv }, - } }, - { R"(sectioN)"sv, R"(NN)"sv }, - { R"(section)"sv, - toml::table{ - { R"(NAME)"sv, R"(upper)"sv }, - { R"(Name)"sv, R"(capitalized)"sv }, - { R"(name)"sv, R"(lower)"sv }, - } }, - }; - REQUIRE(tbl == expected); - }); - - parsing_should_succeed(FILE_LINE_ARGS, - key_escapes, - [](toml::table&& tbl) // key-escapes - { - const auto expected = toml::table{ - { R"( -)"sv, - R"(newline)"sv }, - { R"(")"sv, R"(just a quote)"sv }, - { R"("quoted")"sv, - toml::table{ - { R"(quote)"sv, true }, - } }, - { R"(a.b)"sv, - toml::table{ - { R"(À)"sv, toml::table{} }, - } }, - { "backsp\x08\x08"sv, toml::table{} }, - { R"(À)"sv, R"(latin capital letter A with grave)"sv }, - }; - REQUIRE(tbl == expected); - }); + SECTION("comment-nonascii") + { + parsing_should_succeed(FILE_LINE_ARGS, + comment_nonascii, + [](toml::table&& tbl) // comment-nonascii + { + const auto expected = toml::table{}; + REQUIRE(tbl == expected); + }); + } #endif // UNICODE_LITERALS_OK - parsing_should_succeed(FILE_LINE_ARGS, - key_dotted, - [](toml::table&& tbl) // key-dotted - { - const auto expected = toml::table{ - { R"(a)"sv, - toml::table{ - { R"(few)"sv, - toml::table{ - { R"(dots)"sv, - toml::table{ - { R"(polka)"sv, - toml::table{ - { R"(dance-with)"sv, R"(Dot)"sv }, - { R"(dot)"sv, R"(again?)"sv }, - } }, - } }, - } }, - } }, - { R"(arr)"sv, - toml::array{ + SECTION("datetime-datetime") + { + parsing_should_succeed(FILE_LINE_ARGS, + datetime_datetime, + [](toml::table&& tbl) // datetime-datetime + { + const auto expected = toml::table{ + { R"(lower)"sv, toml::date_time{ { 1987, 7, 5 }, { 17, 45 }, { 0, 0 } } }, + { R"(space)"sv, toml::date_time{ { 1987, 7, 5 }, { 17, 45 }, { 0, 0 } } }, + }; + REQUIRE(tbl == expected); + }); + } + + SECTION("datetime-local-date") + { + parsing_should_succeed(FILE_LINE_ARGS, + datetime_local_date, + [](toml::table&& tbl) // datetime-local-date + { + const auto expected = toml::table{ + { R"(bestdayever)"sv, toml::date{ 1987, 7, 5 } }, + }; + REQUIRE(tbl == expected); + }); + } + + SECTION("datetime-local-time") + { + parsing_should_succeed(FILE_LINE_ARGS, + datetime_local_time, + [](toml::table&& tbl) // datetime-local-time + { + const auto expected = toml::table{ + { R"(besttimeever)"sv, toml::time{ 17, 45 } }, + { R"(milliseconds)"sv, toml::time{ 10, 32, 0, 555000000 } }, + }; + REQUIRE(tbl == expected); + }); + } + + SECTION("datetime-local") + { + parsing_should_succeed(FILE_LINE_ARGS, + datetime_local, + [](toml::table&& tbl) // datetime-local + { + const auto expected = toml::table{ + { R"(local)"sv, toml::date_time{ { 1987, 7, 5 }, { 17, 45 } } }, + { R"(milli)"sv, toml::date_time{ { 1977, 12, 21 }, { 10, 32, 0, 555000000 } } }, + { R"(space)"sv, toml::date_time{ { 1987, 7, 5 }, { 17, 45 } } }, + }; + REQUIRE(tbl == expected); + }); + } + + SECTION("datetime-milliseconds") + { + parsing_should_succeed( + FILE_LINE_ARGS, + datetime_milliseconds, + [](toml::table&& tbl) // datetime-milliseconds + { + const auto expected = toml::table{ + { R"(utc1)"sv, toml::date_time{ { 1987, 7, 5 }, { 17, 45, 56, 123400000 }, { 0, 0 } } }, + { R"(utc2)"sv, toml::date_time{ { 1987, 7, 5 }, { 17, 45, 56, 600000000 }, { 0, 0 } } }, + { R"(wita1)"sv, toml::date_time{ { 1987, 7, 5 }, { 17, 45, 56, 123400000 }, { 8, 0 } } }, + { R"(wita2)"sv, toml::date_time{ { 1987, 7, 5 }, { 17, 45, 56, 600000000 }, { 8, 0 } } }, + }; + REQUIRE(tbl == expected); + }); + } + + SECTION("datetime-timezone") + { + parsing_should_succeed(FILE_LINE_ARGS, + datetime_timezone, + [](toml::table&& tbl) // datetime-timezone + { + const auto expected = toml::table{ + { R"(nzdt)"sv, toml::date_time{ { 1987, 7, 5 }, { 17, 45, 56 }, { 13, 0 } } }, + { R"(nzst)"sv, toml::date_time{ { 1987, 7, 5 }, { 17, 45, 56 }, { 12, 0 } } }, + { R"(pdt)"sv, toml::date_time{ { 1987, 7, 5 }, { 17, 45, 56 }, { -5, 0 } } }, + { R"(utc)"sv, toml::date_time{ { 1987, 7, 5 }, { 17, 45, 56 }, { 0, 0 } } }, + }; + REQUIRE(tbl == expected); + }); + } + +#if TOML_LANG_UNRELEASED + + SECTION("datetime-no-seconds") + { + parsing_should_succeed( + FILE_LINE_ARGS, + datetime_no_seconds, + [](toml::table&& tbl) // datetime-no-seconds + { + const auto expected = toml::table{ + { R"(without-seconds-1)"sv, toml::time{ 13, 37 } }, + { R"(without-seconds-2)"sv, toml::date_time{ { 1979, 5, 27 }, { 7, 32 }, { 0, 0 } } }, + { R"(without-seconds-3)"sv, toml::date_time{ { 1979, 5, 27 }, { 7, 32 }, { -7, 0 } } }, + { R"(without-seconds-4)"sv, toml::date_time{ { 1979, 5, 27 }, { 7, 32 } } }, + }; + REQUIRE(tbl == expected); + }); + } + +#endif // TOML_LANG_UNRELEASED + + SECTION("empty-file") + { + parsing_should_succeed(FILE_LINE_ARGS, + empty_file, + [](toml::table&& tbl) // empty-file + { + const auto expected = toml::table{}; + REQUIRE(tbl == expected); + }); + } + + SECTION("example") + { + parsing_should_succeed( + FILE_LINE_ARGS, + example, + [](toml::table&& tbl) // example + { + const auto expected = toml::table{ + { R"(best-day-ever)"sv, toml::date_time{ { 1987, 7, 5 }, { 17, 45 }, { 0, 0 } } }, + { R"(numtheory)"sv, + toml::table{ + { R"(boring)"sv, false }, + { R"(perfection)"sv, + toml::array{ + 6, + 28, + 496, + } }, + } }, + }; + REQUIRE(tbl == expected); + }); + } + + SECTION("float-exponent") + { + parsing_should_succeed(FILE_LINE_ARGS, + float_exponent, + [](toml::table&& tbl) // float-exponent + { + const auto expected = toml::table{ + { R"(lower)"sv, 300.0 }, { R"(minustenth)"sv, -0.1 }, + { R"(neg)"sv, 0.03 }, { R"(pointlower)"sv, 310.0 }, + { R"(pointupper)"sv, 310.0 }, { R"(pos)"sv, 300.0 }, + { R"(upper)"sv, 300.0 }, { R"(zero)"sv, 3.0 }, + }; + REQUIRE(tbl == expected); + }); + } + + SECTION("float-float") + { + parsing_should_succeed(FILE_LINE_ARGS, + float_float, + [](toml::table&& tbl) // float-float + { + const auto expected = toml::table{ + { R"(negpi)"sv, -3.14 }, + { R"(pi)"sv, 3.14 }, + { R"(pospi)"sv, 3.14 }, + { R"(zero-intpart)"sv, 0.123 }, + }; + REQUIRE(tbl == expected); + }); + } + + SECTION("float-inf-and-nan") + { + parsing_should_succeed(FILE_LINE_ARGS, + float_inf_and_nan, + [](toml::table&& tbl) // float-inf-and-nan + { + const auto expected = toml::table{ + { R"(infinity)"sv, std::numeric_limits::infinity() }, + { R"(infinity_neg)"sv, -std::numeric_limits::infinity() }, + { R"(infinity_plus)"sv, std::numeric_limits::infinity() }, + { R"(nan)"sv, std::numeric_limits::quiet_NaN() }, + { R"(nan_neg)"sv, std::numeric_limits::quiet_NaN() }, + { R"(nan_plus)"sv, std::numeric_limits::quiet_NaN() }, + }; + REQUIRE(tbl == expected); + }); + } + + SECTION("float-long") + { + parsing_should_succeed(FILE_LINE_ARGS, + float_long, + [](toml::table&& tbl) // float-long + { + const auto expected = toml::table{ + { R"(longpi)"sv, 3.141592653589793 }, + { R"(neglongpi)"sv, -3.141592653589793 }, + }; + REQUIRE(tbl == expected); + }); + } + + SECTION("float-underscore") + { + parsing_should_succeed(FILE_LINE_ARGS, + float_underscore, + [](toml::table&& tbl) // float-underscore + { + const auto expected = toml::table{ + { R"(after)"sv, 3141.5927 }, + { R"(before)"sv, 3141.5927 }, + { R"(exponent)"sv, 300000000000000.0 }, + }; + REQUIRE(tbl == expected); + }); + } + + SECTION("float-zero") + { + parsing_should_succeed(FILE_LINE_ARGS, + float_zero, + [](toml::table&& tbl) // float-zero + { + const auto expected = toml::table{ + { R"(zero)"sv, 0.0 }, + { R"(signed-pos)"sv, 0.0 }, + { R"(signed-neg)"sv, 0.0 }, + { R"(exponent)"sv, 0.0 }, + { R"(exponent-two-0)"sv, 0.0 }, + { R"(exponent-signed-pos)"sv, 0.0 }, + { R"(exponent-signed-neg)"sv, 0.0 }, + }; + REQUIRE(tbl == expected); + }); + } + + SECTION("implicit-and-explicit-after") + { + parsing_should_succeed(FILE_LINE_ARGS, + implicit_and_explicit_after, + [](toml::table&& tbl) // implicit-and-explicit-after + { + const auto expected = toml::table{ + { R"(a)"sv, toml::table{ - { R"(a)"sv, + { R"(b)"sv, toml::table{ - { R"(b)"sv, + { R"(c)"sv, toml::table{ - { R"(c)"sv, 1 }, - { R"(d)"sv, 2 }, + { R"(answer)"sv, 42 }, } }, } }, - }, + { R"(better)"sv, 43 }, + } }, + }; + REQUIRE(tbl == expected); + }); + } + + SECTION("implicit-and-explicit-before") + { + parsing_should_succeed(FILE_LINE_ARGS, + implicit_and_explicit_before, + [](toml::table&& tbl) // implicit-and-explicit-before + { + const auto expected = toml::table{ + { R"(a)"sv, toml::table{ - { R"(a)"sv, + { R"(b)"sv, toml::table{ - { R"(b)"sv, + { R"(c)"sv, toml::table{ - { R"(c)"sv, 3 }, - { R"(d)"sv, 4 }, + { R"(answer)"sv, 42 }, } }, } }, - }, - } }, - { R"(count)"sv, - toml::table{ - { R"(a)"sv, 1 }, - { R"(b)"sv, 2 }, - { R"(c)"sv, 3 }, - { R"(d)"sv, 4 }, - { R"(e)"sv, 5 }, - { R"(f)"sv, 6 }, - { R"(g)"sv, 7 }, - { R"(h)"sv, 8 }, - { R"(i)"sv, 9 }, - { R"(j)"sv, 10 }, - { R"(k)"sv, 11 }, - { R"(l)"sv, 12 }, - } }, - { R"(many)"sv, - toml::table{ - { R"(dots)"sv, - toml::table{ - { R"(here)"sv, - toml::table{ - { R"(dot)"sv, - toml::table{ - { R"(dot)"sv, - toml::table{ - { R"(dot)"sv, 42 }, - } }, - } }, - } }, - } }, - } }, - { R"(name)"sv, - toml::table{ - { R"(first)"sv, R"(Arthur)"sv }, - { R"(last)"sv, R"(Dent)"sv }, - } }, - { R"(tbl)"sv, - toml::table{ - { R"(a)"sv, - toml::table{ - { R"(b)"sv, - toml::table{ - { R"(c)"sv, 42.666 }, - } }, - } }, - } }, - }; - REQUIRE(tbl == expected); - }); + { R"(better)"sv, 43 }, + } }, + }; + REQUIRE(tbl == expected); + }); + } - parsing_should_succeed(FILE_LINE_ARGS, - key_empty, - [](toml::table&& tbl) // key-empty - { - const auto expected = toml::table{ - { ""sv, R"(blank)"sv }, - }; - REQUIRE(tbl == expected); - }); + SECTION("implicit-groups") + { + parsing_should_succeed(FILE_LINE_ARGS, + implicit_groups, + [](toml::table&& tbl) // implicit-groups + { + const auto expected = toml::table{ + { R"(a)"sv, + toml::table{ + { R"(b)"sv, + toml::table{ + { R"(c)"sv, + toml::table{ + { R"(answer)"sv, 42 }, + } }, + } }, + } }, + }; + REQUIRE(tbl == expected); + }); + } - parsing_should_succeed(FILE_LINE_ARGS, - key_equals_nospace, - [](toml::table&& tbl) // key-equals-nospace - { - const auto expected = toml::table{ - { R"(answer)"sv, 42 }, - }; - REQUIRE(tbl == expected); - }); + SECTION("inline-table-array") + { + parsing_should_succeed(FILE_LINE_ARGS, + inline_table_array, + [](toml::table&& tbl) // inline-table-array + { + const auto expected = toml::table{ + { R"(people)"sv, + toml::array{ + toml::table{ + { R"(first_name)"sv, R"(Bruce)"sv }, + { R"(last_name)"sv, R"(Springsteen)"sv }, + }, + toml::table{ + { R"(first_name)"sv, R"(Eric)"sv }, + { R"(last_name)"sv, R"(Clapton)"sv }, + }, + toml::table{ + { R"(first_name)"sv, R"(Bob)"sv }, + { R"(last_name)"sv, R"(Seger)"sv }, + }, + } }, + }; + REQUIRE(tbl == expected); + }); + } - parsing_should_succeed(FILE_LINE_ARGS, - key_numeric_dotted, - [](toml::table&& tbl) // key-numeric-dotted - { - const auto expected = toml::table{ - { R"(1)"sv, - toml::table{ - { R"(2)"sv, 3 }, - } }, - }; - REQUIRE(tbl == expected); - }); + SECTION("inline-table-bool") + { + parsing_should_succeed(FILE_LINE_ARGS, + inline_table_bool, + [](toml::table&& tbl) // inline-table-bool + { + const auto expected = toml::table{ + { R"(a)"sv, + toml::table{ + { R"(a)"sv, true }, + { R"(b)"sv, false }, + } }, + }; + REQUIRE(tbl == expected); + }); + } - parsing_should_succeed(FILE_LINE_ARGS, - key_numeric, - [](toml::table&& tbl) // key-numeric - { - const auto expected = toml::table{ - { R"(1)"sv, 1 }, - }; - REQUIRE(tbl == expected); - }); + SECTION("inline-table-empty") + { + parsing_should_succeed(FILE_LINE_ARGS, + inline_table_empty, + [](toml::table&& tbl) // inline-table-empty + { + const auto expected = toml::table{ + { R"(empty1)"sv, toml::table{} }, + { R"(empty2)"sv, toml::table{} }, + { R"(empty_in_array)"sv, + toml::array{ + toml::table{ + { R"(not_empty)"sv, 1 }, + }, + toml::table{}, + } }, + { R"(empty_in_array2)"sv, + toml::array{ + toml::table{}, + toml::table{ + { R"(not_empty)"sv, 1 }, + }, + } }, + { R"(many_empty)"sv, + toml::array{ + toml::table{}, + toml::table{}, + toml::table{}, + } }, + { R"(nested_empty)"sv, + toml::table{ + { R"(empty)"sv, toml::table{} }, + } }, + }; + REQUIRE(tbl == expected); + }); + } - parsing_should_succeed(FILE_LINE_ARGS, - key_quoted_dots, - [](toml::table&& tbl) // key-quoted-dots - { - const auto expected = toml::table{ - { R"(plain)"sv, 1 }, - { R"(plain_table)"sv, - toml::table{ - { R"(plain)"sv, 3 }, - { R"(with.dot)"sv, 4 }, - } }, - { R"(table)"sv, - toml::table{ - { R"(withdot)"sv, - toml::table{ - { R"(key.with.dots)"sv, 6 }, - { R"(plain)"sv, 5 }, - } }, - } }, - { R"(with.dot)"sv, 2 }, - }; - REQUIRE(tbl == expected); - }); + SECTION("inline-table-end-in-bool") + { + parsing_should_succeed(FILE_LINE_ARGS, + inline_table_end_in_bool, + [](toml::table&& tbl) // inline-table-end-in-bool + { + const auto expected = toml::table{ + { R"(black)"sv, + toml::table{ + { R"(allow_prereleases)"sv, true }, + { R"(python)"sv, R"(>3.6)"sv }, + { R"(version)"sv, R"(>=18.9b0)"sv }, + } }, + }; + REQUIRE(tbl == expected); + }); + } - parsing_should_succeed(FILE_LINE_ARGS, - key_space, - [](toml::table&& tbl) // key-space - { - const auto expected = toml::table{ - { R"( c d )"sv, 2 }, - { R"( tbl )"sv, - toml::table{ - { R"( tab tab )"sv, R"(tab)"sv }, - } }, - { R"(a b)"sv, 1 }, - }; - REQUIRE(tbl == expected); - }); + SECTION("inline-table-inline-table") + { + parsing_should_succeed(FILE_LINE_ARGS, + inline_table_inline_table, + [](toml::table&& tbl) // inline-table-inline-table + { + const auto expected = toml::table{ + { R"(name)"sv, + toml::table{ + { R"(first)"sv, R"(Tom)"sv }, + { R"(last)"sv, R"(Preston-Werner)"sv }, + } }, + { R"(point)"sv, + toml::table{ + { R"(x)"sv, 1 }, + { R"(y)"sv, 2 }, + } }, + { R"(simple)"sv, + toml::table{ + { R"(a)"sv, 1 }, + } }, + { R"(str-key)"sv, + toml::table{ + { R"(a)"sv, 1 }, + } }, + { R"(table-array)"sv, + toml::array{ + toml::table{ + { R"(a)"sv, 1 }, + }, + toml::table{ + { R"(b)"sv, 2 }, + }, + } }, + }; + REQUIRE(tbl == expected); + }); + } - parsing_should_succeed(FILE_LINE_ARGS, - key_special_chars, - [](toml::table&& tbl) // key-special-chars - { - const auto expected = toml::table{ - { R"(=~!@$^&*()_+-`1234567890[]|/?><.,;:'=)"sv, 1 }, - }; - REQUIRE(tbl == expected); - }); - - parsing_should_succeed(FILE_LINE_ARGS, - key_special_word, - [](toml::table&& tbl) // key-special-word - { - const auto expected = toml::table{ - { R"(false)"sv, false }, - { R"(inf)"sv, 100000000 }, - { R"(nan)"sv, R"(ceci n'est pas un nombre)"sv }, - { R"(true)"sv, 1 }, - }; - REQUIRE(tbl == expected); - }); - - parsing_should_succeed(FILE_LINE_ARGS, - newline_crlf, - [](toml::table&& tbl) // newline-crlf - { - const auto expected = toml::table{ - { R"(newline)"sv, R"(crlf)"sv }, - { R"(os)"sv, R"(DOS)"sv }, - }; - REQUIRE(tbl == expected); - }); - - parsing_should_succeed(FILE_LINE_ARGS, - newline_lf, - [](toml::table&& tbl) // newline-lf - { - const auto expected = toml::table{ - { R"(newline)"sv, R"(lf)"sv }, - { R"(os)"sv, R"(unix)"sv }, - }; - REQUIRE(tbl == expected); - }); - - parsing_should_succeed(FILE_LINE_ARGS, - spec_example_1_compact, - [](toml::table&& tbl) // spec-example-1-compact - { - const auto expected = toml::table{ - { R"(clients)"sv, - toml::table{ - { R"(data)"sv, - toml::array{ - toml::array{ - R"(gamma)"sv, - R"(delta)"sv, - }, - toml::array{ - 1, - 2, - }, - } }, - { R"(hosts)"sv, - toml::array{ - R"(alpha)"sv, - R"(omega)"sv, - } }, - } }, - { R"(database)"sv, - toml::table{ - { R"(connection_max)"sv, 5000 }, - { R"(enabled)"sv, true }, - { R"(ports)"sv, - toml::array{ - 8001, - 8001, - 8002, - } }, - { R"(server)"sv, R"(192.168.1.1)"sv }, - } }, - { R"(owner)"sv, - toml::table{ - { R"(dob)"sv, toml::date_time{ { 1979, 5, 27 }, { 7, 32 }, { -8, 0 } } }, - { R"(name)"sv, R"(Lance Uppercut)"sv }, - } }, - { R"(servers)"sv, - toml::table{ - { R"(alpha)"sv, - toml::table{ - { R"(dc)"sv, R"(eqdc10)"sv }, - { R"(ip)"sv, R"(10.0.0.1)"sv }, - } }, - { R"(beta)"sv, - toml::table{ - { R"(dc)"sv, R"(eqdc10)"sv }, - { R"(ip)"sv, R"(10.0.0.2)"sv }, - } }, - } }, - { R"(title)"sv, R"(TOML Example)"sv }, - }; - REQUIRE(tbl == expected); - }); - - parsing_should_succeed(FILE_LINE_ARGS, - spec_example_1, - [](toml::table&& tbl) // spec-example-1 - { - const auto expected = toml::table{ - { R"(clients)"sv, - toml::table{ - { R"(data)"sv, - toml::array{ - toml::array{ - R"(gamma)"sv, - R"(delta)"sv, - }, - toml::array{ - 1, - 2, - }, - } }, - { R"(hosts)"sv, - toml::array{ - R"(alpha)"sv, - R"(omega)"sv, - } }, - } }, - { R"(database)"sv, - toml::table{ - { R"(connection_max)"sv, 5000 }, - { R"(enabled)"sv, true }, - { R"(ports)"sv, - toml::array{ - 8001, - 8001, - 8002, - } }, - { R"(server)"sv, R"(192.168.1.1)"sv }, - } }, - { R"(owner)"sv, - toml::table{ - { R"(dob)"sv, toml::date_time{ { 1979, 5, 27 }, { 7, 32 }, { -8, 0 } } }, - { R"(name)"sv, R"(Lance Uppercut)"sv }, - } }, - { R"(servers)"sv, - toml::table{ - { R"(alpha)"sv, - toml::table{ - { R"(dc)"sv, R"(eqdc10)"sv }, - { R"(ip)"sv, R"(10.0.0.1)"sv }, - } }, - { R"(beta)"sv, - toml::table{ - { R"(dc)"sv, R"(eqdc10)"sv }, - { R"(ip)"sv, R"(10.0.0.2)"sv }, - } }, - } }, - { R"(title)"sv, R"(TOML Example)"sv }, - }; - REQUIRE(tbl == expected); - }); - - parsing_should_succeed(FILE_LINE_ARGS, - string_double_quote_escape, - [](toml::table&& tbl) // string-double-quote-escape - { - const auto expected = toml::table{ - { R"(test)"sv, R"("one")"sv }, - }; - REQUIRE(tbl == expected); - }); - - parsing_should_succeed(FILE_LINE_ARGS, - string_empty, - [](toml::table&& tbl) // string-empty - { - const auto expected = toml::table{ - { R"(answer)"sv, ""sv }, - }; - REQUIRE(tbl == expected); - }); - - parsing_should_succeed(FILE_LINE_ARGS, - string_escaped_escape, - [](toml::table&& tbl) // string-escaped-escape - { - const auto expected = toml::table{ - { R"(answer)"sv, R"(\x64)"sv }, - }; - REQUIRE(tbl == expected); - }); - - parsing_should_succeed(FILE_LINE_ARGS, - string_escapes, - [](toml::table&& tbl) // string-escapes - { - const auto expected = toml::table{ - { R"(backslash)"sv, R"(This string has a \ backslash character.)"sv }, - { R"(backspace)"sv, "This string has a \x08 backspace character."sv }, - { R"(carriage)"sv, "This string has a \r carriage return character."sv }, - { R"(delete)"sv, "This string has a \x7F delete control code."sv }, - { R"(formfeed)"sv, "This string has a \f form feed character."sv }, - { R"(newline)"sv, R"(This string has a - new line character.)"sv }, - { R"(notunicode1)"sv, R"(This string does not have a unicode \u escape.)"sv }, - { R"(notunicode2)"sv, R"(This string does not have a unicode \u escape.)"sv }, - { R"(notunicode3)"sv, R"(This string does not have a unicode \u0075 escape.)"sv }, - { R"(notunicode4)"sv, R"(This string does not have a unicode \u escape.)"sv }, - { R"(quote)"sv, R"(This string has a " quote character.)"sv }, - { R"(tab)"sv, R"(This string has a tab character.)"sv }, - { R"(unitseparator)"sv, "This string has a \x1F unit separator control code."sv }, - }; - REQUIRE(tbl == expected); - }); - - parsing_should_succeed(FILE_LINE_ARGS, - string_multiline_escaped_crlf, - [](toml::table&& tbl) // string-multiline-escaped-crlf - { - const auto expected = toml::table{ - { R"(0)"sv, ""sv }, - }; - REQUIRE(tbl == expected); - }); - - parsing_should_succeed(FILE_LINE_ARGS, - string_multiline_quotes, - [](toml::table&& tbl) // string-multiline-quotes - { - const auto expected = toml::table{ - { R"(escaped)"sv, R"(lol""")"sv }, - { R"(lit_one)"sv, R"('one quote')"sv }, - { R"(lit_one_space)"sv, R"( 'one quote' )"sv }, - { R"(lit_two)"sv, R"(''two quotes'')"sv }, - { R"(lit_two_space)"sv, R"( ''two quotes'' )"sv }, - { R"(mismatch1)"sv, R"(aaa'''bbb)"sv }, - { R"(mismatch2)"sv, R"(aaa"""bbb)"sv }, - { R"(one)"sv, R"("one quote")"sv }, - { R"(one_space)"sv, R"( "one quote" )"sv }, - { R"(two)"sv, R"(""two quotes"")"sv }, - { R"(two_space)"sv, R"( ""two quotes"" )"sv }, - }; - REQUIRE(tbl == expected); - }); - - parsing_should_succeed(FILE_LINE_ARGS, - string_multiline, - [](toml::table&& tbl) // string-multiline - { - const auto expected = toml::table{ - { R"(equivalent_one)"sv, R"(The quick brown fox jumps over the lazy dog.)"sv }, - { R"(equivalent_three)"sv, R"(The quick brown fox jumps over the lazy dog.)"sv }, - { R"(equivalent_two)"sv, R"(The quick brown fox jumps over the lazy dog.)"sv }, - { R"(escape-bs-1)"sv, R"(a \ -b)"sv }, - { R"(escape-bs-2)"sv, R"(a \b)"sv }, - { R"(escape-bs-3)"sv, R"(a \\ - b)"sv }, - { R"(keep-ws-before)"sv, R"(a b)"sv }, - { R"(multiline_empty_four)"sv, ""sv }, - { R"(multiline_empty_one)"sv, ""sv }, - { R"(multiline_empty_three)"sv, ""sv }, - { R"(multiline_empty_two)"sv, ""sv }, - { R"(no-space)"sv, R"(ab)"sv }, - { R"(whitespace-after-bs)"sv, R"(The quick brown fox jumps over the lazy dog.)"sv }, - }; - REQUIRE(tbl == expected); - }); - - parsing_should_succeed(FILE_LINE_ARGS, - string_nl, - [](toml::table&& tbl) // string-nl - { - const auto expected = toml::table{ - { R"(lit_nl_end)"sv, R"(value\n)"sv }, - { R"(lit_nl_mid)"sv, R"(val\nue)"sv }, - { R"(lit_nl_uni)"sv, R"(val\ue)"sv }, - { R"(nl_end)"sv, R"(value + SECTION("inline-table-multiline") + { + parsing_should_succeed(FILE_LINE_ARGS, + inline_table_multiline, + [](toml::table&& tbl) // inline-table-multiline + { + const auto expected = toml::table{ + { R"(tbl_multiline)"sv, + toml::table{ + { R"(a)"sv, 1 }, + { R"(b)"sv, R"(multiline )"sv }, - { R"(nl_mid)"sv, R"(val -ue)"sv }, - }; - REQUIRE(tbl == expected); - }); + { R"(c)"sv, R"(and yet +another line)"sv }, + { R"(d)"sv, 4 }, + } }, + }; + REQUIRE(tbl == expected); + }); + } - parsing_should_succeed(FILE_LINE_ARGS, - string_raw_multiline, - [](toml::table&& tbl) // string-raw-multiline - { - const auto expected = toml::table{ - { R"(firstnl)"sv, R"(This string has a ' quote character.)"sv }, - { R"(multiline)"sv, R"(This string + SECTION("inline-table-nest") + { + parsing_should_succeed(FILE_LINE_ARGS, + inline_table_nest, + [](toml::table&& tbl) // inline-table-nest + { + const auto expected = toml::table{ + { R"(arr_arr_tbl_empty)"sv, + toml::array{ + toml::inserter{ toml::array{ + toml::table{}, + } }, + } }, + { R"(arr_arr_tbl_val)"sv, + toml::array{ + toml::inserter{ toml::array{ + toml::table{ + { R"(one)"sv, 1 }, + }, + } }, + } }, + { R"(arr_arr_tbls)"sv, + toml::array{ + toml::inserter{ toml::array{ + toml::table{ + { R"(one)"sv, 1 }, + }, + toml::table{ + { R"(two)"sv, 2 }, + }, + } }, + } }, + { R"(arr_tbl_tbl)"sv, + toml::array{ + toml::table{ + { R"(tbl)"sv, + toml::table{ + { R"(one)"sv, 1 }, + } }, + }, + } }, + { R"(tbl_arr_tbl)"sv, + toml::table{ + { R"(arr_tbl)"sv, + toml::array{ + toml::table{ + { R"(one)"sv, 1 }, + }, + } }, + } }, + { R"(tbl_tbl_empty)"sv, + toml::table{ + { R"(tbl_0)"sv, toml::table{} }, + } }, + { R"(tbl_tbl_val)"sv, + toml::table{ + { R"(tbl_1)"sv, + toml::table{ + { R"(one)"sv, 1 }, + } }, + } }, + }; + REQUIRE(tbl == expected); + }); + } + +#if !TOML_MSVC + + SECTION("inline-table-key-dotted") + { + parsing_should_succeed(FILE_LINE_ARGS, + inline_table_key_dotted, + [](toml::table&& tbl) // inline-table-key-dotted + { + const auto expected = toml::table{ + { R"(a)"sv, + toml::table{ + { R"(a)"sv, + toml::table{ + { R"(b)"sv, 1 }, + } }, + } }, + { R"(arr)"sv, + toml::array{ + toml::table{ + { R"(T)"sv, + toml::table{ + { R"(a)"sv, + toml::table{ + { R"(b)"sv, 1 }, + } }, + } }, + { R"(t)"sv, + toml::table{ + { R"(a)"sv, + toml::table{ + { R"(b)"sv, 1 }, + } }, + } }, + }, + toml::table{ + { R"(T)"sv, + toml::table{ + { R"(a)"sv, + toml::table{ + { R"(b)"sv, 2 }, + } }, + } }, + { R"(t)"sv, + toml::table{ + { R"(a)"sv, + toml::table{ + { R"(b)"sv, 2 }, + } }, + } }, + }, + } }, + { R"(b)"sv, + toml::table{ + { R"(a)"sv, + toml::table{ + { R"(b)"sv, 1 }, + } }, + } }, + { R"(c)"sv, + toml::table{ + { R"(a)"sv, + toml::table{ + { R"(b)"sv, 1 }, + } }, + } }, + { R"(d)"sv, + toml::table{ + { R"(a)"sv, + toml::table{ + { R"(b)"sv, 1 }, + } }, + } }, + { R"(e)"sv, + toml::table{ + { R"(a)"sv, + toml::table{ + { R"(b)"sv, 1 }, + } }, + } }, + { R"(inline)"sv, + toml::table{ + { R"(a)"sv, + toml::table{ + { R"(b)"sv, 42 }, + } }, + } }, + { R"(many)"sv, + toml::table{ + { R"(dots)"sv, + toml::table{ + { R"(here)"sv, + toml::table{ + { R"(dot)"sv, + toml::table{ + { R"(dot)"sv, + toml::table{ + { R"(dot)"sv, + toml::table{ + { R"(a)"sv, + toml::table{ + { R"(b)"sv, + toml::table{ + { R"(c)"sv, 1 }, + { R"(d)"sv, 2 }, + } }, + } }, + } }, + } }, + } }, + } }, + } }, + } }, + { R"(tbl)"sv, + toml::table{ + { R"(a)"sv, + toml::table{ + { R"(b)"sv, + toml::table{ + { R"(c)"sv, + toml::table{ + { R"(d)"sv, + toml::table{ + { R"(e)"sv, 1 }, + } }, + } }, + } }, + } }, + { R"(x)"sv, + toml::table{ + { R"(a)"sv, + toml::table{ + { R"(b)"sv, + toml::table{ + { R"(c)"sv, + toml::table{ + { R"(d)"sv, + toml::table{ + { R"(e)"sv, 1 }, + } }, + } }, + } }, + } }, + } }, + } }, + }; + REQUIRE(tbl == expected); + }); + } + +#endif // !TOML_MSVC + +#if TOML_LANG_UNRELEASED + + SECTION("inline-table-newline") + { + parsing_should_succeed(FILE_LINE_ARGS, + inline_table_newline, + [](toml::table&& tbl) // inline-table-newline + { + const auto expected = toml::table{ + { R"(tbl-1)"sv, + toml::table{ + { R"(1)"sv, 2 }, + { R"(arr)"sv, + toml::array{ + 1, + 2, + 3, + } }, + { R"(hello)"sv, R"(world)"sv }, + { R"(tbl)"sv, + toml::table{ + { R"(k)"sv, 1 }, + } }, + } }, + { R"(tbl-2)"sv, + toml::table{ + { R"(k)"sv, R"( Hello + )"sv }, + } }, + { R"(trailing-comma-1)"sv, + toml::table{ + { R"(c)"sv, 1 }, + } }, + { R"(trailing-comma-2)"sv, + toml::table{ + { R"(c)"sv, 1 }, + } }, + }; + REQUIRE(tbl == expected); + }); + } + +#endif // TOML_LANG_UNRELEASED + + SECTION("integer-integer") + { + parsing_should_succeed(FILE_LINE_ARGS, + integer_integer, + [](toml::table&& tbl) // integer-integer + { + const auto expected = toml::table{ + { R"(answer)"sv, 42 }, + { R"(neganswer)"sv, -42 }, + { R"(posanswer)"sv, 42 }, + { R"(zero)"sv, 0 }, + }; + REQUIRE(tbl == expected); + }); + } + + SECTION("integer-literals") + { + parsing_should_succeed( + FILE_LINE_ARGS, + integer_literals, + [](toml::table&& tbl) // integer-literals + { + const auto expected = toml::table{ + { R"(bin1)"sv, 214 }, { R"(bin2)"sv, 5 }, { R"(hex1)"sv, 3735928559 }, + { R"(hex2)"sv, 3735928559 }, { R"(hex3)"sv, 3735928559 }, { R"(hex4)"sv, 2439 }, + { R"(oct1)"sv, 342391 }, { R"(oct2)"sv, 493 }, { R"(oct3)"sv, 501 }, + }; + REQUIRE(tbl == expected); + }); + } + + SECTION("integer-long") + { + parsing_should_succeed(FILE_LINE_ARGS, + integer_long, + [](toml::table&& tbl) // integer-long + { + const auto expected = toml::table{ + { R"(int64-max)"sv, std::numeric_limits::max() }, + { R"(int64-max-neg)"sv, std::numeric_limits::min() }, + }; + REQUIRE(tbl == expected); + }); + } + + SECTION("integer-underscore") + { + parsing_should_succeed(FILE_LINE_ARGS, + integer_underscore, + [](toml::table&& tbl) // integer-underscore + { + const auto expected = toml::table{ + { R"(kilo)"sv, 1000 }, + { R"(x)"sv, 1111 }, + }; + REQUIRE(tbl == expected); + }); + } + + SECTION("integer-zero") + { + parsing_should_succeed(FILE_LINE_ARGS, + integer_zero, + [](toml::table&& tbl) // integer-zero + { + const auto expected = toml::table{ + { R"(a2)"sv, 0 }, { R"(a3)"sv, 0 }, { R"(b1)"sv, 0 }, { R"(b2)"sv, 0 }, + { R"(b3)"sv, 0 }, { R"(d1)"sv, 0 }, { R"(d2)"sv, 0 }, { R"(d3)"sv, 0 }, + { R"(h1)"sv, 0 }, { R"(h2)"sv, 0 }, { R"(h3)"sv, 0 }, { R"(o1)"sv, 0 }, + }; + REQUIRE(tbl == expected); + }); + } + +#if UNICODE_LITERALS_OK + + SECTION("key-case-sensitive") + { + parsing_should_succeed(FILE_LINE_ARGS, + key_case_sensitive, + [](toml::table&& tbl) // key-case-sensitive + { + const auto expected = toml::table{ + { R"(Section)"sv, + toml::table{ + { R"(M)"sv, R"(latin letter M)"sv }, + { R"(name)"sv, R"(different section!!)"sv }, + { R"(Μ)"sv, R"(greek capital letter MU)"sv }, + { R"(μ)"sv, R"(greek small letter mu)"sv }, + } }, + { R"(sectioN)"sv, R"(NN)"sv }, + { R"(section)"sv, + toml::table{ + { R"(NAME)"sv, R"(upper)"sv }, + { R"(Name)"sv, R"(capitalized)"sv }, + { R"(name)"sv, R"(lower)"sv }, + } }, + }; + REQUIRE(tbl == expected); + }); + } + + SECTION("key-escapes") + { + parsing_should_succeed(FILE_LINE_ARGS, + key_escapes, + [](toml::table&& tbl) // key-escapes + { + const auto expected = toml::table{ + { R"( +)"sv, + R"(newline)"sv }, + { R"(")"sv, R"(just a quote)"sv }, + { R"("quoted")"sv, + toml::table{ + { R"(quote)"sv, true }, + } }, + { R"(a.b)"sv, + toml::table{ + { R"(À)"sv, toml::table{} }, + } }, + { "backsp\x08\x08"sv, toml::table{} }, + { R"(À)"sv, R"(latin capital letter A with grave)"sv }, + }; + REQUIRE(tbl == expected); + }); + } + + SECTION("key-quoted-unicode") + { + parsing_should_succeed(FILE_LINE_ARGS, + key_quoted_unicode, + [](toml::table&& tbl) // key-quoted-unicode + { + const auto expected = toml::table{ + { "\x00"sv, R"(null)"sv }, + { R"(\u0000)"sv, R"(different key)"sv }, + { "\x08 \f A \x7F € ÿ ퟿  ￿ 𐀀 􏿿"sv, R"(escaped key)"sv }, + { R"(~ € ÿ ퟿  ￿ 𐀀 􏿿)"sv, R"(basic key)"sv }, + { R"(l ~ € ÿ ퟿  ￿ 𐀀 􏿿)"sv, R"(literal key)"sv }, + }; + REQUIRE(tbl == expected); + }); + } + +#endif // UNICODE_LITERALS_OK + + SECTION("key-dotted-empty") + { + parsing_should_succeed(FILE_LINE_ARGS, + key_dotted_empty, + [](toml::table&& tbl) // key-dotted-empty + { + const auto expected = toml::table{ + { ""sv, + toml::table{ + { R"(x)"sv, R"(empty.x)"sv }, + } }, + { R"(x)"sv, + toml::table{ + { ""sv, R"(x.empty)"sv }, + } }, + { R"(a)"sv, + toml::table{ + { ""sv, + toml::table{ + { ""sv, R"(empty.empty)"sv }, + } }, + } }, + }; + REQUIRE(tbl == expected); + }); + } + + SECTION("key-dotted") + { + parsing_should_succeed(FILE_LINE_ARGS, + key_dotted, + [](toml::table&& tbl) // key-dotted + { + const auto expected = toml::table{ + { R"(a)"sv, + toml::table{ + { R"(few)"sv, + toml::table{ + { R"(dots)"sv, + toml::table{ + { R"(polka)"sv, + toml::table{ + { R"(dance-with)"sv, R"(Dot)"sv }, + { R"(dot)"sv, R"(again?)"sv }, + } }, + } }, + } }, + } }, + { R"(arr)"sv, + toml::array{ + toml::table{ + { R"(a)"sv, + toml::table{ + { R"(b)"sv, + toml::table{ + { R"(c)"sv, 1 }, + { R"(d)"sv, 2 }, + } }, + } }, + }, + toml::table{ + { R"(a)"sv, + toml::table{ + { R"(b)"sv, + toml::table{ + { R"(c)"sv, 3 }, + { R"(d)"sv, 4 }, + } }, + } }, + }, + } }, + { R"(count)"sv, + toml::table{ + { R"(a)"sv, 1 }, + { R"(b)"sv, 2 }, + { R"(c)"sv, 3 }, + { R"(d)"sv, 4 }, + { R"(e)"sv, 5 }, + { R"(f)"sv, 6 }, + { R"(g)"sv, 7 }, + { R"(h)"sv, 8 }, + { R"(i)"sv, 9 }, + { R"(j)"sv, 10 }, + { R"(k)"sv, 11 }, + { R"(l)"sv, 12 }, + } }, + { R"(many)"sv, + toml::table{ + { R"(dots)"sv, + toml::table{ + { R"(here)"sv, + toml::table{ + { R"(dot)"sv, + toml::table{ + { R"(dot)"sv, + toml::table{ + { R"(dot)"sv, 42 }, + } }, + } }, + } }, + } }, + } }, + { R"(name)"sv, + toml::table{ + { R"(first)"sv, R"(Arthur)"sv }, + { R"(last)"sv, R"(Dent)"sv }, + } }, + { R"(tbl)"sv, + toml::table{ + { R"(a)"sv, + toml::table{ + { R"(b)"sv, + toml::table{ + { R"(c)"sv, 42.666 }, + } }, + } }, + } }, + }; + REQUIRE(tbl == expected); + }); + } + + SECTION("key-empty") + { + parsing_should_succeed(FILE_LINE_ARGS, + key_empty, + [](toml::table&& tbl) // key-empty + { + const auto expected = toml::table{ + { ""sv, R"(blank)"sv }, + }; + REQUIRE(tbl == expected); + }); + } + + SECTION("key-equals-nospace") + { + parsing_should_succeed(FILE_LINE_ARGS, + key_equals_nospace, + [](toml::table&& tbl) // key-equals-nospace + { + const auto expected = toml::table{ + { R"(answer)"sv, 42 }, + }; + REQUIRE(tbl == expected); + }); + } + + SECTION("key-numeric-dotted") + { + parsing_should_succeed(FILE_LINE_ARGS, + key_numeric_dotted, + [](toml::table&& tbl) // key-numeric-dotted + { + const auto expected = toml::table{ + { R"(1)"sv, + toml::table{ + { R"(2)"sv, 3 }, + } }, + }; + REQUIRE(tbl == expected); + }); + } + + SECTION("key-numeric") + { + parsing_should_succeed(FILE_LINE_ARGS, + key_numeric, + [](toml::table&& tbl) // key-numeric + { + const auto expected = toml::table{ + { R"(1)"sv, 1 }, + }; + REQUIRE(tbl == expected); + }); + } + + SECTION("key-quoted-dots") + { + parsing_should_succeed(FILE_LINE_ARGS, + key_quoted_dots, + [](toml::table&& tbl) // key-quoted-dots + { + const auto expected = toml::table{ + { R"(plain)"sv, 1 }, + { R"(plain_table)"sv, + toml::table{ + { R"(plain)"sv, 3 }, + { R"(with.dot)"sv, 4 }, + } }, + { R"(table)"sv, + toml::table{ + { R"(withdot)"sv, + toml::table{ + { R"(key.with.dots)"sv, 6 }, + { R"(plain)"sv, 5 }, + } }, + } }, + { R"(with.dot)"sv, 2 }, + }; + REQUIRE(tbl == expected); + }); + } + + SECTION("key-space") + { + parsing_should_succeed(FILE_LINE_ARGS, + key_space, + [](toml::table&& tbl) // key-space + { + const auto expected = toml::table{ + { R"( c d )"sv, 2 }, + { R"( tbl )"sv, + toml::table{ + { R"( tab tab )"sv, R"(tab)"sv }, + } }, + { R"(a b)"sv, 1 }, + }; + REQUIRE(tbl == expected); + }); + } + + SECTION("key-special-chars") + { + parsing_should_succeed(FILE_LINE_ARGS, + key_special_chars, + [](toml::table&& tbl) // key-special-chars + { + const auto expected = toml::table{ + { R"(=~!@$^&*()_+-`1234567890[]|/?><.,;:'=)"sv, 1 }, + }; + REQUIRE(tbl == expected); + }); + } + + SECTION("key-special-word") + { + parsing_should_succeed(FILE_LINE_ARGS, + key_special_word, + [](toml::table&& tbl) // key-special-word + { + const auto expected = toml::table{ + { R"(false)"sv, false }, + { R"(inf)"sv, 100000000 }, + { R"(nan)"sv, R"(ceci n'est pas un nombre)"sv }, + { R"(true)"sv, 1 }, + }; + REQUIRE(tbl == expected); + }); + } + +#if TOML_LANG_UNRELEASED && UNICODE_LITERALS_OK + + SECTION("key-unicode") + { + parsing_should_succeed(FILE_LINE_ARGS, + key_unicode, + [](toml::table&& tbl) // key-unicode + { + const auto expected = toml::table{ + { R"(a‍b)"sv, R"(zwj)"sv }, + { R"(tiếng-Việt)"sv, + toml::array{ + toml::table{ + { R"(tiəŋ˧˦)"sv, + toml::table{ + { R"(viət̚˧˨ʔ)"sv, R"(north)"sv }, + } }, + }, + toml::table{ + { R"(tiəŋ˦˧˥)"sv, + toml::table{ + { R"(viək̚˨˩ʔ)"sv, R"(central)"sv }, + } }, + }, + } }, + { R"(ÅÅ)"sv, R"(U+00C5 U+0041 U+030A)"sv }, + { R"(€)"sv, R"(Euro)"sv }, + { R"(中文)"sv, + toml::table{ + { R"(中文)"sv, + toml::table{ + { R"(中文)"sv, R"(Chinese language)"sv }, + } }, + } }, + { R"(😂)"sv, R"(rofl)"sv }, + }; + REQUIRE(tbl == expected); + }); + } + +#endif // TOML_LANG_UNRELEASED && UNICODE_LITERALS_OK + + SECTION("newline-crlf") + { + parsing_should_succeed(FILE_LINE_ARGS, + newline_crlf, + [](toml::table&& tbl) // newline-crlf + { + const auto expected = toml::table{ + { R"(newline)"sv, R"(crlf)"sv }, + { R"(os)"sv, R"(DOS)"sv }, + }; + REQUIRE(tbl == expected); + }); + } + + SECTION("newline-lf") + { + parsing_should_succeed(FILE_LINE_ARGS, + newline_lf, + [](toml::table&& tbl) // newline-lf + { + const auto expected = toml::table{ + { R"(newline)"sv, R"(lf)"sv }, + { R"(os)"sv, R"(unix)"sv }, + }; + REQUIRE(tbl == expected); + }); + } + + SECTION("spec-array-0") + { + parsing_should_succeed(FILE_LINE_ARGS, + spec_array_0, + [](toml::table&& tbl) // spec-array-0 + { + const auto expected = toml::table{ + { R"(colors)"sv, + toml::array{ + R"(red)"sv, + R"(yellow)"sv, + R"(green)"sv, + } }, + { R"(contributors)"sv, + toml::array{ + R"(Foo Bar )"sv, + toml::table{ + { R"(email)"sv, R"(bazqux@example.com)"sv }, + { R"(name)"sv, R"(Baz Qux)"sv }, + { R"(url)"sv, R"(https://example.com/bazqux)"sv }, + }, + } }, + { R"(integers)"sv, + toml::array{ + 1, + 2, + 3, + } }, + { R"(nested_arrays_of_ints)"sv, + toml::array{ + toml::array{ + 1, + 2, + }, + toml::array{ + 3, + 4, + 5, + }, + } }, + { R"(nested_mixed_array)"sv, + toml::array{ + toml::array{ + 1, + 2, + }, + toml::array{ + R"(a)"sv, + R"(b)"sv, + R"(c)"sv, + }, + } }, + { R"(numbers)"sv, + toml::array{ + 0.1, + 0.2, + 0.5, + 1, + 2, + 5, + } }, + { R"(string_array)"sv, + toml::array{ + R"(all)"sv, + R"(strings)"sv, + R"(are the same)"sv, + R"(type)"sv, + } }, + }; + REQUIRE(tbl == expected); + }); + } + + SECTION("spec-array-1") + { + parsing_should_succeed(FILE_LINE_ARGS, + spec_array_1, + [](toml::table&& tbl) // spec-array-1 + { + const auto expected = toml::table{ + { R"(integers2)"sv, + toml::array{ + 1, + 2, + 3, + } }, + { R"(integers3)"sv, + toml::array{ + 1, + 2, + } }, + }; + REQUIRE(tbl == expected); + }); + } + + SECTION("spec-array-of-tables-0") + { + parsing_should_succeed(FILE_LINE_ARGS, + spec_array_of_tables_0, + [](toml::table&& tbl) // spec-array-of-tables-0 + { + const auto expected = toml::table{ + { R"(products)"sv, + toml::array{ + toml::table{ + { R"(name)"sv, R"(Hammer)"sv }, + { R"(sku)"sv, 738594937 }, + }, + toml::table{}, + toml::table{ + { R"(color)"sv, R"(gray)"sv }, + { R"(name)"sv, R"(Nail)"sv }, + { R"(sku)"sv, 284758393 }, + }, + } }, + }; + REQUIRE(tbl == expected); + }); + } + + SECTION("spec-array-of-tables-1") + { + parsing_should_succeed(FILE_LINE_ARGS, + spec_array_of_tables_1, + [](toml::table&& tbl) // spec-array-of-tables-1 + { + const auto expected = toml::table{ + { R"(fruits)"sv, + toml::array{ + toml::table{ + { R"(name)"sv, R"(apple)"sv }, + { R"(physical)"sv, + toml::table{ + { R"(color)"sv, R"(red)"sv }, + { R"(shape)"sv, R"(round)"sv }, + } }, + { R"(varieties)"sv, + toml::array{ + toml::table{ + { R"(name)"sv, R"(red delicious)"sv }, + }, + toml::table{ + { R"(name)"sv, R"(granny smith)"sv }, + }, + } }, + }, + toml::table{ + { R"(name)"sv, R"(banana)"sv }, + { R"(varieties)"sv, + toml::array{ + toml::table{ + { R"(name)"sv, R"(plantain)"sv }, + }, + } }, + }, + } }, + }; + REQUIRE(tbl == expected); + }); + } + + SECTION("spec-array-of-tables-2") + { + parsing_should_succeed(FILE_LINE_ARGS, + spec_array_of_tables_2, + [](toml::table&& tbl) // spec-array-of-tables-2 + { + const auto expected = toml::table{ + { R"(points)"sv, + toml::array{ + toml::table{ + { R"(x)"sv, 1 }, + { R"(y)"sv, 2 }, + { R"(z)"sv, 3 }, + }, + toml::table{ + { R"(x)"sv, 7 }, + { R"(y)"sv, 8 }, + { R"(z)"sv, 9 }, + }, + toml::table{ + { R"(x)"sv, 2 }, + { R"(y)"sv, 4 }, + { R"(z)"sv, 8 }, + }, + } }, + }; + REQUIRE(tbl == expected); + }); + } + + SECTION("spec-boolean-0") + { + parsing_should_succeed(FILE_LINE_ARGS, + spec_boolean_0, + [](toml::table&& tbl) // spec-boolean-0 + { + const auto expected = toml::table{ + { R"(bool1)"sv, true }, + { R"(bool2)"sv, false }, + }; + REQUIRE(tbl == expected); + }); + } + + SECTION("spec-comment-0") + { + parsing_should_succeed(FILE_LINE_ARGS, + spec_comment_0, + [](toml::table&& tbl) // spec-comment-0 + { + const auto expected = toml::table{ + { R"(another)"sv, R"(# This is not a comment)"sv }, + { R"(key)"sv, R"(value)"sv }, + }; + REQUIRE(tbl == expected); + }); + } + + SECTION("spec-float-0") + { + parsing_should_succeed(FILE_LINE_ARGS, + spec_float_0, + [](toml::table&& tbl) // spec-float-0 + { + const auto expected = toml::table{ + { R"(flt1)"sv, 1.0 }, { R"(flt2)"sv, 3.1415 }, { R"(flt3)"sv, -0.01 }, + { R"(flt4)"sv, 5e+22 }, { R"(flt5)"sv, 1000000.0 }, { R"(flt6)"sv, -0.02 }, + { R"(flt7)"sv, 6.626e-34 }, + }; + REQUIRE(tbl == expected); + }); + } + + SECTION("spec-float-1") + { + parsing_should_succeed(FILE_LINE_ARGS, + spec_float_1, + [](toml::table&& tbl) // spec-float-1 + { + const auto expected = toml::table{ + { R"(flt8)"sv, 224617.445991228 }, + }; + REQUIRE(tbl == expected); + }); + } + + SECTION("spec-float-2") + { + parsing_should_succeed(FILE_LINE_ARGS, + spec_float_2, + [](toml::table&& tbl) // spec-float-2 + { + const auto expected = toml::table{ + { R"(sf1)"sv, std::numeric_limits::infinity() }, + { R"(sf2)"sv, std::numeric_limits::infinity() }, + { R"(sf3)"sv, -std::numeric_limits::infinity() }, + { R"(sf4)"sv, std::numeric_limits::quiet_NaN() }, + { R"(sf5)"sv, std::numeric_limits::quiet_NaN() }, + { R"(sf6)"sv, std::numeric_limits::quiet_NaN() }, + }; + REQUIRE(tbl == expected); + }); + } + + SECTION("spec-inline-table-0") + { + parsing_should_succeed(FILE_LINE_ARGS, + spec_inline_table_0, + [](toml::table&& tbl) // spec-inline-table-0 + { + const auto expected = toml::table{ + { R"(animal)"sv, + toml::table{ + { R"(type)"sv, + toml::table{ + { R"(name)"sv, R"(pug)"sv }, + } }, + } }, + { R"(name)"sv, + toml::table{ + { R"(first)"sv, R"(Tom)"sv }, + { R"(last)"sv, R"(Preston-Werner)"sv }, + } }, + { R"(point)"sv, + toml::table{ + { R"(x)"sv, 1 }, + { R"(y)"sv, 2 }, + } }, + }; + REQUIRE(tbl == expected); + }); + } + + SECTION("spec-inline-table-1") + { + parsing_should_succeed(FILE_LINE_ARGS, + spec_inline_table_1, + [](toml::table&& tbl) // spec-inline-table-1 + { + const auto expected = toml::table{ + { R"(animal)"sv, + toml::table{ + { R"(type)"sv, + toml::table{ + { R"(name)"sv, R"(pug)"sv }, + } }, + } }, + { R"(name)"sv, + toml::table{ + { R"(first)"sv, R"(Tom)"sv }, + { R"(last)"sv, R"(Preston-Werner)"sv }, + } }, + { R"(point)"sv, + toml::table{ + { R"(x)"sv, 1 }, + { R"(y)"sv, 2 }, + } }, + }; + REQUIRE(tbl == expected); + }); + } + + SECTION("spec-inline-table-2") + { + parsing_should_succeed(FILE_LINE_ARGS, + spec_inline_table_2, + [](toml::table&& tbl) // spec-inline-table-2 + { + const auto expected = toml::table{ + { R"(product)"sv, + toml::table{ + { R"(type)"sv, + toml::table{ + { R"(name)"sv, R"(Nail)"sv }, + } }, + } }, + }; + REQUIRE(tbl == expected); + }); + } + + SECTION("spec-inline-table-3") + { + parsing_should_succeed(FILE_LINE_ARGS, + spec_inline_table_3, + [](toml::table&& tbl) // spec-inline-table-3 + { + const auto expected = toml::table{ + { R"(product)"sv, + toml::table{ + { R"(type)"sv, + toml::table{ + { R"(name)"sv, R"(Nail)"sv }, + } }, + } }, + }; + REQUIRE(tbl == expected); + }); + } + + SECTION("spec-integer-0") + { + parsing_should_succeed(FILE_LINE_ARGS, + spec_integer_0, + [](toml::table&& tbl) // spec-integer-0 + { + const auto expected = toml::table{ + { R"(int1)"sv, 99 }, + { R"(int2)"sv, 42 }, + { R"(int3)"sv, 0 }, + { R"(int4)"sv, -17 }, + }; + REQUIRE(tbl == expected); + }); + } + + SECTION("spec-integer-1") + { + parsing_should_succeed(FILE_LINE_ARGS, + spec_integer_1, + [](toml::table&& tbl) // spec-integer-1 + { + const auto expected = toml::table{ + { R"(int5)"sv, 1000 }, + { R"(int6)"sv, 5349221 }, + { R"(int7)"sv, 5349221 }, + { R"(int8)"sv, 12345 }, + }; + REQUIRE(tbl == expected); + }); + } + + SECTION("spec-integer-2") + { + parsing_should_succeed(FILE_LINE_ARGS, + spec_integer_2, + [](toml::table&& tbl) // spec-integer-2 + { + const auto expected = toml::table{ + { R"(bin1)"sv, 214 }, { R"(hex1)"sv, 3735928559 }, + { R"(hex2)"sv, 3735928559 }, { R"(hex3)"sv, 3735928559 }, + { R"(oct1)"sv, 342391 }, { R"(oct2)"sv, 493 }, + }; + REQUIRE(tbl == expected); + }); + } + + SECTION("spec-key-value-pair-0") + { + parsing_should_succeed(FILE_LINE_ARGS, + spec_key_value_pair_0, + [](toml::table&& tbl) // spec-key-value-pair-0 + { + const auto expected = toml::table{ + { R"(key)"sv, R"(value)"sv }, + }; + REQUIRE(tbl == expected); + }); + } + + SECTION("spec-keys-0") + { + parsing_should_succeed(FILE_LINE_ARGS, + spec_keys_0, + [](toml::table&& tbl) // spec-keys-0 + { + const auto expected = toml::table{ + { R"(1234)"sv, R"(value)"sv }, + { R"(bare-key)"sv, R"(value)"sv }, + { R"(bare_key)"sv, R"(value)"sv }, + { R"(key)"sv, R"(value)"sv }, + }; + REQUIRE(tbl == expected); + }); + } + + SECTION("spec-keys-3") + { + parsing_should_succeed(FILE_LINE_ARGS, + spec_keys_3, + [](toml::table&& tbl) // spec-keys-3 + { + const auto expected = toml::table{ + { R"(name)"sv, R"(Orange)"sv }, + { R"(physical)"sv, + toml::table{ + { R"(color)"sv, R"(orange)"sv }, + { R"(shape)"sv, R"(round)"sv }, + } }, + { R"(site)"sv, + toml::table{ + { R"(google.com)"sv, true }, + } }, + }; + REQUIRE(tbl == expected); + }); + } + + SECTION("spec-keys-4") + { + parsing_should_succeed(FILE_LINE_ARGS, + spec_keys_4, + [](toml::table&& tbl) // spec-keys-4 + { + const auto expected = toml::table{ + { R"(fruit)"sv, + toml::table{ + { R"(color)"sv, R"(yellow)"sv }, + { R"(flavor)"sv, R"(banana)"sv }, + { R"(name)"sv, R"(banana)"sv }, + } }, + }; + REQUIRE(tbl == expected); + }); + } + + SECTION("spec-keys-5") + { + parsing_should_succeed(FILE_LINE_ARGS, + spec_keys_5, + [](toml::table&& tbl) // spec-keys-5 + { + const auto expected = toml::table{ + { R"(apple)"sv, + toml::table{ + { R"(color)"sv, R"(red)"sv }, + { R"(skin)"sv, R"(thin)"sv }, + { R"(type)"sv, R"(fruit)"sv }, + } }, + { R"(orange)"sv, + toml::table{ + { R"(color)"sv, R"(orange)"sv }, + { R"(skin)"sv, R"(thick)"sv }, + { R"(type)"sv, R"(fruit)"sv }, + } }, + }; + REQUIRE(tbl == expected); + }); + } + + SECTION("spec-keys-6") + { + parsing_should_succeed(FILE_LINE_ARGS, + spec_keys_6, + [](toml::table&& tbl) // spec-keys-6 + { + const auto expected = toml::table{ + { R"(apple)"sv, + toml::table{ + { R"(color)"sv, R"(red)"sv }, + { R"(skin)"sv, R"(thin)"sv }, + { R"(type)"sv, R"(fruit)"sv }, + } }, + { R"(orange)"sv, + toml::table{ + { R"(color)"sv, R"(orange)"sv }, + { R"(skin)"sv, R"(thick)"sv }, + { R"(type)"sv, R"(fruit)"sv }, + } }, + }; + REQUIRE(tbl == expected); + }); + } + + SECTION("spec-keys-7") + { + parsing_should_succeed(FILE_LINE_ARGS, + spec_keys_7, + [](toml::table&& tbl) // spec-keys-7 + { + const auto expected = toml::table{ + { R"(3)"sv, + toml::table{ + { R"(14159)"sv, R"(pi)"sv }, + } }, + }; + REQUIRE(tbl == expected); + }); + } + + SECTION("spec-local-date-0") + { + parsing_should_succeed(FILE_LINE_ARGS, + spec_local_date_0, + [](toml::table&& tbl) // spec-local-date-0 + { + const auto expected = toml::table{ + { R"(ld1)"sv, toml::date{ 1979, 5, 27 } }, + }; + REQUIRE(tbl == expected); + }); + } + + SECTION("spec-local-date-time-0") + { + parsing_should_succeed(FILE_LINE_ARGS, + spec_local_date_time_0, + [](toml::table&& tbl) // spec-local-date-time-0 + { + const auto expected = toml::table{ + { R"(ldt1)"sv, toml::date_time{ { 1979, 5, 27 }, { 7, 32 } } }, + { R"(ldt2)"sv, toml::date_time{ { 1979, 5, 27 }, { 0, 32, 0, 999999000 } } }, + }; + REQUIRE(tbl == expected); + }); + } + + SECTION("spec-local-time-0") + { + parsing_should_succeed(FILE_LINE_ARGS, + spec_local_time_0, + [](toml::table&& tbl) // spec-local-time-0 + { + const auto expected = toml::table{ + { R"(lt1)"sv, toml::time{ 7, 32 } }, + { R"(lt2)"sv, toml::time{ 0, 32, 0, 999999000 } }, + }; + REQUIRE(tbl == expected); + }); + } + + SECTION("spec-offset-date-time-0") + { + parsing_should_succeed( + FILE_LINE_ARGS, + spec_offset_date_time_0, + [](toml::table&& tbl) // spec-offset-date-time-0 + { + const auto expected = toml::table{ + { R"(odt1)"sv, toml::date_time{ { 1979, 5, 27 }, { 7, 32 }, { 0, 0 } } }, + { R"(odt2)"sv, toml::date_time{ { 1979, 5, 27 }, { 0, 32 }, { -7, 0 } } }, + { R"(odt3)"sv, toml::date_time{ { 1979, 5, 27 }, { 0, 32, 0, 999999000 }, { -7, 0 } } }, + }; + REQUIRE(tbl == expected); + }); + } + + SECTION("spec-offset-date-time-1") + { + parsing_should_succeed(FILE_LINE_ARGS, + spec_offset_date_time_1, + [](toml::table&& tbl) // spec-offset-date-time-1 + { + const auto expected = toml::table{ + { R"(odt4)"sv, toml::date_time{ { 1979, 5, 27 }, { 7, 32 }, { 0, 0 } } }, + }; + REQUIRE(tbl == expected); + }); + } + + SECTION("spec-string-1") + { + parsing_should_succeed(FILE_LINE_ARGS, + spec_string_1, + [](toml::table&& tbl) // spec-string-1 + { + const auto expected = toml::table{ + { R"(str1)"sv, R"(Roses are red +Violets are blue)"sv }, + }; + REQUIRE(tbl == expected); + }); + } + + SECTION("spec-string-2") + { + parsing_should_succeed(FILE_LINE_ARGS, + spec_string_2, + [](toml::table&& tbl) // spec-string-2 + { + const auto expected = toml::table{ + { R"(str2)"sv, R"(Roses are red +Violets are blue)"sv }, + { R"(str3)"sv, + "Roses are red\r\n" + "Violets are blue"sv }, + }; + REQUIRE(tbl == expected); + }); + } + + SECTION("spec-string-3") + { + parsing_should_succeed(FILE_LINE_ARGS, + spec_string_3, + [](toml::table&& tbl) // spec-string-3 + { + const auto expected = toml::table{ + { R"(str1)"sv, R"(The quick brown fox jumps over the lazy dog.)"sv }, + { R"(str2)"sv, R"(The quick brown fox jumps over the lazy dog.)"sv }, + { R"(str3)"sv, R"(The quick brown fox jumps over the lazy dog.)"sv }, + }; + REQUIRE(tbl == expected); + }); + } + + SECTION("spec-string-4") + { + parsing_should_succeed(FILE_LINE_ARGS, + spec_string_4, + [](toml::table&& tbl) // spec-string-4 + { + const auto expected = toml::table{ + { R"(str4)"sv, R"(Here are two quotation marks: "". Simple enough.)"sv }, + { R"(str5)"sv, R"(Here are three quotation marks: """.)"sv }, + { R"(str6)"sv, R"(Here are fifteen quotation marks: """"""""""""""".)"sv }, + { R"(str7)"sv, R"("This," she said, "is just a pointless statement.")"sv }, + }; + REQUIRE(tbl == expected); + }); + } + + SECTION("spec-string-5") + { + parsing_should_succeed(FILE_LINE_ARGS, + spec_string_5, + [](toml::table&& tbl) // spec-string-5 + { + const auto expected = toml::table{ + { R"(quoted)"sv, R"(Tom "Dubs" Preston-Werner)"sv }, + { R"(regex)"sv, R"(<\i\c*\s*>)"sv }, + { R"(winpath)"sv, R"(C:\Users\nodejs\templates)"sv }, + { R"(winpath2)"sv, R"(\\ServerX\admin$\system32\)"sv }, + }; + REQUIRE(tbl == expected); + }); + } + + SECTION("spec-string-6") + { + parsing_should_succeed(FILE_LINE_ARGS, + spec_string_6, + [](toml::table&& tbl) // spec-string-6 + { + const auto expected = toml::table{ + { R"(lines)"sv, R"(The first newline is +trimmed in raw strings. + All other whitespace + is preserved. +)"sv }, + { R"(regex2)"sv, R"(I [dw]on't need \d{2} apples)"sv }, + }; + REQUIRE(tbl == expected); + }); + } + + SECTION("spec-string-7") + { + parsing_should_succeed(FILE_LINE_ARGS, + spec_string_7, + [](toml::table&& tbl) // spec-string-7 + { + const auto expected = toml::table{ + { R"(apos15)"sv, R"(Here are fifteen apostrophes: ''''''''''''''')"sv }, + { R"(quot15)"sv, R"(Here are fifteen quotation marks: """"""""""""""")"sv }, + { R"(str)"sv, R"('That,' she said, 'is still pointless.')"sv }, + }; + REQUIRE(tbl == expected); + }); + } + + SECTION("spec-table-0") + { + parsing_should_succeed(FILE_LINE_ARGS, + spec_table_0, + [](toml::table&& tbl) // spec-table-0 + { + const auto expected = toml::table{ + { R"(table)"sv, toml::table{} }, + }; + REQUIRE(tbl == expected); + }); + } + + SECTION("spec-table-1") + { + parsing_should_succeed(FILE_LINE_ARGS, + spec_table_1, + [](toml::table&& tbl) // spec-table-1 + { + const auto expected = toml::table{ + { R"(table-1)"sv, + toml::table{ + { R"(key1)"sv, R"(some string)"sv }, + { R"(key2)"sv, 123 }, + } }, + { R"(table-2)"sv, + toml::table{ + { R"(key1)"sv, R"(another string)"sv }, + { R"(key2)"sv, 456 }, + } }, + }; + REQUIRE(tbl == expected); + }); + } + + SECTION("spec-table-2") + { + parsing_should_succeed(FILE_LINE_ARGS, + spec_table_2, + [](toml::table&& tbl) // spec-table-2 + { + const auto expected = toml::table{ + { R"(dog)"sv, + toml::table{ + { R"(tater.man)"sv, + toml::table{ + { R"(type)"sv, + toml::table{ + { R"(name)"sv, R"(pug)"sv }, + } }, + } }, + } }, + }; + REQUIRE(tbl == expected); + }); + } + + SECTION("spec-table-4") + { + parsing_should_succeed(FILE_LINE_ARGS, + spec_table_4, + [](toml::table&& tbl) // spec-table-4 + { + const auto expected = toml::table{ + { R"(x)"sv, + toml::table{ + { R"(y)"sv, + toml::table{ + { R"(z)"sv, + toml::table{ + { R"(w)"sv, toml::table{} }, + } }, + } }, + } }, + }; + REQUIRE(tbl == expected); + }); + } + + SECTION("spec-table-5") + { + parsing_should_succeed(FILE_LINE_ARGS, + spec_table_5, + [](toml::table&& tbl) // spec-table-5 + { + const auto expected = toml::table{ + { R"(animal)"sv, toml::table{} }, + { R"(fruit)"sv, + toml::table{ + { R"(apple)"sv, toml::table{} }, + { R"(orange)"sv, toml::table{} }, + } }, + }; + REQUIRE(tbl == expected); + }); + } + + SECTION("spec-table-6") + { + parsing_should_succeed(FILE_LINE_ARGS, + spec_table_6, + [](toml::table&& tbl) // spec-table-6 + { + const auto expected = toml::table{ + { R"(animal)"sv, toml::table{} }, + { R"(fruit)"sv, + toml::table{ + { R"(apple)"sv, toml::table{} }, + { R"(orange)"sv, toml::table{} }, + } }, + }; + REQUIRE(tbl == expected); + }); + } + + SECTION("spec-table-7") + { + parsing_should_succeed(FILE_LINE_ARGS, + spec_table_7, + [](toml::table&& tbl) // spec-table-7 + { + const auto expected = toml::table{ + { R"(breed)"sv, R"(pug)"sv }, + { R"(name)"sv, R"(Fido)"sv }, + { R"(owner)"sv, + toml::table{ + { R"(member_since)"sv, toml::date{ 1999, 8, 4 } }, + { R"(name)"sv, R"(Regina Dogman)"sv }, + } }, + }; + REQUIRE(tbl == expected); + }); + } + + SECTION("spec-table-8") + { + parsing_should_succeed(FILE_LINE_ARGS, + spec_table_8, + [](toml::table&& tbl) // spec-table-8 + { + const auto expected = toml::table{ + { R"(fruit)"sv, + toml::table{ + { R"(apple)"sv, + toml::table{ + { R"(color)"sv, R"(red)"sv }, + { R"(taste)"sv, + toml::table{ + { R"(sweet)"sv, true }, + } }, + } }, + } }, + }; + REQUIRE(tbl == expected); + }); + } + + SECTION("spec-table-9") + { + parsing_should_succeed(FILE_LINE_ARGS, + spec_table_9, + [](toml::table&& tbl) // spec-table-9 + { + const auto expected = toml::table{ + { R"(fruit)"sv, + toml::table{ + { R"(apple)"sv, + toml::table{ + { R"(color)"sv, R"(red)"sv }, + { R"(taste)"sv, + toml::table{ + { R"(sweet)"sv, true }, + } }, + { R"(texture)"sv, + toml::table{ + { R"(smooth)"sv, true }, + } }, + } }, + } }, + }; + REQUIRE(tbl == expected); + }); + } + + SECTION("spec-example-1-compact") + { + parsing_should_succeed(FILE_LINE_ARGS, + spec_example_1_compact, + [](toml::table&& tbl) // spec-example-1-compact + { + const auto expected = toml::table{ + { R"(clients)"sv, + toml::table{ + { R"(data)"sv, + toml::array{ + toml::array{ + R"(gamma)"sv, + R"(delta)"sv, + }, + toml::array{ + 1, + 2, + }, + } }, + { R"(hosts)"sv, + toml::array{ + R"(alpha)"sv, + R"(omega)"sv, + } }, + } }, + { R"(database)"sv, + toml::table{ + { R"(connection_max)"sv, 5000 }, + { R"(enabled)"sv, true }, + { R"(ports)"sv, + toml::array{ + 8001, + 8001, + 8002, + } }, + { R"(server)"sv, R"(192.168.1.1)"sv }, + } }, + { R"(owner)"sv, + toml::table{ + { R"(dob)"sv, toml::date_time{ { 1979, 5, 27 }, { 7, 32 }, { -8, 0 } } }, + { R"(name)"sv, R"(Lance Uppercut)"sv }, + } }, + { R"(servers)"sv, + toml::table{ + { R"(alpha)"sv, + toml::table{ + { R"(dc)"sv, R"(eqdc10)"sv }, + { R"(ip)"sv, R"(10.0.0.1)"sv }, + } }, + { R"(beta)"sv, + toml::table{ + { R"(dc)"sv, R"(eqdc10)"sv }, + { R"(ip)"sv, R"(10.0.0.2)"sv }, + } }, + } }, + { R"(title)"sv, R"(TOML Example)"sv }, + }; + REQUIRE(tbl == expected); + }); + } + + SECTION("spec-example-1") + { + parsing_should_succeed(FILE_LINE_ARGS, + spec_example_1, + [](toml::table&& tbl) // spec-example-1 + { + const auto expected = toml::table{ + { R"(clients)"sv, + toml::table{ + { R"(data)"sv, + toml::array{ + toml::array{ + R"(gamma)"sv, + R"(delta)"sv, + }, + toml::array{ + 1, + 2, + }, + } }, + { R"(hosts)"sv, + toml::array{ + R"(alpha)"sv, + R"(omega)"sv, + } }, + } }, + { R"(database)"sv, + toml::table{ + { R"(connection_max)"sv, 5000 }, + { R"(enabled)"sv, true }, + { R"(ports)"sv, + toml::array{ + 8001, + 8001, + 8002, + } }, + { R"(server)"sv, R"(192.168.1.1)"sv }, + } }, + { R"(owner)"sv, + toml::table{ + { R"(dob)"sv, toml::date_time{ { 1979, 5, 27 }, { 7, 32 }, { -8, 0 } } }, + { R"(name)"sv, R"(Lance Uppercut)"sv }, + } }, + { R"(servers)"sv, + toml::table{ + { R"(alpha)"sv, + toml::table{ + { R"(dc)"sv, R"(eqdc10)"sv }, + { R"(ip)"sv, R"(10.0.0.1)"sv }, + } }, + { R"(beta)"sv, + toml::table{ + { R"(dc)"sv, R"(eqdc10)"sv }, + { R"(ip)"sv, R"(10.0.0.2)"sv }, + } }, + } }, + { R"(title)"sv, R"(TOML Example)"sv }, + }; + REQUIRE(tbl == expected); + }); + } + +#if UNICODE_LITERALS_OK + + SECTION("spec-keys-1") + { + parsing_should_succeed(FILE_LINE_ARGS, + spec_keys_1, + [](toml::table&& tbl) // spec-keys-1 + { + const auto expected = toml::table{ + { R"(127.0.0.1)"sv, R"(value)"sv }, { R"(character encoding)"sv, R"(value)"sv }, + { R"(key2)"sv, R"(value)"sv }, { R"(quoted "value")"sv, R"(value)"sv }, + { R"(ʎǝʞ)"sv, R"(value)"sv }, + }; + REQUIRE(tbl == expected); + }); + } + + SECTION("spec-string-0") + { + parsing_should_succeed(FILE_LINE_ARGS, + spec_string_0, + [](toml::table&& tbl) // spec-string-0 + { + const auto expected = toml::table{ + { R"(str)"sv, R"(I'm a string. "You can quote me". Name José +Location SF.)"sv }, + }; + REQUIRE(tbl == expected); + }); + } + + SECTION("spec-table-3") + { + parsing_should_succeed(FILE_LINE_ARGS, + spec_table_3, + [](toml::table&& tbl) // spec-table-3 + { + const auto expected = toml::table{ + { R"(a)"sv, + toml::table{ + { R"(b)"sv, + toml::table{ + { R"(c)"sv, toml::table{} }, + } }, + } }, + { R"(d)"sv, + toml::table{ + { R"(e)"sv, + toml::table{ + { R"(f)"sv, toml::table{} }, + } }, + } }, + { R"(g)"sv, + toml::table{ + { R"(h)"sv, + toml::table{ + { R"(i)"sv, toml::table{} }, + } }, + } }, + { R"(j)"sv, + toml::table{ + { R"(ʞ)"sv, + toml::table{ + { R"(l)"sv, toml::table{} }, + } }, + } }, + }; + REQUIRE(tbl == expected); + }); + } + +#endif // UNICODE_LITERALS_OK + + SECTION("string-double-quote-escape") + { + parsing_should_succeed(FILE_LINE_ARGS, + string_double_quote_escape, + [](toml::table&& tbl) // string-double-quote-escape + { + const auto expected = toml::table{ + { R"(test)"sv, R"("one")"sv }, + }; + REQUIRE(tbl == expected); + }); + } + + SECTION("string-empty") + { + parsing_should_succeed(FILE_LINE_ARGS, + string_empty, + [](toml::table&& tbl) // string-empty + { + const auto expected = toml::table{ + { R"(answer)"sv, ""sv }, + }; + REQUIRE(tbl == expected); + }); + } + + SECTION("string-escaped-escape") + { + parsing_should_succeed(FILE_LINE_ARGS, + string_escaped_escape, + [](toml::table&& tbl) // string-escaped-escape + { + const auto expected = toml::table{ + { R"(answer)"sv, R"(\x64)"sv }, + }; + REQUIRE(tbl == expected); + }); + } + + SECTION("string-escapes") + { + parsing_should_succeed( + FILE_LINE_ARGS, + string_escapes, + [](toml::table&& tbl) // string-escapes + { + const auto expected = toml::table{ + { R"(backslash)"sv, R"(This string has a \ backslash character.)"sv }, + { R"(backspace)"sv, "This string has a \x08 backspace character."sv }, + { R"(carriage)"sv, "This string has a \r carriage return character."sv }, + { R"(delete)"sv, "This string has a \x7F delete control code."sv }, + { R"(formfeed)"sv, "This string has a \f form feed character."sv }, + { R"(newline)"sv, R"(This string has a + new line character.)"sv }, + { R"(notunicode1)"sv, R"(This string does not have a unicode \u escape.)"sv }, + { R"(notunicode2)"sv, R"(This string does not have a unicode \u escape.)"sv }, + { R"(notunicode3)"sv, R"(This string does not have a unicode \u0075 escape.)"sv }, + { R"(notunicode4)"sv, R"(This string does not have a unicode \u escape.)"sv }, + { R"(quote)"sv, R"(This string has a " quote character.)"sv }, + { R"(tab)"sv, R"(This string has a tab character.)"sv }, + { R"(unitseparator)"sv, "This string has a \x1F unit separator control code."sv }, + }; + REQUIRE(tbl == expected); + }); + } + + SECTION("string-multiline-escaped-crlf") + { + parsing_should_succeed(FILE_LINE_ARGS, + string_multiline_escaped_crlf, + [](toml::table&& tbl) // string-multiline-escaped-crlf + { + const auto expected = toml::table{ + { R"(0)"sv, ""sv }, + }; + REQUIRE(tbl == expected); + }); + } + + SECTION("string-multiline-quotes") + { + parsing_should_succeed(FILE_LINE_ARGS, + string_multiline_quotes, + [](toml::table&& tbl) // string-multiline-quotes + { + const auto expected = toml::table{ + { R"(escaped)"sv, R"(lol""")"sv }, + { R"(lit_one)"sv, R"('one quote')"sv }, + { R"(lit_one_space)"sv, R"( 'one quote' )"sv }, + { R"(lit_two)"sv, R"(''two quotes'')"sv }, + { R"(lit_two_space)"sv, R"( ''two quotes'' )"sv }, + { R"(mismatch1)"sv, R"(aaa'''bbb)"sv }, + { R"(mismatch2)"sv, R"(aaa"""bbb)"sv }, + { R"(one)"sv, R"("one quote")"sv }, + { R"(one_space)"sv, R"( "one quote" )"sv }, + { R"(two)"sv, R"(""two quotes"")"sv }, + { R"(two_space)"sv, R"( ""two quotes"" )"sv }, + }; + REQUIRE(tbl == expected); + }); + } + + SECTION("string-multiline") + { + parsing_should_succeed( + FILE_LINE_ARGS, + string_multiline, + [](toml::table&& tbl) // string-multiline + { + const auto expected = toml::table{ + { R"(equivalent_one)"sv, R"(The quick brown fox jumps over the lazy dog.)"sv }, + { R"(equivalent_three)"sv, R"(The quick brown fox jumps over the lazy dog.)"sv }, + { R"(equivalent_two)"sv, R"(The quick brown fox jumps over the lazy dog.)"sv }, + { R"(escape-bs-1)"sv, R"(a \ +b)"sv }, + { R"(escape-bs-2)"sv, R"(a \b)"sv }, + { R"(escape-bs-3)"sv, R"(a \\ + b)"sv }, + { R"(keep-ws-before)"sv, R"(a b)"sv }, + { R"(multiline_empty_four)"sv, ""sv }, + { R"(multiline_empty_one)"sv, ""sv }, + { R"(multiline_empty_three)"sv, ""sv }, + { R"(multiline_empty_two)"sv, ""sv }, + { R"(no-space)"sv, R"(ab)"sv }, + { R"(whitespace-after-bs)"sv, R"(The quick brown fox jumps over the lazy dog.)"sv }, + }; + REQUIRE(tbl == expected); + }); + } + + SECTION("string-nl") + { + parsing_should_succeed(FILE_LINE_ARGS, + string_nl, + [](toml::table&& tbl) // string-nl + { + const auto expected = toml::table{ + { R"(lit_nl_end)"sv, R"(value\n)"sv }, + { R"(lit_nl_mid)"sv, R"(val\nue)"sv }, + { R"(lit_nl_uni)"sv, R"(val\ue)"sv }, + { R"(nl_end)"sv, R"(value +)"sv }, + { R"(nl_mid)"sv, R"(val +ue)"sv }, + }; + REQUIRE(tbl == expected); + }); + } + + SECTION("string-raw-multiline") + { + parsing_should_succeed(FILE_LINE_ARGS, + string_raw_multiline, + [](toml::table&& tbl) // string-raw-multiline + { + const auto expected = toml::table{ + { R"(firstnl)"sv, R"(This string has a ' quote character.)"sv }, + { R"(multiline)"sv, R"(This string has ' a quote character and more than one newline in it.)"sv }, - { R"(oneline)"sv, R"(This string has a ' quote character.)"sv }, - }; - REQUIRE(tbl == expected); - }); + { R"(oneline)"sv, R"(This string has a ' quote character.)"sv }, + { R"(multiline_with_tab)"sv, R"(First line + Followed by a tab)"sv }, + }; + REQUIRE(tbl == expected); + }); + } - parsing_should_succeed(FILE_LINE_ARGS, - string_raw, - [](toml::table&& tbl) // string-raw - { - const auto expected = toml::table{ - { R"(backslash)"sv, R"(This string has a \\ backslash character.)"sv }, - { R"(backspace)"sv, R"(This string has a \b backspace character.)"sv }, - { R"(carriage)"sv, R"(This string has a \r carriage return character.)"sv }, - { R"(formfeed)"sv, R"(This string has a \f form feed character.)"sv }, - { R"(newline)"sv, R"(This string has a \n new line character.)"sv }, - { R"(slash)"sv, R"(This string has a \/ slash character.)"sv }, - { R"(tab)"sv, R"(This string has a \t tab character.)"sv }, - }; - REQUIRE(tbl == expected); - }); + SECTION("string-raw") + { + parsing_should_succeed(FILE_LINE_ARGS, + string_raw, + [](toml::table&& tbl) // string-raw + { + const auto expected = toml::table{ + { R"(backslash)"sv, R"(This string has a \\ backslash character.)"sv }, + { R"(backspace)"sv, R"(This string has a \b backspace character.)"sv }, + { R"(carriage)"sv, R"(This string has a \r carriage return character.)"sv }, + { R"(formfeed)"sv, R"(This string has a \f form feed character.)"sv }, + { R"(newline)"sv, R"(This string has a \n new line character.)"sv }, + { R"(slash)"sv, R"(This string has a \/ slash character.)"sv }, + { R"(tab)"sv, R"(This string has a \t tab character.)"sv }, + { R"(unescaped_tab)"sv, R"(This string has an unescaped tab character.)"sv }, + }; + REQUIRE(tbl == expected); + }); + } - parsing_should_succeed(FILE_LINE_ARGS, - string_simple, - [](toml::table&& tbl) // string-simple - { - const auto expected = toml::table{ - { R"(answer)"sv, R"(You are not drinking enough whisky.)"sv }, - }; - REQUIRE(tbl == expected); - }); + SECTION("string-simple") + { + parsing_should_succeed(FILE_LINE_ARGS, + string_simple, + [](toml::table&& tbl) // string-simple + { + const auto expected = toml::table{ + { R"(answer)"sv, R"(You are not drinking enough whisky.)"sv }, + }; + REQUIRE(tbl == expected); + }); + } - parsing_should_succeed(FILE_LINE_ARGS, - string_with_pound, - [](toml::table&& tbl) // string-with-pound - { - const auto expected = toml::table{ - { R"(pound)"sv, R"(We see no # comments here.)"sv }, - { R"(poundcomment)"sv, R"(But there are # some comments here.)"sv }, - }; - REQUIRE(tbl == expected); - }); + SECTION("string-with-pound") + { + parsing_should_succeed(FILE_LINE_ARGS, + string_with_pound, + [](toml::table&& tbl) // string-with-pound + { + const auto expected = toml::table{ + { R"(pound)"sv, R"(We see no # comments here.)"sv }, + { R"(poundcomment)"sv, R"(But there are # some comments here.)"sv }, + }; + REQUIRE(tbl == expected); + }); + } #if TOML_LANG_UNRELEASED - parsing_should_succeed(FILE_LINE_ARGS, - string_escape_esc, - [](toml::table&& tbl) // string-escape-esc - { - const auto expected = toml::table{ - { R"(esc)"sv, "\x1B There is no escape! \x1B"sv }, - }; - REQUIRE(tbl == expected); - }); + SECTION("string-escape-esc") + { + parsing_should_succeed(FILE_LINE_ARGS, + string_escape_esc, + [](toml::table&& tbl) // string-escape-esc + { + const auto expected = toml::table{ + { R"(esc)"sv, "\x1B There is no escape! \x1B"sv }, + }; + REQUIRE(tbl == expected); + }); + } #endif // TOML_LANG_UNRELEASED #if UNICODE_LITERALS_OK - parsing_should_succeed(FILE_LINE_ARGS, - string_escape_tricky, - [](toml::table&& tbl) // string-escape-tricky - { - const auto expected = toml::table{ - { R"(end_esc)"sv, R"(String does not end here" but ends here\)"sv }, - { R"(lit_end_esc)"sv, R"(String ends here\)"sv }, - { R"(lit_multiline_end)"sv, R"(There is no escape\)"sv }, - { R"(lit_multiline_not_unicode)"sv, R"(\u007f)"sv }, - { R"(multiline_end_esc)"sv, R"(When will it end? """...""" should be here")"sv }, - { R"(multiline_not_unicode)"sv, R"(\u0041)"sv }, - { R"(multiline_unicode)"sv, R"( )"sv }, - }; - REQUIRE(tbl == expected); - }); + SECTION("string-escape-tricky") + { + parsing_should_succeed(FILE_LINE_ARGS, + string_escape_tricky, + [](toml::table&& tbl) // string-escape-tricky + { + const auto expected = toml::table{ + { R"(end_esc)"sv, R"(String does not end here" but ends here\)"sv }, + { R"(lit_end_esc)"sv, R"(String ends here\)"sv }, + { R"(lit_multiline_end)"sv, R"(There is no escape\)"sv }, + { R"(lit_multiline_not_unicode)"sv, R"(\u007f)"sv }, + { R"(multiline_end_esc)"sv, R"(When will it end? """...""" should be here")"sv }, + { R"(multiline_not_unicode)"sv, R"(\u0041)"sv }, + { R"(multiline_unicode)"sv, R"( )"sv }, + }; + REQUIRE(tbl == expected); + }); + } - parsing_should_succeed(FILE_LINE_ARGS, - string_unicode_escape, - [](toml::table&& tbl) // string-unicode-escape - { - const auto expected = toml::table{ - { R"(answer4)"sv, R"(δ)"sv }, - { R"(answer8)"sv, R"(δ)"sv }, - }; - REQUIRE(tbl == expected); - }); + SECTION("string-quoted-unicode") + { + parsing_should_succeed( + FILE_LINE_ARGS, + string_quoted_unicode, + [](toml::table&& tbl) // string-quoted-unicode + { + const auto expected = toml::table{ + { R"(escaped_string)"sv, "\x00 \x08 \f A \x7F € ÿ ퟿  ￿ 𐀀 􏿿"sv }, + { R"(not_escaped_string)"sv, + R"(\u0000 \u0008 \u000c \U00000041 \u007f \u0080 \u00ff \ud7ff \ue000 \uffff \U00010000 \U0010ffff)"sv }, + { R"(basic_string)"sv, R"(~ € ÿ ퟿  ￿ 𐀀 􏿿)"sv }, + { R"(literal_string)"sv, R"(~ € ÿ ퟿  ￿ 𐀀 􏿿)"sv }, + }; + REQUIRE(tbl == expected); + }); + } - parsing_should_succeed(FILE_LINE_ARGS, - string_unicode_literal, - [](toml::table&& tbl) // string-unicode-literal - { - const auto expected = toml::table{ - { R"(answer)"sv, R"(δ)"sv }, - }; - REQUIRE(tbl == expected); - }); + SECTION("string-unicode-escape") + { + parsing_should_succeed(FILE_LINE_ARGS, + string_unicode_escape, + [](toml::table&& tbl) // string-unicode-escape + { + const auto expected = toml::table{ + { R"(answer4)"sv, R"(δ)"sv }, + { R"(answer8)"sv, R"(δ)"sv }, + }; + REQUIRE(tbl == expected); + }); + } + + SECTION("string-unicode-literal") + { + parsing_should_succeed(FILE_LINE_ARGS, + string_unicode_literal, + [](toml::table&& tbl) // string-unicode-literal + { + const auto expected = toml::table{ + { R"(answer)"sv, R"(δ)"sv }, + }; + REQUIRE(tbl == expected); + }); + } #endif // UNICODE_LITERALS_OK - parsing_should_succeed(FILE_LINE_ARGS, - table_array_implicit, - [](toml::table&& tbl) // table-array-implicit - { - const auto expected = toml::table{ - { R"(albums)"sv, - toml::table{ - { R"(songs)"sv, - toml::array{ - toml::table{ - { R"(name)"sv, R"(Glory Days)"sv }, - }, - } }, - } }, - }; - REQUIRE(tbl == expected); - }); +#if TOML_LANG_UNRELEASED && UNICODE_LITERALS_OK - parsing_should_succeed(FILE_LINE_ARGS, - table_array_many, - [](toml::table&& tbl) // table-array-many - { - const auto expected = toml::table{ - { R"(people)"sv, - toml::array{ - toml::table{ - { R"(first_name)"sv, R"(Bruce)"sv }, - { R"(last_name)"sv, R"(Springsteen)"sv }, - }, - toml::table{ - { R"(first_name)"sv, R"(Eric)"sv }, - { R"(last_name)"sv, R"(Clapton)"sv }, - }, - toml::table{ - { R"(first_name)"sv, R"(Bob)"sv }, - { R"(last_name)"sv, R"(Seger)"sv }, - }, - } }, - }; - REQUIRE(tbl == expected); - }); + SECTION("string-hex-escape") + { + parsing_should_succeed(FILE_LINE_ARGS, + string_hex_escape, + [](toml::table&& tbl) // string-hex-escape + { + const auto expected = toml::table{ + { R"(bs)"sv, "\x7F"sv }, + { R"(hello)"sv, R"(hello +)"sv }, + { R"(higher-than-127)"sv, R"(Sørmirbæren)"sv }, + { R"(literal)"sv, R"(\x20 \x09 \x0d\x0a)"sv }, + { R"(multiline)"sv, + " \x1B \r\n" + "\n" + "\x7F\n" + "\x00\n" + "hello\n" + "\n" + "Sørmirbæren\n" + ""sv }, + { R"(multiline-literal)"sv, R"(\x20 \x09 \x0d\x0a +)"sv }, + { R"(nul)"sv, "\x00"sv }, + { R"(whitespace)"sv, + " \x1B \r\n" + ""sv }, + }; + REQUIRE(tbl == expected); + }); + } - parsing_should_succeed(FILE_LINE_ARGS, - table_array_nest, - [](toml::table&& tbl) // table-array-nest - { - const auto expected = toml::table{ - { R"(albums)"sv, - toml::array{ +#endif // TOML_LANG_UNRELEASED && UNICODE_LITERALS_OK + + SECTION("table-array-implicit-and-explicit-after") + { + parsing_should_succeed(FILE_LINE_ARGS, + table_array_implicit_and_explicit_after, + [](toml::table&& tbl) // table-array-implicit-and-explicit-after + { + const auto expected = toml::table{ + { R"(a)"sv, toml::table{ - { R"(name)"sv, R"(Born to Run)"sv }, - { R"(songs)"sv, + { R"(b)"sv, toml::array{ toml::table{ - { R"(name)"sv, R"(Jungleland)"sv }, - }, - toml::table{ - { R"(name)"sv, R"(Meeting Across the River)"sv }, + { R"(x)"sv, 1 }, }, } }, - }, + { R"(y)"sv, 2 }, + } }, + }; + REQUIRE(tbl == expected); + }); + } + + SECTION("table-array-implicit") + { + parsing_should_succeed(FILE_LINE_ARGS, + table_array_implicit, + [](toml::table&& tbl) // table-array-implicit + { + const auto expected = toml::table{ + { R"(albums)"sv, toml::table{ - { R"(name)"sv, R"(Born in the USA)"sv }, { R"(songs)"sv, toml::array{ toml::table{ { R"(name)"sv, R"(Glory Days)"sv }, }, - toml::table{ - { R"(name)"sv, R"(Dancing in the Dark)"sv }, - }, } }, - }, - } }, - }; - REQUIRE(tbl == expected); - }); + } }, + }; + REQUIRE(tbl == expected); + }); + } - parsing_should_succeed(FILE_LINE_ARGS, - table_array_one, - [](toml::table&& tbl) // table-array-one - { - const auto expected = toml::table{ - { R"(people)"sv, - toml::array{ + SECTION("table-array-many") + { + parsing_should_succeed(FILE_LINE_ARGS, + table_array_many, + [](toml::table&& tbl) // table-array-many + { + const auto expected = toml::table{ + { R"(people)"sv, + toml::array{ + toml::table{ + { R"(first_name)"sv, R"(Bruce)"sv }, + { R"(last_name)"sv, R"(Springsteen)"sv }, + }, + toml::table{ + { R"(first_name)"sv, R"(Eric)"sv }, + { R"(last_name)"sv, R"(Clapton)"sv }, + }, + toml::table{ + { R"(first_name)"sv, R"(Bob)"sv }, + { R"(last_name)"sv, R"(Seger)"sv }, + }, + } }, + }; + REQUIRE(tbl == expected); + }); + } + + SECTION("table-array-nest") + { + parsing_should_succeed(FILE_LINE_ARGS, + table_array_nest, + [](toml::table&& tbl) // table-array-nest + { + const auto expected = toml::table{ + { R"(albums)"sv, + toml::array{ + toml::table{ + { R"(name)"sv, R"(Born to Run)"sv }, + { R"(songs)"sv, + toml::array{ + toml::table{ + { R"(name)"sv, R"(Jungleland)"sv }, + }, + toml::table{ + { R"(name)"sv, R"(Meeting Across the River)"sv }, + }, + } }, + }, + toml::table{ + { R"(name)"sv, R"(Born in the USA)"sv }, + { R"(songs)"sv, + toml::array{ + toml::table{ + { R"(name)"sv, R"(Glory Days)"sv }, + }, + toml::table{ + { R"(name)"sv, R"(Dancing in the Dark)"sv }, + }, + } }, + }, + } }, + }; + REQUIRE(tbl == expected); + }); + } + + SECTION("table-array-one") + { + parsing_should_succeed(FILE_LINE_ARGS, + table_array_one, + [](toml::table&& tbl) // table-array-one + { + const auto expected = toml::table{ + { R"(people)"sv, + toml::array{ + toml::table{ + { R"(first_name)"sv, R"(Bruce)"sv }, + { R"(last_name)"sv, R"(Springsteen)"sv }, + }, + } }, + }; + REQUIRE(tbl == expected); + }); + } + + SECTION("table-array-table-array") + { + parsing_should_succeed(FILE_LINE_ARGS, + table_array_table_array, + [](toml::table&& tbl) // table-array-table-array + { + const auto expected = toml::table{ + { R"(a)"sv, + toml::array{ + toml::table{ + { R"(b)"sv, + toml::array{ + toml::table{ + { R"(c)"sv, + toml::table{ + { R"(d)"sv, R"(val0)"sv }, + } }, + }, + toml::table{ + { R"(c)"sv, + toml::table{ + { R"(d)"sv, R"(val1)"sv }, + } }, + }, + } }, + }, + } }, + }; + REQUIRE(tbl == expected); + }); + } + + SECTION("table-array-within-dotted") + { + parsing_should_succeed(FILE_LINE_ARGS, + table_array_within_dotted, + [](toml::table&& tbl) // table-array-within-dotted + { + const auto expected = toml::table{ + { R"(fruit)"sv, toml::table{ - { R"(first_name)"sv, R"(Bruce)"sv }, - { R"(last_name)"sv, R"(Springsteen)"sv }, - }, - } }, - }; - REQUIRE(tbl == expected); - }); + { R"(apple)"sv, + toml::table{ + { R"(color)"sv, R"(red)"sv }, + { R"(seeds)"sv, + toml::array{ + toml::table{ + { R"(size)"sv, 2 }, + }, + } }, + } }, + } }, + }; + REQUIRE(tbl == expected); + }); + } - parsing_should_succeed(FILE_LINE_ARGS, - table_array_table_array, - [](toml::table&& tbl) // table-array-table-array - { - const auto expected = toml::table{ - { R"(a)"sv, - toml::array{ + SECTION("table-empty-name") + { + parsing_should_succeed(FILE_LINE_ARGS, + table_empty_name, + [](toml::table&& tbl) // table-empty-name + { + const auto expected = toml::table{ + { ""sv, + toml::table{ + { R"(x)"sv, 1 }, + { R"(a)"sv, + toml::table{ + { R"(x)"sv, 2 }, + } }, + } }, + { R"(a)"sv, + toml::table{ + { ""sv, + toml::table{ + { R"(x)"sv, 3 }, + } }, + } }, + }; + REQUIRE(tbl == expected); + }); + } + + SECTION("table-empty") + { + parsing_should_succeed(FILE_LINE_ARGS, + table_empty, + [](toml::table&& tbl) // table-empty + { + const auto expected = toml::table{ + { R"(a)"sv, toml::table{} }, + }; + REQUIRE(tbl == expected); + }); + } + + SECTION("table-keyword") + { + parsing_should_succeed(FILE_LINE_ARGS, + table_keyword, + [](toml::table&& tbl) // table-keyword + { + const auto expected = toml::table{ + { R"(true)"sv, toml::table{} }, + { R"(false)"sv, toml::table{} }, + { R"(inf)"sv, toml::table{} }, + { R"(nan)"sv, toml::table{} }, + }; + REQUIRE(tbl == expected); + }); + } + + SECTION("table-no-eol") + { + parsing_should_succeed(FILE_LINE_ARGS, + table_no_eol, + [](toml::table&& tbl) // table-no-eol + { + const auto expected = toml::table{ + { R"(table)"sv, toml::table{} }, + }; + REQUIRE(tbl == expected); + }); + } + + SECTION("table-sub-empty") + { + parsing_should_succeed(FILE_LINE_ARGS, + table_sub_empty, + [](toml::table&& tbl) // table-sub-empty + { + const auto expected = toml::table{ + { R"(a)"sv, + toml::table{ + { R"(b)"sv, toml::table{} }, + } }, + }; + REQUIRE(tbl == expected); + }); + } + + SECTION("table-sub") + { + parsing_should_succeed(FILE_LINE_ARGS, + table_sub, + [](toml::table&& tbl) // table-sub + { + const auto expected = toml::table{ + { R"(a)"sv, + toml::table{ + { R"(extend)"sv, + toml::table{ + { R"(key)"sv, 2 }, + { R"(more)"sv, + toml::table{ + { R"(key)"sv, 3 }, + } }, + } }, + { R"(key)"sv, 1 }, + } }, + }; + REQUIRE(tbl == expected); + }); + } + + SECTION("table-whitespace") + { + parsing_should_succeed(FILE_LINE_ARGS, + table_whitespace, + [](toml::table&& tbl) // table-whitespace + { + const auto expected = toml::table{ + { R"(valid key)"sv, toml::table{} }, + }; + REQUIRE(tbl == expected); + }); + } + + SECTION("table-with-literal-string") + { + parsing_should_succeed(FILE_LINE_ARGS, + table_with_literal_string, + [](toml::table&& tbl) // table-with-literal-string + { + const auto expected = toml::table{ + { R"(a)"sv, + toml::table{ + { R"("b")"sv, + toml::table{ + { R"(c)"sv, + toml::table{ + { R"(answer)"sv, 42 }, + } }, + } }, + } }, + }; + REQUIRE(tbl == expected); + }); + } + + SECTION("table-with-pound") + { + parsing_should_succeed(FILE_LINE_ARGS, + table_with_pound, + [](toml::table&& tbl) // table-with-pound + { + const auto expected = toml::table{ + { R"(key#group)"sv, + toml::table{ + { R"(answer)"sv, 42 }, + } }, + }; + REQUIRE(tbl == expected); + }); + } + + SECTION("table-with-single-quotes") + { + parsing_should_succeed(FILE_LINE_ARGS, + table_with_single_quotes, + [](toml::table&& tbl) // table-with-single-quotes + { + const auto expected = toml::table{ + { R"(a)"sv, toml::table{ { R"(b)"sv, - toml::array{ - toml::table{ - { R"(c)"sv, - toml::table{ - { R"(d)"sv, R"(val0)"sv }, - } }, - }, - toml::table{ - { R"(c)"sv, - toml::table{ - { R"(d)"sv, R"(val1)"sv }, - } }, - }, + toml::table{ + { R"(c)"sv, + toml::table{ + { R"(answer)"sv, 42 }, + } }, } }, - }, - } }, - }; - REQUIRE(tbl == expected); - }); + } }, + }; + REQUIRE(tbl == expected); + }); + } - parsing_should_succeed(FILE_LINE_ARGS, - table_empty, - [](toml::table&& tbl) // table-empty - { - const auto expected = toml::table{ - { R"(a)"sv, toml::table{} }, - }; - REQUIRE(tbl == expected); - }); - - parsing_should_succeed(FILE_LINE_ARGS, - table_keyword, - [](toml::table&& tbl) // table-keyword - { - const auto expected = toml::table{ - { R"(true)"sv, toml::table{} }, - { R"(false)"sv, toml::table{} }, - { R"(inf)"sv, toml::table{} }, - { R"(nan)"sv, toml::table{} }, - }; - REQUIRE(tbl == expected); - }); - - parsing_should_succeed(FILE_LINE_ARGS, - table_no_eol, - [](toml::table&& tbl) // table-no-eol - { - const auto expected = toml::table{ - { R"(table)"sv, toml::table{} }, - }; - REQUIRE(tbl == expected); - }); - - parsing_should_succeed(FILE_LINE_ARGS, - table_sub_empty, - [](toml::table&& tbl) // table-sub-empty - { - const auto expected = toml::table{ - { R"(a)"sv, - toml::table{ - { R"(b)"sv, toml::table{} }, - } }, - }; - REQUIRE(tbl == expected); - }); - - parsing_should_succeed(FILE_LINE_ARGS, - table_whitespace, - [](toml::table&& tbl) // table-whitespace - { - const auto expected = toml::table{ - { R"(valid key)"sv, toml::table{} }, - }; - REQUIRE(tbl == expected); - }); - - parsing_should_succeed(FILE_LINE_ARGS, - table_with_literal_string, - [](toml::table&& tbl) // table-with-literal-string - { - const auto expected = toml::table{ - { R"(a)"sv, - toml::table{ - { R"("b")"sv, - toml::table{ - { R"(c)"sv, - toml::table{ - { R"(answer)"sv, 42 }, - } }, - } }, - } }, - }; - REQUIRE(tbl == expected); - }); - - parsing_should_succeed(FILE_LINE_ARGS, - table_with_pound, - [](toml::table&& tbl) // table-with-pound - { - const auto expected = toml::table{ - { R"(key#group)"sv, - toml::table{ - { R"(answer)"sv, 42 }, - } }, - }; - REQUIRE(tbl == expected); - }); - - parsing_should_succeed(FILE_LINE_ARGS, - table_with_single_quotes, - [](toml::table&& tbl) // table-with-single-quotes - { - const auto expected = toml::table{ - { R"(a)"sv, - toml::table{ - { R"(b)"sv, - toml::table{ - { R"(c)"sv, - toml::table{ - { R"(answer)"sv, 42 }, - } }, - } }, - } }, - }; - REQUIRE(tbl == expected); - }); - - parsing_should_succeed(FILE_LINE_ARGS, - table_without_super, - [](toml::table&& tbl) // table-without-super - { - const auto expected = toml::table{ - { R"(x)"sv, - toml::table{ - { R"(y)"sv, - toml::table{ - { R"(z)"sv, - toml::table{ - { R"(w)"sv, toml::table{} }, - } }, - } }, - } }, - }; - REQUIRE(tbl == expected); - }); + SECTION("table-without-super") + { + parsing_should_succeed(FILE_LINE_ARGS, + table_without_super, + [](toml::table&& tbl) // table-without-super + { + const auto expected = toml::table{ + { R"(x)"sv, + toml::table{ + { R"(y)"sv, + toml::table{ + { R"(z)"sv, + toml::table{ + { R"(w)"sv, toml::table{} }, + } }, + } }, + } }, + }; + REQUIRE(tbl == expected); + }); + } #if UNICODE_LITERALS_OK - parsing_should_succeed(FILE_LINE_ARGS, - table_names, - [](toml::table&& tbl) // table-names - { - const auto expected = toml::table{ - { R"(a)"sv, - toml::table{ - { R"( x )"sv, toml::table{} }, - { R"(b)"sv, - toml::table{ - { R"(c)"sv, toml::table{} }, - } }, - { R"(b.c)"sv, toml::table{} }, - { R"(d.e)"sv, toml::table{} }, - } }, - { R"(d)"sv, - toml::table{ - { R"(e)"sv, - toml::table{ - { R"(f)"sv, toml::table{} }, - } }, - } }, - { R"(g)"sv, - toml::table{ - { R"(h)"sv, - toml::table{ - { R"(i)"sv, toml::table{} }, - } }, - } }, - { R"(j)"sv, - toml::table{ - { R"(ʞ)"sv, - toml::table{ - { R"(l)"sv, toml::table{} }, - } }, - } }, - { R"(x)"sv, - toml::table{ - { R"(1)"sv, - toml::table{ - { R"(2)"sv, toml::table{} }, - } }, - } }, - }; - REQUIRE(tbl == expected); - }); + SECTION("table-names") + { + parsing_should_succeed(FILE_LINE_ARGS, + table_names, + [](toml::table&& tbl) // table-names + { + const auto expected = toml::table{ + { R"(a)"sv, + toml::table{ + { R"( x )"sv, toml::table{} }, + { R"(b)"sv, + toml::table{ + { R"(c)"sv, toml::table{} }, + } }, + { R"(b.c)"sv, toml::table{} }, + { R"(d.e)"sv, toml::table{} }, + } }, + { R"(d)"sv, + toml::table{ + { R"(e)"sv, + toml::table{ + { R"(f)"sv, toml::table{} }, + } }, + } }, + { R"(g)"sv, + toml::table{ + { R"(h)"sv, + toml::table{ + { R"(i)"sv, toml::table{} }, + } }, + } }, + { R"(j)"sv, + toml::table{ + { R"(ʞ)"sv, + toml::table{ + { R"(l)"sv, toml::table{} }, + } }, + } }, + { R"(x)"sv, + toml::table{ + { R"(1)"sv, + toml::table{ + { R"(2)"sv, toml::table{} }, + } }, + } }, + }; + REQUIRE(tbl == expected); + }); + } #endif // UNICODE_LITERALS_OK } diff --git a/tests/conformance_iarna_invalid.cpp b/tests/conformance_iarna_invalid.cpp index 8544102..3ac007c 100644 --- a/tests/conformance_iarna_invalid.cpp +++ b/tests/conformance_iarna_invalid.cpp @@ -167,122 +167,285 @@ namespace TEST_CASE("conformance - iarna/invalid") { - parsing_should_fail(FILE_LINE_ARGS, array_of_tables_1); // array-of-tables-1 + SECTION("array-of-tables-1") + { + parsing_should_fail(FILE_LINE_ARGS, array_of_tables_1); // array-of-tables-1 + } - parsing_should_fail(FILE_LINE_ARGS, array_of_tables_2); // array-of-tables-2 + SECTION("array-of-tables-2") + { + parsing_should_fail(FILE_LINE_ARGS, array_of_tables_2); // array-of-tables-2 + } - parsing_should_fail(FILE_LINE_ARGS, bare_key_1); // bare-key-1 + SECTION("bare-key-1") + { + parsing_should_fail(FILE_LINE_ARGS, bare_key_1); // bare-key-1 + } - parsing_should_fail(FILE_LINE_ARGS, bare_key_2); // bare-key-2 + SECTION("bare-key-2") + { + parsing_should_fail(FILE_LINE_ARGS, bare_key_2); // bare-key-2 + } - parsing_should_fail(FILE_LINE_ARGS, bare_key_3); // bare-key-3 + SECTION("bare-key-3") + { + parsing_should_fail(FILE_LINE_ARGS, bare_key_3); // bare-key-3 + } - parsing_should_fail(FILE_LINE_ARGS, comment_control_1); // comment-control-1 + SECTION("comment-control-1") + { + parsing_should_fail(FILE_LINE_ARGS, comment_control_1); // comment-control-1 + } - parsing_should_fail(FILE_LINE_ARGS, comment_control_2); // comment-control-2 + SECTION("comment-control-2") + { + parsing_should_fail(FILE_LINE_ARGS, comment_control_2); // comment-control-2 + } - parsing_should_fail(FILE_LINE_ARGS, comment_control_3); // comment-control-3 + SECTION("comment-control-3") + { + parsing_should_fail(FILE_LINE_ARGS, comment_control_3); // comment-control-3 + } - parsing_should_fail(FILE_LINE_ARGS, comment_control_4); // comment-control-4 + SECTION("comment-control-4") + { + parsing_should_fail(FILE_LINE_ARGS, comment_control_4); // comment-control-4 + } - parsing_should_fail(FILE_LINE_ARGS, inline_table_imutable_1); // inline-table-imutable-1 + SECTION("inline-table-imutable-1") + { + parsing_should_fail(FILE_LINE_ARGS, inline_table_imutable_1); // inline-table-imutable-1 + } - parsing_should_fail(FILE_LINE_ARGS, inline_table_imutable_2); // inline-table-imutable-2 + SECTION("inline-table-imutable-2") + { + parsing_should_fail(FILE_LINE_ARGS, inline_table_imutable_2); // inline-table-imutable-2 + } #if !TOML_LANG_UNRELEASED - parsing_should_fail(FILE_LINE_ARGS, inline_table_trailing_comma); // inline-table-trailing-comma + SECTION("inline-table-trailing-comma") + { + parsing_should_fail(FILE_LINE_ARGS, inline_table_trailing_comma); // inline-table-trailing-comma + } #endif // !TOML_LANG_UNRELEASED - parsing_should_fail(FILE_LINE_ARGS, int_0_padded); // int-0-padded + SECTION("int-0-padded") + { + parsing_should_fail(FILE_LINE_ARGS, int_0_padded); // int-0-padded + } - parsing_should_fail(FILE_LINE_ARGS, int_signed_bin); // int-signed-bin + SECTION("int-signed-bin") + { + parsing_should_fail(FILE_LINE_ARGS, int_signed_bin); // int-signed-bin + } - parsing_should_fail(FILE_LINE_ARGS, int_signed_hex); // int-signed-hex + SECTION("int-signed-hex") + { + parsing_should_fail(FILE_LINE_ARGS, int_signed_hex); // int-signed-hex + } - parsing_should_fail(FILE_LINE_ARGS, int_signed_oct); // int-signed-oct + SECTION("int-signed-oct") + { + parsing_should_fail(FILE_LINE_ARGS, int_signed_oct); // int-signed-oct + } - parsing_should_fail(FILE_LINE_ARGS, key_value_pair_1); // key-value-pair-1 + SECTION("key-value-pair-1") + { + parsing_should_fail(FILE_LINE_ARGS, key_value_pair_1); // key-value-pair-1 + } - parsing_should_fail(FILE_LINE_ARGS, key_value_pair_2); // key-value-pair-2 + SECTION("key-value-pair-2") + { + parsing_should_fail(FILE_LINE_ARGS, key_value_pair_2); // key-value-pair-2 + } - parsing_should_fail(FILE_LINE_ARGS, multiple_dot_key); // multiple-dot-key + SECTION("multiple-dot-key") + { + parsing_should_fail(FILE_LINE_ARGS, multiple_dot_key); // multiple-dot-key + } - parsing_should_fail(FILE_LINE_ARGS, multiple_key); // multiple-key + SECTION("multiple-key") + { + parsing_should_fail(FILE_LINE_ARGS, multiple_key); // multiple-key + } - parsing_should_fail(FILE_LINE_ARGS, no_key_name); // no-key-name + SECTION("no-key-name") + { + parsing_should_fail(FILE_LINE_ARGS, no_key_name); // no-key-name + } - parsing_should_fail(FILE_LINE_ARGS, string_basic_control_1); // string-basic-control-1 + SECTION("string-basic-control-1") + { + parsing_should_fail(FILE_LINE_ARGS, string_basic_control_1); // string-basic-control-1 + } - parsing_should_fail(FILE_LINE_ARGS, string_basic_control_2); // string-basic-control-2 + SECTION("string-basic-control-2") + { + parsing_should_fail(FILE_LINE_ARGS, string_basic_control_2); // string-basic-control-2 + } - parsing_should_fail(FILE_LINE_ARGS, string_basic_control_3); // string-basic-control-3 + SECTION("string-basic-control-3") + { + parsing_should_fail(FILE_LINE_ARGS, string_basic_control_3); // string-basic-control-3 + } - parsing_should_fail(FILE_LINE_ARGS, string_basic_control_4); // string-basic-control-4 + SECTION("string-basic-control-4") + { + parsing_should_fail(FILE_LINE_ARGS, string_basic_control_4); // string-basic-control-4 + } - parsing_should_fail(FILE_LINE_ARGS, string_basic_multiline_control_1); // string-basic-multiline-control-1 + SECTION("string-basic-multiline-control-1") + { + parsing_should_fail(FILE_LINE_ARGS, string_basic_multiline_control_1); // string-basic-multiline-control-1 + } - parsing_should_fail(FILE_LINE_ARGS, string_basic_multiline_control_2); // string-basic-multiline-control-2 + SECTION("string-basic-multiline-control-2") + { + parsing_should_fail(FILE_LINE_ARGS, string_basic_multiline_control_2); // string-basic-multiline-control-2 + } - parsing_should_fail(FILE_LINE_ARGS, string_basic_multiline_control_3); // string-basic-multiline-control-3 + SECTION("string-basic-multiline-control-3") + { + parsing_should_fail(FILE_LINE_ARGS, string_basic_multiline_control_3); // string-basic-multiline-control-3 + } - parsing_should_fail(FILE_LINE_ARGS, string_basic_multiline_control_4); // string-basic-multiline-control-4 + SECTION("string-basic-multiline-control-4") + { + parsing_should_fail(FILE_LINE_ARGS, string_basic_multiline_control_4); // string-basic-multiline-control-4 + } - parsing_should_fail(FILE_LINE_ARGS, - string_basic_multiline_invalid_backslash); // string-basic-multiline-invalid-backslash + SECTION("string-basic-multiline-invalid-backslash") + { + parsing_should_fail(FILE_LINE_ARGS, + string_basic_multiline_invalid_backslash); // string-basic-multiline-invalid-backslash + } - parsing_should_fail( - FILE_LINE_ARGS, - string_basic_multiline_out_of_range_unicode_escape_1); // string-basic-multiline-out-of-range-unicode-escape-1 + SECTION("string-basic-multiline-out-of-range-unicode-escape-1") + { + parsing_should_fail( + FILE_LINE_ARGS, + string_basic_multiline_out_of_range_unicode_escape_1); // string-basic-multiline-out-of-range-unicode-escape-1 + } - parsing_should_fail( - FILE_LINE_ARGS, - string_basic_multiline_out_of_range_unicode_escape_2); // string-basic-multiline-out-of-range-unicode-escape-2 + SECTION("string-basic-multiline-out-of-range-unicode-escape-2") + { + parsing_should_fail( + FILE_LINE_ARGS, + string_basic_multiline_out_of_range_unicode_escape_2); // string-basic-multiline-out-of-range-unicode-escape-2 + } - parsing_should_fail(FILE_LINE_ARGS, string_basic_multiline_quotes); // string-basic-multiline-quotes + SECTION("string-basic-multiline-quotes") + { + parsing_should_fail(FILE_LINE_ARGS, string_basic_multiline_quotes); // string-basic-multiline-quotes + } - parsing_should_fail(FILE_LINE_ARGS, string_basic_multiline_unknown_escape); // string-basic-multiline-unknown-escape + SECTION("string-basic-multiline-unknown-escape") + { + parsing_should_fail(FILE_LINE_ARGS, + string_basic_multiline_unknown_escape); // string-basic-multiline-unknown-escape + } - parsing_should_fail(FILE_LINE_ARGS, - string_basic_out_of_range_unicode_escape_1); // string-basic-out-of-range-unicode-escape-1 + SECTION("string-basic-out-of-range-unicode-escape-1") + { + parsing_should_fail(FILE_LINE_ARGS, + string_basic_out_of_range_unicode_escape_1); // string-basic-out-of-range-unicode-escape-1 + } - parsing_should_fail(FILE_LINE_ARGS, - string_basic_out_of_range_unicode_escape_2); // string-basic-out-of-range-unicode-escape-2 + SECTION("string-basic-out-of-range-unicode-escape-2") + { + parsing_should_fail(FILE_LINE_ARGS, + string_basic_out_of_range_unicode_escape_2); // string-basic-out-of-range-unicode-escape-2 + } - parsing_should_fail(FILE_LINE_ARGS, string_basic_unknown_escape); // string-basic-unknown-escape + SECTION("string-basic-unknown-escape") + { + parsing_should_fail(FILE_LINE_ARGS, string_basic_unknown_escape); // string-basic-unknown-escape + } - parsing_should_fail(FILE_LINE_ARGS, string_literal_control_1); // string-literal-control-1 + SECTION("string-literal-control-1") + { + parsing_should_fail(FILE_LINE_ARGS, string_literal_control_1); // string-literal-control-1 + } - parsing_should_fail(FILE_LINE_ARGS, string_literal_control_2); // string-literal-control-2 + SECTION("string-literal-control-2") + { + parsing_should_fail(FILE_LINE_ARGS, string_literal_control_2); // string-literal-control-2 + } - parsing_should_fail(FILE_LINE_ARGS, string_literal_control_3); // string-literal-control-3 + SECTION("string-literal-control-3") + { + parsing_should_fail(FILE_LINE_ARGS, string_literal_control_3); // string-literal-control-3 + } - parsing_should_fail(FILE_LINE_ARGS, string_literal_control_4); // string-literal-control-4 + SECTION("string-literal-control-4") + { + parsing_should_fail(FILE_LINE_ARGS, string_literal_control_4); // string-literal-control-4 + } - parsing_should_fail(FILE_LINE_ARGS, string_literal_multiline_control_1); // string-literal-multiline-control-1 + SECTION("string-literal-multiline-control-1") + { + parsing_should_fail(FILE_LINE_ARGS, string_literal_multiline_control_1); // string-literal-multiline-control-1 + } - parsing_should_fail(FILE_LINE_ARGS, string_literal_multiline_control_2); // string-literal-multiline-control-2 + SECTION("string-literal-multiline-control-2") + { + parsing_should_fail(FILE_LINE_ARGS, string_literal_multiline_control_2); // string-literal-multiline-control-2 + } - parsing_should_fail(FILE_LINE_ARGS, string_literal_multiline_control_3); // string-literal-multiline-control-3 + SECTION("string-literal-multiline-control-3") + { + parsing_should_fail(FILE_LINE_ARGS, string_literal_multiline_control_3); // string-literal-multiline-control-3 + } - parsing_should_fail(FILE_LINE_ARGS, string_literal_multiline_control_4); // string-literal-multiline-control-4 + SECTION("string-literal-multiline-control-4") + { + parsing_should_fail(FILE_LINE_ARGS, string_literal_multiline_control_4); // string-literal-multiline-control-4 + } - parsing_should_fail(FILE_LINE_ARGS, string_literal_multiline_quotes); // string-literal-multiline-quotes + SECTION("string-literal-multiline-quotes") + { + parsing_should_fail(FILE_LINE_ARGS, string_literal_multiline_quotes); // string-literal-multiline-quotes + } - parsing_should_fail(FILE_LINE_ARGS, table_1); // table-1 + SECTION("table-1") + { + parsing_should_fail(FILE_LINE_ARGS, table_1); // table-1 + } - parsing_should_fail(FILE_LINE_ARGS, table_2); // table-2 + SECTION("table-2") + { + parsing_should_fail(FILE_LINE_ARGS, table_2); // table-2 + } - parsing_should_fail(FILE_LINE_ARGS, table_3); // table-3 + SECTION("table-3") + { + parsing_should_fail(FILE_LINE_ARGS, table_3); // table-3 + } - parsing_should_fail(FILE_LINE_ARGS, table_4); // table-4 + SECTION("table-4") + { + parsing_should_fail(FILE_LINE_ARGS, table_4); // table-4 + } - parsing_should_fail(FILE_LINE_ARGS, table_invalid_1); // table-invalid-1 + SECTION("table-invalid-1") + { + parsing_should_fail(FILE_LINE_ARGS, table_invalid_1); // table-invalid-1 + } - parsing_should_fail(FILE_LINE_ARGS, table_invalid_2); // table-invalid-2 + SECTION("table-invalid-2") + { + parsing_should_fail(FILE_LINE_ARGS, table_invalid_2); // table-invalid-2 + } - parsing_should_fail(FILE_LINE_ARGS, table_invalid_3); // table-invalid-3 + SECTION("table-invalid-3") + { + parsing_should_fail(FILE_LINE_ARGS, table_invalid_3); // table-invalid-3 + } - parsing_should_fail(FILE_LINE_ARGS, table_invalid_4); // table-invalid-4 + SECTION("table-invalid-4") + { + parsing_should_fail(FILE_LINE_ARGS, table_invalid_4); // table-invalid-4 + } } diff --git a/tests/conformance_iarna_valid.cpp b/tests/conformance_iarna_valid.cpp index f33f8d1..71a1522 100644 --- a/tests/conformance_iarna_valid.cpp +++ b/tests/conformance_iarna_valid.cpp @@ -291,1551 +291,1920 @@ def = 456)"sv; TEST_CASE("conformance - iarna/valid") { - parsing_should_succeed(FILE_LINE_ARGS, - spec_array_1, - [](toml::table&& tbl) // spec-array-1 - { - const auto expected = toml::table{ - { R"(integers)"sv, - toml::array{ - 1, - 2, - 3, - } }, - }; - REQUIRE(tbl == expected); - }); - - parsing_should_succeed(FILE_LINE_ARGS, - spec_array_2, - [](toml::table&& tbl) // spec-array-2 - { - const auto expected = toml::table{ - { R"(colors)"sv, - toml::array{ - R"(red)"sv, - R"(yellow)"sv, - R"(green)"sv, - } }, - }; - REQUIRE(tbl == expected); - }); - - parsing_should_succeed(FILE_LINE_ARGS, - spec_array_3, - [](toml::table&& tbl) // spec-array-3 - { - const auto expected = toml::table{ - { R"(nested_array_of_int)"sv, - toml::array{ + SECTION("spec-array-1") + { + parsing_should_succeed(FILE_LINE_ARGS, + spec_array_1, + [](toml::table&& tbl) // spec-array-1 + { + const auto expected = toml::table{ + { R"(integers)"sv, toml::array{ 1, 2, - }, - toml::array{ 3, - 4, - 5, - }, - } }, - }; - REQUIRE(tbl == expected); - }); + } }, + }; + REQUIRE(tbl == expected); + }); + } - parsing_should_succeed(FILE_LINE_ARGS, - spec_array_4, - [](toml::table&& tbl) // spec-array-4 - { - const auto expected = toml::table{ - { R"(string_array)"sv, - toml::array{ - R"(all)"sv, - R"(strings)"sv, - R"(are the same)"sv, - R"(type)"sv, - } }, - }; - REQUIRE(tbl == expected); - }); + SECTION("spec-array-2") + { + parsing_should_succeed(FILE_LINE_ARGS, + spec_array_2, + [](toml::table&& tbl) // spec-array-2 + { + const auto expected = toml::table{ + { R"(colors)"sv, + toml::array{ + R"(red)"sv, + R"(yellow)"sv, + R"(green)"sv, + } }, + }; + REQUIRE(tbl == expected); + }); + } - parsing_should_succeed(FILE_LINE_ARGS, - spec_array_5, - [](toml::table&& tbl) // spec-array-5 - { - const auto expected = toml::table{ - { R"(nested_mixed_array)"sv, - toml::array{ + SECTION("spec-array-3") + { + parsing_should_succeed(FILE_LINE_ARGS, + spec_array_3, + [](toml::table&& tbl) // spec-array-3 + { + const auto expected = toml::table{ + { R"(nested_array_of_int)"sv, + toml::array{ + toml::array{ + 1, + 2, + }, + toml::array{ + 3, + 4, + 5, + }, + } }, + }; + REQUIRE(tbl == expected); + }); + } + + SECTION("spec-array-4") + { + parsing_should_succeed(FILE_LINE_ARGS, + spec_array_4, + [](toml::table&& tbl) // spec-array-4 + { + const auto expected = toml::table{ + { R"(string_array)"sv, + toml::array{ + R"(all)"sv, + R"(strings)"sv, + R"(are the same)"sv, + R"(type)"sv, + } }, + }; + REQUIRE(tbl == expected); + }); + } + + SECTION("spec-array-5") + { + parsing_should_succeed(FILE_LINE_ARGS, + spec_array_5, + [](toml::table&& tbl) // spec-array-5 + { + const auto expected = toml::table{ + { R"(nested_mixed_array)"sv, + toml::array{ + toml::array{ + 1, + 2, + }, + toml::array{ + R"(a)"sv, + R"(b)"sv, + R"(c)"sv, + }, + } }, + }; + REQUIRE(tbl == expected); + }); + } + + SECTION("spec-array-7") + { + parsing_should_succeed(FILE_LINE_ARGS, + spec_array_7, + [](toml::table&& tbl) // spec-array-7 + { + const auto expected = toml::table{ + { R"(integers2)"sv, toml::array{ 1, 2, - }, + 3, + } }, + }; + REQUIRE(tbl == expected); + }); + } + + SECTION("spec-array-8") + { + parsing_should_succeed(FILE_LINE_ARGS, + spec_array_8, + [](toml::table&& tbl) // spec-array-8 + { + const auto expected = toml::table{ + { R"(integers3)"sv, toml::array{ - R"(a)"sv, - R"(b)"sv, - R"(c)"sv, - }, - } }, - }; - REQUIRE(tbl == expected); - }); + 1, + 2, + } }, + }; + REQUIRE(tbl == expected); + }); + } - parsing_should_succeed(FILE_LINE_ARGS, - spec_array_7, - [](toml::table&& tbl) // spec-array-7 - { - const auto expected = toml::table{ - { R"(integers2)"sv, - toml::array{ - 1, - 2, - 3, - } }, - }; - REQUIRE(tbl == expected); - }); + SECTION("spec-array-mixed-number-types") + { + parsing_should_succeed(FILE_LINE_ARGS, + spec_array_mixed_number_types, + [](toml::table&& tbl) // spec-array-mixed-number-types + { + const auto expected = toml::table{ + { R"(numbers)"sv, + toml::array{ + 0.1, + 0.2, + 0.5, + 1, + 2, + 5, + } }, + }; + REQUIRE(tbl == expected); + }); + } - parsing_should_succeed(FILE_LINE_ARGS, - spec_array_8, - [](toml::table&& tbl) // spec-array-8 - { - const auto expected = toml::table{ - { R"(integers3)"sv, - toml::array{ - 1, - 2, - } }, - }; - REQUIRE(tbl == expected); - }); + SECTION("spec-array-more-mixed-types") + { + parsing_should_succeed(FILE_LINE_ARGS, + spec_array_more_mixed_types, + [](toml::table&& tbl) // spec-array-more-mixed-types + { + const auto expected = toml::table{ + { R"(contributors)"sv, + toml::array{ + R"(Foo Bar )"sv, + toml::table{ + { R"(name)"sv, R"(Baz Qux)"sv }, + { R"(email)"sv, R"(bazqux@example.com)"sv }, + { R"(url)"sv, R"(https://example.com/bazqux)"sv }, + }, + } }, + }; + REQUIRE(tbl == expected); + }); + } - parsing_should_succeed(FILE_LINE_ARGS, - spec_array_mixed_number_types, - [](toml::table&& tbl) // spec-array-mixed-number-types - { - const auto expected = toml::table{ - { R"(numbers)"sv, - toml::array{ - 0.1, - 0.2, - 0.5, - 1, - 2, - 5, - } }, - }; - REQUIRE(tbl == expected); - }); + SECTION("spec-array-of-tables-1") + { + parsing_should_succeed(FILE_LINE_ARGS, + spec_array_of_tables_1, + [](toml::table&& tbl) // spec-array-of-tables-1 + { + const auto expected = toml::table{ + { R"(products)"sv, + toml::array{ + toml::table{ + { R"(name)"sv, R"(Hammer)"sv }, + { R"(sku)"sv, 738594937 }, + }, + toml::table{}, + toml::table{ + { R"(name)"sv, R"(Nail)"sv }, + { R"(sku)"sv, 284758393 }, + { R"(color)"sv, R"(gray)"sv }, + }, + } }, + }; + REQUIRE(tbl == expected); + }); + } - parsing_should_succeed(FILE_LINE_ARGS, - spec_array_more_mixed_types, - [](toml::table&& tbl) // spec-array-more-mixed-types - { - const auto expected = toml::table{ - { R"(contributors)"sv, - toml::array{ - R"(Foo Bar )"sv, + SECTION("spec-array-of-tables-2") + { + parsing_should_succeed(FILE_LINE_ARGS, + spec_array_of_tables_2, + [](toml::table&& tbl) // spec-array-of-tables-2 + { + const auto expected = toml::table{ + { R"(fruit)"sv, + toml::array{ + toml::table{ + { R"(name)"sv, R"(apple)"sv }, + { R"(physical)"sv, + toml::table{ + { R"(color)"sv, R"(red)"sv }, + { R"(shape)"sv, R"(round)"sv }, + } }, + { R"(variety)"sv, + toml::array{ + toml::table{ + { R"(name)"sv, R"(red delicious)"sv }, + }, + toml::table{ + { R"(name)"sv, R"(granny smith)"sv }, + }, + } }, + }, + toml::table{ + { R"(name)"sv, R"(banana)"sv }, + { R"(variety)"sv, + toml::array{ + toml::table{ + { R"(name)"sv, R"(plantain)"sv }, + }, + } }, + }, + } }, + }; + REQUIRE(tbl == expected); + }); + } + + SECTION("spec-array-of-tables-3") + { + parsing_should_succeed(FILE_LINE_ARGS, + spec_array_of_tables_3, + [](toml::table&& tbl) // spec-array-of-tables-3 + { + const auto expected = toml::table{ + { R"(points)"sv, + toml::array{ + toml::table{ + { R"(x)"sv, 1 }, + { R"(y)"sv, 2 }, + { R"(z)"sv, 3 }, + }, + toml::table{ + { R"(x)"sv, 7 }, + { R"(y)"sv, 8 }, + { R"(z)"sv, 9 }, + }, + toml::table{ + { R"(x)"sv, 2 }, + { R"(y)"sv, 4 }, + { R"(z)"sv, 8 }, + }, + } }, + }; + REQUIRE(tbl == expected); + }); + } + + SECTION("spec-boolean-1") + { + parsing_should_succeed(FILE_LINE_ARGS, + spec_boolean_1, + [](toml::table&& tbl) // spec-boolean-1 + { + const auto expected = toml::table{ + { R"(bool1)"sv, true }, + }; + REQUIRE(tbl == expected); + }); + } + + SECTION("spec-boolean-2") + { + parsing_should_succeed(FILE_LINE_ARGS, + spec_boolean_2, + [](toml::table&& tbl) // spec-boolean-2 + { + const auto expected = toml::table{ + { R"(bool1)"sv, false }, + }; + REQUIRE(tbl == expected); + }); + } + + SECTION("spec-case-sensitive") + { + parsing_should_succeed(FILE_LINE_ARGS, + spec_case_sensitive, + [](toml::table&& tbl) // spec-case-sensitive + { + const auto expected = toml::table{ + { R"(abc)"sv, 123 }, + { R"(ABC)"sv, 456 }, + }; + REQUIRE(tbl == expected); + }); + } + + SECTION("spec-comment-mid-array") + { + parsing_should_succeed(FILE_LINE_ARGS, + spec_comment_mid_array, + [](toml::table&& tbl) // spec-comment-mid-array + { + const auto expected = toml::table{ + { R"(abc)"sv, + toml::array{ + 123, + 456, + } }, + }; + REQUIRE(tbl == expected); + }); + } + + SECTION("spec-comment-mid-string") + { + parsing_should_succeed(FILE_LINE_ARGS, + spec_comment_mid_string, + [](toml::table&& tbl) // spec-comment-mid-string + { + const auto expected = toml::table{ + { R"(another)"sv, R"(# This is not a comment)"sv }, + }; + REQUIRE(tbl == expected); + }); + } + + SECTION("spec-comment-tab") + { + parsing_should_succeed(FILE_LINE_ARGS, + spec_comment_tab, + [](toml::table&& tbl) // spec-comment-tab + { + const auto expected = toml::table{ + { R"(key)"sv, R"(value)"sv }, + }; + REQUIRE(tbl == expected); + }); + } + + SECTION("spec-comment") + { + parsing_should_succeed(FILE_LINE_ARGS, + spec_comment, + [](toml::table&& tbl) // spec-comment + { + const auto expected = toml::table{ + { R"(key)"sv, R"(value)"sv }, + }; + REQUIRE(tbl == expected); + }); + } + + SECTION("spec-date-local-1") + { + parsing_should_succeed(FILE_LINE_ARGS, + spec_date_local_1, + [](toml::table&& tbl) // spec-date-local-1 + { + const auto expected = toml::table{ + { R"(ld1)"sv, toml::date{ 1979, 5, 27 } }, + }; + REQUIRE(tbl == expected); + }); + } + + SECTION("spec-date-time-1") + { + parsing_should_succeed(FILE_LINE_ARGS, + spec_date_time_1, + [](toml::table&& tbl) // spec-date-time-1 + { + const auto expected = toml::table{ + { R"(odt1)"sv, toml::date_time{ { 1979, 5, 27 }, { 7, 32 }, { 0, 0 } } }, + }; + REQUIRE(tbl == expected); + }); + } + + SECTION("spec-date-time-2") + { + parsing_should_succeed(FILE_LINE_ARGS, + spec_date_time_2, + [](toml::table&& tbl) // spec-date-time-2 + { + const auto expected = toml::table{ + { R"(odt2)"sv, toml::date_time{ { 1979, 5, 27 }, { 0, 32 }, { -7, 0 } } }, + }; + REQUIRE(tbl == expected); + }); + } + + SECTION("spec-date-time-3") + { + parsing_should_succeed( + FILE_LINE_ARGS, + spec_date_time_3, + [](toml::table&& tbl) // spec-date-time-3 + { + const auto expected = toml::table{ + { R"(odt3)"sv, toml::date_time{ { 1979, 5, 27 }, { 0, 32, 0, 999999000 }, { -7, 0 } } }, + }; + REQUIRE(tbl == expected); + }); + } + + SECTION("spec-date-time-4") + { + parsing_should_succeed(FILE_LINE_ARGS, + spec_date_time_4, + [](toml::table&& tbl) // spec-date-time-4 + { + const auto expected = toml::table{ + { R"(odt4)"sv, toml::date_time{ { 1979, 5, 27 }, { 7, 32 }, { 0, 0 } } }, + }; + REQUIRE(tbl == expected); + }); + } + + SECTION("spec-date-time-5") + { + parsing_should_succeed( + FILE_LINE_ARGS, + spec_date_time_5, + [](toml::table&& tbl) // spec-date-time-5 + { + const auto expected = toml::table{ + { R"(odt5)"sv, toml::date_time{ { 1979, 5, 27 }, { 7, 32, 0, 123000000 }, { 0, 0 } } }, + }; + REQUIRE(tbl == expected); + }); + } + + SECTION("spec-date-time-local-1") + { + parsing_should_succeed(FILE_LINE_ARGS, + spec_date_time_local_1, + [](toml::table&& tbl) // spec-date-time-local-1 + { + const auto expected = toml::table{ + { R"(ldt1)"sv, toml::date_time{ { 1979, 5, 27 }, { 7, 32 } } }, + }; + REQUIRE(tbl == expected); + }); + } + + SECTION("spec-dotted-keys-1") + { + parsing_should_succeed(FILE_LINE_ARGS, + spec_dotted_keys_1, + [](toml::table&& tbl) // spec-dotted-keys-1 + { + const auto expected = toml::table{ + { R"(name)"sv, R"(Orange)"sv }, + { R"(physical)"sv, toml::table{ - { R"(name)"sv, R"(Baz Qux)"sv }, - { R"(email)"sv, R"(bazqux@example.com)"sv }, - { R"(url)"sv, R"(https://example.com/bazqux)"sv }, - }, - } }, - }; - REQUIRE(tbl == expected); - }); + { R"(color)"sv, R"(orange)"sv }, + { R"(shape)"sv, R"(round)"sv }, + } }, + { R"(site)"sv, + toml::table{ + { R"(google.com)"sv, true }, + } }, + }; + REQUIRE(tbl == expected); + }); + } - parsing_should_succeed(FILE_LINE_ARGS, - spec_array_of_tables_1, - [](toml::table&& tbl) // spec-array-of-tables-1 - { - const auto expected = toml::table{ - { R"(products)"sv, - toml::array{ + SECTION("spec-dotted-keys-2") + { + parsing_should_succeed(FILE_LINE_ARGS, + spec_dotted_keys_2, + [](toml::table&& tbl) // spec-dotted-keys-2 + { + const auto expected = toml::table{ + { R"(a)"sv, toml::table{ - { R"(name)"sv, R"(Hammer)"sv }, - { R"(sku)"sv, 738594937 }, - }, - toml::table{}, - toml::table{ - { R"(name)"sv, R"(Nail)"sv }, - { R"(sku)"sv, 284758393 }, - { R"(color)"sv, R"(gray)"sv }, - }, - } }, - }; - REQUIRE(tbl == expected); - }); + { R"(b)"sv, 23 }, + } }, + }; + REQUIRE(tbl == expected); + }); + } - parsing_should_succeed(FILE_LINE_ARGS, - spec_array_of_tables_2, - [](toml::table&& tbl) // spec-array-of-tables-2 - { - const auto expected = toml::table{ - { R"(fruit)"sv, - toml::array{ + SECTION("spec-dotted-keys-3") + { + parsing_should_succeed(FILE_LINE_ARGS, + spec_dotted_keys_3, + [](toml::table&& tbl) // spec-dotted-keys-3 + { + const auto expected = toml::table{ + { R"(a)"sv, toml::table{ - { R"(name)"sv, R"(apple)"sv }, - { R"(physical)"sv, + { R"(b)"sv, 23 }, + } }, + }; + REQUIRE(tbl == expected); + }); + } + + SECTION("spec-empty-key-name-1") + { + parsing_should_succeed(FILE_LINE_ARGS, + spec_empty_key_name_1, + [](toml::table&& tbl) // spec-empty-key-name-1 + { + const auto expected = toml::table{ + { ""sv, R"(blank)"sv }, + }; + REQUIRE(tbl == expected); + }); + } + + SECTION("spec-empty-key-name-2") + { + parsing_should_succeed(FILE_LINE_ARGS, + spec_empty_key_name_2, + [](toml::table&& tbl) // spec-empty-key-name-2 + { + const auto expected = toml::table{ + { ""sv, R"(blank)"sv }, + }; + REQUIRE(tbl == expected); + }); + } + + SECTION("spec-extend-dotted-object-1") + { + parsing_should_succeed(FILE_LINE_ARGS, + spec_extend_dotted_object_1, + [](toml::table&& tbl) // spec-extend-dotted-object-1 + { + const auto expected = toml::table{ + { R"(fruit)"sv, + toml::table{ + { R"(apple)"sv, toml::table{ - { R"(color)"sv, R"(red)"sv }, - { R"(shape)"sv, R"(round)"sv }, + { R"(smooth)"sv, true }, } }, - { R"(variety)"sv, + { R"(orange)"sv, 2 }, + } }, + }; + REQUIRE(tbl == expected); + }); + } + + SECTION("spec-extend-dotted-object-2") + { + parsing_should_succeed(FILE_LINE_ARGS, + spec_extend_dotted_object_2, + [](toml::table&& tbl) // spec-extend-dotted-object-2 + { + const auto expected = toml::table{ + { R"(apple)"sv, + toml::table{ + { R"(type)"sv, R"(fruit)"sv }, + { R"(skin)"sv, R"(thin)"sv }, + { R"(color)"sv, R"(red)"sv }, + } }, + { R"(orange)"sv, + toml::table{ + { R"(type)"sv, R"(fruit)"sv }, + { R"(skin)"sv, R"(thick)"sv }, + { R"(color)"sv, R"(orange)"sv }, + } }, + }; + REQUIRE(tbl == expected); + }); + } + + SECTION("spec-extend-dotted-object-3") + { + parsing_should_succeed(FILE_LINE_ARGS, + spec_extend_dotted_object_3, + [](toml::table&& tbl) // spec-extend-dotted-object-3 + { + const auto expected = toml::table{ + { R"(apple)"sv, + toml::table{ + { R"(type)"sv, R"(fruit)"sv }, + { R"(skin)"sv, R"(thin)"sv }, + { R"(color)"sv, R"(red)"sv }, + } }, + { R"(orange)"sv, + toml::table{ + { R"(type)"sv, R"(fruit)"sv }, + { R"(skin)"sv, R"(thick)"sv }, + { R"(color)"sv, R"(orange)"sv }, + } }, + }; + REQUIRE(tbl == expected); + }); + } + + SECTION("spec-float-1") + { + parsing_should_succeed(FILE_LINE_ARGS, + spec_float_1, + [](toml::table&& tbl) // spec-float-1 + { + const auto expected = toml::table{ + { R"(flt1)"sv, 1.0 }, + }; + REQUIRE(tbl == expected); + }); + } + + SECTION("spec-float-10") + { + parsing_should_succeed(FILE_LINE_ARGS, + spec_float_10, + [](toml::table&& tbl) // spec-float-10 + { + const auto expected = toml::table{ + { R"(sf1)"sv, std::numeric_limits::infinity() }, + }; + REQUIRE(tbl == expected); + }); + } + + SECTION("spec-float-11") + { + parsing_should_succeed(FILE_LINE_ARGS, + spec_float_11, + [](toml::table&& tbl) // spec-float-11 + { + const auto expected = toml::table{ + { R"(sf2)"sv, std::numeric_limits::infinity() }, + }; + REQUIRE(tbl == expected); + }); + } + + SECTION("spec-float-12") + { + parsing_should_succeed(FILE_LINE_ARGS, + spec_float_12, + [](toml::table&& tbl) // spec-float-12 + { + const auto expected = toml::table{ + { R"(sf2)"sv, -std::numeric_limits::infinity() }, + }; + REQUIRE(tbl == expected); + }); + } + + SECTION("spec-float-13") + { + parsing_should_succeed(FILE_LINE_ARGS, + spec_float_13, + [](toml::table&& tbl) // spec-float-13 + { + const auto expected = toml::table{ + { R"(sf4)"sv, std::numeric_limits::quiet_NaN() }, + }; + REQUIRE(tbl == expected); + }); + } + + SECTION("spec-float-14") + { + parsing_should_succeed(FILE_LINE_ARGS, + spec_float_14, + [](toml::table&& tbl) // spec-float-14 + { + const auto expected = toml::table{ + { R"(sf5)"sv, std::numeric_limits::quiet_NaN() }, + }; + REQUIRE(tbl == expected); + }); + } + + SECTION("spec-float-15") + { + parsing_should_succeed(FILE_LINE_ARGS, + spec_float_15, + [](toml::table&& tbl) // spec-float-15 + { + const auto expected = toml::table{ + { R"(sf6)"sv, std::numeric_limits::quiet_NaN() }, + }; + REQUIRE(tbl == expected); + }); + } + + SECTION("spec-float-2") + { + parsing_should_succeed(FILE_LINE_ARGS, + spec_float_2, + [](toml::table&& tbl) // spec-float-2 + { + const auto expected = toml::table{ + { R"(flt2)"sv, 3.1415 }, + }; + REQUIRE(tbl == expected); + }); + } + + SECTION("spec-float-3") + { + parsing_should_succeed(FILE_LINE_ARGS, + spec_float_3, + [](toml::table&& tbl) // spec-float-3 + { + const auto expected = toml::table{ + { R"(flt3)"sv, -0.01 }, + }; + REQUIRE(tbl == expected); + }); + } + + SECTION("spec-float-4") + { + parsing_should_succeed(FILE_LINE_ARGS, + spec_float_4, + [](toml::table&& tbl) // spec-float-4 + { + const auto expected = toml::table{ + { R"(flt4)"sv, 5e+22 }, + }; + REQUIRE(tbl == expected); + }); + } + + SECTION("spec-float-5") + { + parsing_should_succeed(FILE_LINE_ARGS, + spec_float_5, + [](toml::table&& tbl) // spec-float-5 + { + const auto expected = toml::table{ + { R"(flt5)"sv, 1000000.0 }, + }; + REQUIRE(tbl == expected); + }); + } + + SECTION("spec-float-6") + { + parsing_should_succeed(FILE_LINE_ARGS, + spec_float_6, + [](toml::table&& tbl) // spec-float-6 + { + const auto expected = toml::table{ + { R"(flt6)"sv, -0.02 }, + }; + REQUIRE(tbl == expected); + }); + } + + SECTION("spec-float-7") + { + parsing_should_succeed(FILE_LINE_ARGS, + spec_float_7, + [](toml::table&& tbl) // spec-float-7 + { + const auto expected = toml::table{ + { R"(flt7)"sv, 6.626e-34 }, + }; + REQUIRE(tbl == expected); + }); + } + + SECTION("spec-float-8") + { + parsing_should_succeed(FILE_LINE_ARGS, + spec_float_8, + [](toml::table&& tbl) // spec-float-8 + { + const auto expected = toml::table{ + { R"(flt8)"sv, 224617.445991228 }, + }; + REQUIRE(tbl == expected); + }); + } + + SECTION("spec-float-9") + { + parsing_should_succeed(FILE_LINE_ARGS, + spec_float_9, + [](toml::table&& tbl) // spec-float-9 + { + const auto expected = toml::table{ + { R"(flt9)"sv, -0.0 }, + }; + REQUIRE(tbl == expected); + }); + } + + SECTION("spec-int-1") + { + parsing_should_succeed(FILE_LINE_ARGS, + spec_int_1, + [](toml::table&& tbl) // spec-int-1 + { + const auto expected = toml::table{ + { R"(int1)"sv, 99 }, + }; + REQUIRE(tbl == expected); + }); + } + + SECTION("spec-int-2") + { + parsing_should_succeed(FILE_LINE_ARGS, + spec_int_2, + [](toml::table&& tbl) // spec-int-2 + { + const auto expected = toml::table{ + { R"(int2)"sv, 42 }, + }; + REQUIRE(tbl == expected); + }); + } + + SECTION("spec-int-3") + { + parsing_should_succeed(FILE_LINE_ARGS, + spec_int_3, + [](toml::table&& tbl) // spec-int-3 + { + const auto expected = toml::table{ + { R"(int3)"sv, 0 }, + }; + REQUIRE(tbl == expected); + }); + } + + SECTION("spec-int-3a") + { + parsing_should_succeed(FILE_LINE_ARGS, + spec_int_3a, + [](toml::table&& tbl) // spec-int-3a + { + const auto expected = toml::table{ + { R"(int3)"sv, 0 }, + }; + REQUIRE(tbl == expected); + }); + } + + SECTION("spec-int-3b") + { + parsing_should_succeed(FILE_LINE_ARGS, + spec_int_3b, + [](toml::table&& tbl) // spec-int-3b + { + const auto expected = toml::table{ + { R"(int3)"sv, 0 }, + }; + REQUIRE(tbl == expected); + }); + } + + SECTION("spec-int-4") + { + parsing_should_succeed(FILE_LINE_ARGS, + spec_int_4, + [](toml::table&& tbl) // spec-int-4 + { + const auto expected = toml::table{ + { R"(int4)"sv, -17 }, + }; + REQUIRE(tbl == expected); + }); + } + + SECTION("spec-int-5") + { + parsing_should_succeed(FILE_LINE_ARGS, + spec_int_5, + [](toml::table&& tbl) // spec-int-5 + { + const auto expected = toml::table{ + { R"(int5)"sv, 1000 }, + }; + REQUIRE(tbl == expected); + }); + } + + SECTION("spec-int-6") + { + parsing_should_succeed(FILE_LINE_ARGS, + spec_int_6, + [](toml::table&& tbl) // spec-int-6 + { + const auto expected = toml::table{ + { R"(int6)"sv, 5349221 }, + }; + REQUIRE(tbl == expected); + }); + } + + SECTION("spec-int-7") + { + parsing_should_succeed(FILE_LINE_ARGS, + spec_int_7, + [](toml::table&& tbl) // spec-int-7 + { + const auto expected = toml::table{ + { R"(int7)"sv, 12345 }, + }; + REQUIRE(tbl == expected); + }); + } + + SECTION("spec-int-bin1") + { + parsing_should_succeed(FILE_LINE_ARGS, + spec_int_bin1, + [](toml::table&& tbl) // spec-int-bin1 + { + const auto expected = toml::table{ + { R"(bin1)"sv, 214 }, + }; + REQUIRE(tbl == expected); + }); + } + + SECTION("spec-int-hex1") + { + parsing_should_succeed(FILE_LINE_ARGS, + spec_int_hex1, + [](toml::table&& tbl) // spec-int-hex1 + { + const auto expected = toml::table{ + { R"(hex1)"sv, 3735928559 }, + }; + REQUIRE(tbl == expected); + }); + } + + SECTION("spec-int-hex2") + { + parsing_should_succeed(FILE_LINE_ARGS, + spec_int_hex2, + [](toml::table&& tbl) // spec-int-hex2 + { + const auto expected = toml::table{ + { R"(hex2)"sv, 3735928559 }, + }; + REQUIRE(tbl == expected); + }); + } + + SECTION("spec-int-hex3") + { + parsing_should_succeed(FILE_LINE_ARGS, + spec_int_hex3, + [](toml::table&& tbl) // spec-int-hex3 + { + const auto expected = toml::table{ + { R"(hex3)"sv, 3735928559 }, + }; + REQUIRE(tbl == expected); + }); + } + + SECTION("spec-int-max") + { + parsing_should_succeed(FILE_LINE_ARGS, + spec_int_max, + [](toml::table&& tbl) // spec-int-max + { + const auto expected = toml::table{ + { R"(max)"sv, std::numeric_limits::max() }, + }; + REQUIRE(tbl == expected); + }); + } + + SECTION("spec-int-min") + { + parsing_should_succeed(FILE_LINE_ARGS, + spec_int_min, + [](toml::table&& tbl) // spec-int-min + { + const auto expected = toml::table{ + { R"(min)"sv, std::numeric_limits::min() }, + }; + REQUIRE(tbl == expected); + }); + } + + SECTION("spec-int-oct1") + { + parsing_should_succeed(FILE_LINE_ARGS, + spec_int_oct1, + [](toml::table&& tbl) // spec-int-oct1 + { + const auto expected = toml::table{ + { R"(oct1)"sv, 342391 }, + }; + REQUIRE(tbl == expected); + }); + } + + SECTION("spec-int-oct2") + { + parsing_should_succeed(FILE_LINE_ARGS, + spec_int_oct2, + [](toml::table&& tbl) // spec-int-oct2 + { + const auto expected = toml::table{ + { R"(oct2)"sv, 493 }, + }; + REQUIRE(tbl == expected); + }); + } + + SECTION("spec-key-value-pair-1") + { + parsing_should_succeed(FILE_LINE_ARGS, + spec_key_value_pair_1, + [](toml::table&& tbl) // spec-key-value-pair-1 + { + const auto expected = toml::table{ + { R"(key)"sv, R"(value)"sv }, + }; + REQUIRE(tbl == expected); + }); + } + + SECTION("spec-key-value-pair-2") + { + parsing_should_succeed(FILE_LINE_ARGS, + spec_key_value_pair_2, + [](toml::table&& tbl) // spec-key-value-pair-2 + { + const auto expected = toml::table{ + { R"(bare_key)"sv, R"(value)"sv }, + }; + REQUIRE(tbl == expected); + }); + } + + SECTION("spec-key-value-pair-3") + { + parsing_should_succeed(FILE_LINE_ARGS, + spec_key_value_pair_3, + [](toml::table&& tbl) // spec-key-value-pair-3 + { + const auto expected = toml::table{ + { R"(bare-key)"sv, R"(value)"sv }, + }; + REQUIRE(tbl == expected); + }); + } + + SECTION("spec-key-value-pair-4") + { + parsing_should_succeed(FILE_LINE_ARGS, + spec_key_value_pair_4, + [](toml::table&& tbl) // spec-key-value-pair-4 + { + const auto expected = toml::table{ + { R"(1234)"sv, R"(value)"sv }, + }; + REQUIRE(tbl == expected); + }); + } + + SECTION("spec-key-value-pair-5") + { + parsing_should_succeed(FILE_LINE_ARGS, + spec_key_value_pair_5, + [](toml::table&& tbl) // spec-key-value-pair-5 + { + const auto expected = toml::table{ + { R"(1234)"sv, R"(value)"sv }, + }; + REQUIRE(tbl == expected); + }); + } + + SECTION("spec-key-value-pair-6") + { + parsing_should_succeed(FILE_LINE_ARGS, + spec_key_value_pair_6, + [](toml::table&& tbl) // spec-key-value-pair-6 + { + const auto expected = toml::table{ + { R"(-)"sv, 1 }, + }; + REQUIRE(tbl == expected); + }); + } + + SECTION("spec-key-value-pair-7") + { + parsing_should_succeed(FILE_LINE_ARGS, + spec_key_value_pair_7, + [](toml::table&& tbl) // spec-key-value-pair-7 + { + const auto expected = toml::table{ + { R"(_)"sv, 1 }, + }; + REQUIRE(tbl == expected); + }); + } + + SECTION("spec-key-value-pair-8") + { + parsing_should_succeed(FILE_LINE_ARGS, + spec_key_value_pair_8, + [](toml::table&& tbl) // spec-key-value-pair-8 + { + const auto expected = toml::table{ + { R"(-_-_-_-_-)"sv, 1 }, + }; + REQUIRE(tbl == expected); + }); + } + + SECTION("spec-key-value-pair-9") + { + parsing_should_succeed(FILE_LINE_ARGS, + spec_key_value_pair_9, + [](toml::table&& tbl) // spec-key-value-pair-9 + { + const auto expected = toml::table{ + { R"(3)"sv, + toml::table{ + { R"(14159)"sv, R"(pi)"sv }, + } }, + }; + REQUIRE(tbl == expected); + }); + } + + SECTION("spec-newline-1") + { + parsing_should_succeed(FILE_LINE_ARGS, + spec_newline_1, + [](toml::table&& tbl) // spec-newline-1 + { + const auto expected = toml::table{ + { R"(abc)"sv, 123 }, + { R"(def)"sv, 456 }, + }; + REQUIRE(tbl == expected); + }); + } + + SECTION("spec-newline-2") + { + parsing_should_succeed(FILE_LINE_ARGS, + spec_newline_2, + [](toml::table&& tbl) // spec-newline-2 + { + const auto expected = toml::table{ + { R"(abc)"sv, 123 }, + { R"(def)"sv, 456 }, + }; + REQUIRE(tbl == expected); + }); + } + + SECTION("spec-newline-3") + { + parsing_should_succeed(FILE_LINE_ARGS, + spec_newline_3, + [](toml::table&& tbl) // spec-newline-3 + { + const auto expected = toml::table{ + { R"(abc)"sv, 123 }, + { R"(def)"sv, 456 }, + { R"(ghi)"sv, 789 }, + }; + REQUIRE(tbl == expected); + }); + } + + SECTION("spec-quoted-literal-keys-1") + { + parsing_should_succeed(FILE_LINE_ARGS, + spec_quoted_literal_keys_1, + [](toml::table&& tbl) // spec-quoted-literal-keys-1 + { + const auto expected = toml::table{ + { R"(quoted "value")"sv, R"(value)"sv }, + }; + REQUIRE(tbl == expected); + }); + } + + SECTION("spec-readme-example") + { + parsing_should_succeed(FILE_LINE_ARGS, + spec_readme_example, + [](toml::table&& tbl) // spec-readme-example + { + const auto expected = toml::table{ + { R"(title)"sv, R"(TOML Example)"sv }, + { R"(owner)"sv, + toml::table{ + { R"(name)"sv, R"(Tom Preston-Werner)"sv }, + { R"(dob)"sv, toml::date_time{ { 1979, 5, 27 }, { 7, 32 }, { -8, 0 } } }, + } }, + { R"(database)"sv, + toml::table{ + { R"(server)"sv, R"(192.168.1.1)"sv }, + { R"(ports)"sv, toml::array{ - toml::table{ - { R"(name)"sv, R"(red delicious)"sv }, + 8001, + 8001, + 8002, + } }, + { R"(connection_max)"sv, 5000 }, + { R"(enabled)"sv, true }, + } }, + { R"(servers)"sv, + toml::table{ + { R"(alpha)"sv, + toml::table{ + { R"(ip)"sv, R"(10.0.0.1)"sv }, + { R"(dc)"sv, R"(eqdc10)"sv }, + } }, + { R"(beta)"sv, + toml::table{ + { R"(ip)"sv, R"(10.0.0.2)"sv }, + { R"(dc)"sv, R"(eqdc10)"sv }, + } }, + } }, + { R"(clients)"sv, + toml::table{ + { R"(data)"sv, + toml::array{ + toml::array{ + R"(gamma)"sv, + R"(delta)"sv, }, - toml::table{ - { R"(name)"sv, R"(granny smith)"sv }, + toml::array{ + 1, + 2, }, } }, - }, - toml::table{ - { R"(name)"sv, R"(banana)"sv }, - { R"(variety)"sv, + { R"(hosts)"sv, toml::array{ - toml::table{ - { R"(name)"sv, R"(plantain)"sv }, - }, + R"(alpha)"sv, + R"(omega)"sv, } }, - }, - } }, - }; - REQUIRE(tbl == expected); - }); - - parsing_should_succeed(FILE_LINE_ARGS, - spec_array_of_tables_3, - [](toml::table&& tbl) // spec-array-of-tables-3 - { - const auto expected = toml::table{ - { R"(points)"sv, - toml::array{ - toml::table{ - { R"(x)"sv, 1 }, - { R"(y)"sv, 2 }, - { R"(z)"sv, 3 }, - }, - toml::table{ - { R"(x)"sv, 7 }, - { R"(y)"sv, 8 }, - { R"(z)"sv, 9 }, - }, - toml::table{ - { R"(x)"sv, 2 }, - { R"(y)"sv, 4 }, - { R"(z)"sv, 8 }, - }, - } }, - }; - REQUIRE(tbl == expected); - }); - - parsing_should_succeed(FILE_LINE_ARGS, - spec_boolean_1, - [](toml::table&& tbl) // spec-boolean-1 - { - const auto expected = toml::table{ - { R"(bool1)"sv, true }, - }; - REQUIRE(tbl == expected); - }); - - parsing_should_succeed(FILE_LINE_ARGS, - spec_boolean_2, - [](toml::table&& tbl) // spec-boolean-2 - { - const auto expected = toml::table{ - { R"(bool1)"sv, false }, - }; - REQUIRE(tbl == expected); - }); - - parsing_should_succeed(FILE_LINE_ARGS, - spec_case_sensitive, - [](toml::table&& tbl) // spec-case-sensitive - { - const auto expected = toml::table{ - { R"(abc)"sv, 123 }, - { R"(ABC)"sv, 456 }, - }; - REQUIRE(tbl == expected); - }); - - parsing_should_succeed(FILE_LINE_ARGS, - spec_comment_mid_array, - [](toml::table&& tbl) // spec-comment-mid-array - { - const auto expected = toml::table{ - { R"(abc)"sv, - toml::array{ - 123, - 456, - } }, - }; - REQUIRE(tbl == expected); - }); - - parsing_should_succeed(FILE_LINE_ARGS, - spec_comment_mid_string, - [](toml::table&& tbl) // spec-comment-mid-string - { - const auto expected = toml::table{ - { R"(another)"sv, R"(# This is not a comment)"sv }, - }; - REQUIRE(tbl == expected); - }); - - parsing_should_succeed(FILE_LINE_ARGS, - spec_comment_tab, - [](toml::table&& tbl) // spec-comment-tab - { - const auto expected = toml::table{ - { R"(key)"sv, R"(value)"sv }, - }; - REQUIRE(tbl == expected); - }); - - parsing_should_succeed(FILE_LINE_ARGS, - spec_comment, - [](toml::table&& tbl) // spec-comment - { - const auto expected = toml::table{ - { R"(key)"sv, R"(value)"sv }, - }; - REQUIRE(tbl == expected); - }); - - parsing_should_succeed(FILE_LINE_ARGS, - spec_date_local_1, - [](toml::table&& tbl) // spec-date-local-1 - { - const auto expected = toml::table{ - { R"(ld1)"sv, toml::date{ 1979, 5, 27 } }, - }; - REQUIRE(tbl == expected); - }); - - parsing_should_succeed(FILE_LINE_ARGS, - spec_date_time_1, - [](toml::table&& tbl) // spec-date-time-1 - { - const auto expected = toml::table{ - { R"(odt1)"sv, toml::date_time{ { 1979, 5, 27 }, { 7, 32 }, { 0, 0 } } }, - }; - REQUIRE(tbl == expected); - }); - - parsing_should_succeed(FILE_LINE_ARGS, - spec_date_time_2, - [](toml::table&& tbl) // spec-date-time-2 - { - const auto expected = toml::table{ - { R"(odt2)"sv, toml::date_time{ { 1979, 5, 27 }, { 0, 32 }, { -7, 0 } } }, - }; - REQUIRE(tbl == expected); - }); - - parsing_should_succeed( - FILE_LINE_ARGS, - spec_date_time_3, - [](toml::table&& tbl) // spec-date-time-3 - { - const auto expected = toml::table{ - { R"(odt3)"sv, toml::date_time{ { 1979, 5, 27 }, { 0, 32, 0, 999999000 }, { -7, 0 } } }, - }; - REQUIRE(tbl == expected); - }); - - parsing_should_succeed(FILE_LINE_ARGS, - spec_date_time_4, - [](toml::table&& tbl) // spec-date-time-4 - { - const auto expected = toml::table{ - { R"(odt4)"sv, toml::date_time{ { 1979, 5, 27 }, { 7, 32 }, { 0, 0 } } }, - }; - REQUIRE(tbl == expected); - }); - - parsing_should_succeed( - FILE_LINE_ARGS, - spec_date_time_5, - [](toml::table&& tbl) // spec-date-time-5 - { - const auto expected = toml::table{ - { R"(odt5)"sv, toml::date_time{ { 1979, 5, 27 }, { 7, 32, 0, 123000000 }, { 0, 0 } } }, - }; - REQUIRE(tbl == expected); - }); - - parsing_should_succeed(FILE_LINE_ARGS, - spec_date_time_local_1, - [](toml::table&& tbl) // spec-date-time-local-1 - { - const auto expected = toml::table{ - { R"(ldt1)"sv, toml::date_time{ { 1979, 5, 27 }, { 7, 32 } } }, - }; - REQUIRE(tbl == expected); - }); - - parsing_should_succeed(FILE_LINE_ARGS, - spec_dotted_keys_1, - [](toml::table&& tbl) // spec-dotted-keys-1 - { - const auto expected = toml::table{ - { R"(name)"sv, R"(Orange)"sv }, - { R"(physical)"sv, - toml::table{ - { R"(color)"sv, R"(orange)"sv }, - { R"(shape)"sv, R"(round)"sv }, - } }, - { R"(site)"sv, - toml::table{ - { R"(google.com)"sv, true }, - } }, - }; - REQUIRE(tbl == expected); - }); - - parsing_should_succeed(FILE_LINE_ARGS, - spec_dotted_keys_2, - [](toml::table&& tbl) // spec-dotted-keys-2 - { - const auto expected = toml::table{ - { R"(a)"sv, - toml::table{ - { R"(b)"sv, 23 }, - } }, - }; - REQUIRE(tbl == expected); - }); - - parsing_should_succeed(FILE_LINE_ARGS, - spec_dotted_keys_3, - [](toml::table&& tbl) // spec-dotted-keys-3 - { - const auto expected = toml::table{ - { R"(a)"sv, - toml::table{ - { R"(b)"sv, 23 }, - } }, - }; - REQUIRE(tbl == expected); - }); - - parsing_should_succeed(FILE_LINE_ARGS, - spec_empty_key_name_1, - [](toml::table&& tbl) // spec-empty-key-name-1 - { - const auto expected = toml::table{ - { ""sv, R"(blank)"sv }, - }; - REQUIRE(tbl == expected); - }); - - parsing_should_succeed(FILE_LINE_ARGS, - spec_empty_key_name_2, - [](toml::table&& tbl) // spec-empty-key-name-2 - { - const auto expected = toml::table{ - { ""sv, R"(blank)"sv }, - }; - REQUIRE(tbl == expected); - }); - - parsing_should_succeed(FILE_LINE_ARGS, - spec_extend_dotted_object_1, - [](toml::table&& tbl) // spec-extend-dotted-object-1 - { - const auto expected = toml::table{ - { R"(fruit)"sv, - toml::table{ - { R"(apple)"sv, - toml::table{ - { R"(smooth)"sv, true }, - } }, - { R"(orange)"sv, 2 }, - } }, - }; - REQUIRE(tbl == expected); - }); - - parsing_should_succeed(FILE_LINE_ARGS, - spec_extend_dotted_object_2, - [](toml::table&& tbl) // spec-extend-dotted-object-2 - { - const auto expected = toml::table{ - { R"(apple)"sv, - toml::table{ - { R"(type)"sv, R"(fruit)"sv }, - { R"(skin)"sv, R"(thin)"sv }, - { R"(color)"sv, R"(red)"sv }, - } }, - { R"(orange)"sv, - toml::table{ - { R"(type)"sv, R"(fruit)"sv }, - { R"(skin)"sv, R"(thick)"sv }, - { R"(color)"sv, R"(orange)"sv }, - } }, - }; - REQUIRE(tbl == expected); - }); - - parsing_should_succeed(FILE_LINE_ARGS, - spec_extend_dotted_object_3, - [](toml::table&& tbl) // spec-extend-dotted-object-3 - { - const auto expected = toml::table{ - { R"(apple)"sv, - toml::table{ - { R"(type)"sv, R"(fruit)"sv }, - { R"(skin)"sv, R"(thin)"sv }, - { R"(color)"sv, R"(red)"sv }, - } }, - { R"(orange)"sv, - toml::table{ - { R"(type)"sv, R"(fruit)"sv }, - { R"(skin)"sv, R"(thick)"sv }, - { R"(color)"sv, R"(orange)"sv }, - } }, - }; - REQUIRE(tbl == expected); - }); - - parsing_should_succeed(FILE_LINE_ARGS, - spec_float_1, - [](toml::table&& tbl) // spec-float-1 - { - const auto expected = toml::table{ - { R"(flt1)"sv, 1.0 }, - }; - REQUIRE(tbl == expected); - }); - - parsing_should_succeed(FILE_LINE_ARGS, - spec_float_10, - [](toml::table&& tbl) // spec-float-10 - { - const auto expected = toml::table{ - { R"(sf1)"sv, std::numeric_limits::infinity() }, - }; - REQUIRE(tbl == expected); - }); - - parsing_should_succeed(FILE_LINE_ARGS, - spec_float_11, - [](toml::table&& tbl) // spec-float-11 - { - const auto expected = toml::table{ - { R"(sf2)"sv, std::numeric_limits::infinity() }, - }; - REQUIRE(tbl == expected); - }); - - parsing_should_succeed(FILE_LINE_ARGS, - spec_float_12, - [](toml::table&& tbl) // spec-float-12 - { - const auto expected = toml::table{ - { R"(sf2)"sv, -std::numeric_limits::infinity() }, - }; - REQUIRE(tbl == expected); - }); - - parsing_should_succeed(FILE_LINE_ARGS, - spec_float_13, - [](toml::table&& tbl) // spec-float-13 - { - const auto expected = toml::table{ - { R"(sf4)"sv, std::numeric_limits::quiet_NaN() }, - }; - REQUIRE(tbl == expected); - }); - - parsing_should_succeed(FILE_LINE_ARGS, - spec_float_14, - [](toml::table&& tbl) // spec-float-14 - { - const auto expected = toml::table{ - { R"(sf5)"sv, std::numeric_limits::quiet_NaN() }, - }; - REQUIRE(tbl == expected); - }); - - parsing_should_succeed(FILE_LINE_ARGS, - spec_float_15, - [](toml::table&& tbl) // spec-float-15 - { - const auto expected = toml::table{ - { R"(sf6)"sv, std::numeric_limits::quiet_NaN() }, - }; - REQUIRE(tbl == expected); - }); - - parsing_should_succeed(FILE_LINE_ARGS, - spec_float_2, - [](toml::table&& tbl) // spec-float-2 - { - const auto expected = toml::table{ - { R"(flt2)"sv, 3.1415 }, - }; - REQUIRE(tbl == expected); - }); - - parsing_should_succeed(FILE_LINE_ARGS, - spec_float_3, - [](toml::table&& tbl) // spec-float-3 - { - const auto expected = toml::table{ - { R"(flt3)"sv, -0.01 }, - }; - REQUIRE(tbl == expected); - }); - - parsing_should_succeed(FILE_LINE_ARGS, - spec_float_4, - [](toml::table&& tbl) // spec-float-4 - { - const auto expected = toml::table{ - { R"(flt4)"sv, 5e+22 }, - }; - REQUIRE(tbl == expected); - }); - - parsing_should_succeed(FILE_LINE_ARGS, - spec_float_5, - [](toml::table&& tbl) // spec-float-5 - { - const auto expected = toml::table{ - { R"(flt5)"sv, 1000000.0 }, - }; - REQUIRE(tbl == expected); - }); - - parsing_should_succeed(FILE_LINE_ARGS, - spec_float_6, - [](toml::table&& tbl) // spec-float-6 - { - const auto expected = toml::table{ - { R"(flt6)"sv, -0.02 }, - }; - REQUIRE(tbl == expected); - }); - - parsing_should_succeed(FILE_LINE_ARGS, - spec_float_7, - [](toml::table&& tbl) // spec-float-7 - { - const auto expected = toml::table{ - { R"(flt7)"sv, 6.626e-34 }, - }; - REQUIRE(tbl == expected); - }); - - parsing_should_succeed(FILE_LINE_ARGS, - spec_float_8, - [](toml::table&& tbl) // spec-float-8 - { - const auto expected = toml::table{ - { R"(flt8)"sv, 224617.445991228 }, - }; - REQUIRE(tbl == expected); - }); - - parsing_should_succeed(FILE_LINE_ARGS, - spec_float_9, - [](toml::table&& tbl) // spec-float-9 - { - const auto expected = toml::table{ - { R"(flt9)"sv, -0.0 }, - }; - REQUIRE(tbl == expected); - }); - - parsing_should_succeed(FILE_LINE_ARGS, - spec_int_1, - [](toml::table&& tbl) // spec-int-1 - { - const auto expected = toml::table{ - { R"(int1)"sv, 99 }, - }; - REQUIRE(tbl == expected); - }); - - parsing_should_succeed(FILE_LINE_ARGS, - spec_int_2, - [](toml::table&& tbl) // spec-int-2 - { - const auto expected = toml::table{ - { R"(int2)"sv, 42 }, - }; - REQUIRE(tbl == expected); - }); - - parsing_should_succeed(FILE_LINE_ARGS, - spec_int_3, - [](toml::table&& tbl) // spec-int-3 - { - const auto expected = toml::table{ - { R"(int3)"sv, 0 }, - }; - REQUIRE(tbl == expected); - }); - - parsing_should_succeed(FILE_LINE_ARGS, - spec_int_3a, - [](toml::table&& tbl) // spec-int-3a - { - const auto expected = toml::table{ - { R"(int3)"sv, 0 }, - }; - REQUIRE(tbl == expected); - }); - - parsing_should_succeed(FILE_LINE_ARGS, - spec_int_3b, - [](toml::table&& tbl) // spec-int-3b - { - const auto expected = toml::table{ - { R"(int3)"sv, 0 }, - }; - REQUIRE(tbl == expected); - }); - - parsing_should_succeed(FILE_LINE_ARGS, - spec_int_4, - [](toml::table&& tbl) // spec-int-4 - { - const auto expected = toml::table{ - { R"(int4)"sv, -17 }, - }; - REQUIRE(tbl == expected); - }); - - parsing_should_succeed(FILE_LINE_ARGS, - spec_int_5, - [](toml::table&& tbl) // spec-int-5 - { - const auto expected = toml::table{ - { R"(int5)"sv, 1000 }, - }; - REQUIRE(tbl == expected); - }); - - parsing_should_succeed(FILE_LINE_ARGS, - spec_int_6, - [](toml::table&& tbl) // spec-int-6 - { - const auto expected = toml::table{ - { R"(int6)"sv, 5349221 }, - }; - REQUIRE(tbl == expected); - }); - - parsing_should_succeed(FILE_LINE_ARGS, - spec_int_7, - [](toml::table&& tbl) // spec-int-7 - { - const auto expected = toml::table{ - { R"(int7)"sv, 12345 }, - }; - REQUIRE(tbl == expected); - }); - - parsing_should_succeed(FILE_LINE_ARGS, - spec_int_bin1, - [](toml::table&& tbl) // spec-int-bin1 - { - const auto expected = toml::table{ - { R"(bin1)"sv, 214 }, - }; - REQUIRE(tbl == expected); - }); - - parsing_should_succeed(FILE_LINE_ARGS, - spec_int_hex1, - [](toml::table&& tbl) // spec-int-hex1 - { - const auto expected = toml::table{ - { R"(hex1)"sv, 3735928559 }, - }; - REQUIRE(tbl == expected); - }); - - parsing_should_succeed(FILE_LINE_ARGS, - spec_int_hex2, - [](toml::table&& tbl) // spec-int-hex2 - { - const auto expected = toml::table{ - { R"(hex2)"sv, 3735928559 }, - }; - REQUIRE(tbl == expected); - }); - - parsing_should_succeed(FILE_LINE_ARGS, - spec_int_hex3, - [](toml::table&& tbl) // spec-int-hex3 - { - const auto expected = toml::table{ - { R"(hex3)"sv, 3735928559 }, - }; - REQUIRE(tbl == expected); - }); - - parsing_should_succeed(FILE_LINE_ARGS, - spec_int_max, - [](toml::table&& tbl) // spec-int-max - { - const auto expected = toml::table{ - { R"(max)"sv, std::numeric_limits::max() }, - }; - REQUIRE(tbl == expected); - }); - - parsing_should_succeed(FILE_LINE_ARGS, - spec_int_min, - [](toml::table&& tbl) // spec-int-min - { - const auto expected = toml::table{ - { R"(min)"sv, std::numeric_limits::min() }, - }; - REQUIRE(tbl == expected); - }); - - parsing_should_succeed(FILE_LINE_ARGS, - spec_int_oct1, - [](toml::table&& tbl) // spec-int-oct1 - { - const auto expected = toml::table{ - { R"(oct1)"sv, 342391 }, - }; - REQUIRE(tbl == expected); - }); - - parsing_should_succeed(FILE_LINE_ARGS, - spec_int_oct2, - [](toml::table&& tbl) // spec-int-oct2 - { - const auto expected = toml::table{ - { R"(oct2)"sv, 493 }, - }; - REQUIRE(tbl == expected); - }); - - parsing_should_succeed(FILE_LINE_ARGS, - spec_key_value_pair_1, - [](toml::table&& tbl) // spec-key-value-pair-1 - { - const auto expected = toml::table{ - { R"(key)"sv, R"(value)"sv }, - }; - REQUIRE(tbl == expected); - }); - - parsing_should_succeed(FILE_LINE_ARGS, - spec_key_value_pair_2, - [](toml::table&& tbl) // spec-key-value-pair-2 - { - const auto expected = toml::table{ - { R"(bare_key)"sv, R"(value)"sv }, - }; - REQUIRE(tbl == expected); - }); - - parsing_should_succeed(FILE_LINE_ARGS, - spec_key_value_pair_3, - [](toml::table&& tbl) // spec-key-value-pair-3 - { - const auto expected = toml::table{ - { R"(bare-key)"sv, R"(value)"sv }, - }; - REQUIRE(tbl == expected); - }); - - parsing_should_succeed(FILE_LINE_ARGS, - spec_key_value_pair_4, - [](toml::table&& tbl) // spec-key-value-pair-4 - { - const auto expected = toml::table{ - { R"(1234)"sv, R"(value)"sv }, - }; - REQUIRE(tbl == expected); - }); - - parsing_should_succeed(FILE_LINE_ARGS, - spec_key_value_pair_5, - [](toml::table&& tbl) // spec-key-value-pair-5 - { - const auto expected = toml::table{ - { R"(1234)"sv, R"(value)"sv }, - }; - REQUIRE(tbl == expected); - }); - - parsing_should_succeed(FILE_LINE_ARGS, - spec_key_value_pair_6, - [](toml::table&& tbl) // spec-key-value-pair-6 - { - const auto expected = toml::table{ - { R"(-)"sv, 1 }, - }; - REQUIRE(tbl == expected); - }); - - parsing_should_succeed(FILE_LINE_ARGS, - spec_key_value_pair_7, - [](toml::table&& tbl) // spec-key-value-pair-7 - { - const auto expected = toml::table{ - { R"(_)"sv, 1 }, - }; - REQUIRE(tbl == expected); - }); - - parsing_should_succeed(FILE_LINE_ARGS, - spec_key_value_pair_8, - [](toml::table&& tbl) // spec-key-value-pair-8 - { - const auto expected = toml::table{ - { R"(-_-_-_-_-)"sv, 1 }, - }; - REQUIRE(tbl == expected); - }); - - parsing_should_succeed(FILE_LINE_ARGS, - spec_key_value_pair_9, - [](toml::table&& tbl) // spec-key-value-pair-9 - { - const auto expected = toml::table{ - { R"(3)"sv, - toml::table{ - { R"(14159)"sv, R"(pi)"sv }, - } }, - }; - REQUIRE(tbl == expected); - }); - - parsing_should_succeed(FILE_LINE_ARGS, - spec_newline_1, - [](toml::table&& tbl) // spec-newline-1 - { - const auto expected = toml::table{ - { R"(abc)"sv, 123 }, - { R"(def)"sv, 456 }, - }; - REQUIRE(tbl == expected); - }); - - parsing_should_succeed(FILE_LINE_ARGS, - spec_newline_2, - [](toml::table&& tbl) // spec-newline-2 - { - const auto expected = toml::table{ - { R"(abc)"sv, 123 }, - { R"(def)"sv, 456 }, - }; - REQUIRE(tbl == expected); - }); - - parsing_should_succeed(FILE_LINE_ARGS, - spec_newline_3, - [](toml::table&& tbl) // spec-newline-3 - { - const auto expected = toml::table{ - { R"(abc)"sv, 123 }, - { R"(def)"sv, 456 }, - { R"(ghi)"sv, 789 }, - }; - REQUIRE(tbl == expected); - }); - - parsing_should_succeed(FILE_LINE_ARGS, - spec_quoted_literal_keys_1, - [](toml::table&& tbl) // spec-quoted-literal-keys-1 - { - const auto expected = toml::table{ - { R"(quoted "value")"sv, R"(value)"sv }, - }; - REQUIRE(tbl == expected); - }); - - parsing_should_succeed(FILE_LINE_ARGS, - spec_readme_example, - [](toml::table&& tbl) // spec-readme-example - { - const auto expected = toml::table{ - { R"(title)"sv, R"(TOML Example)"sv }, - { R"(owner)"sv, - toml::table{ - { R"(name)"sv, R"(Tom Preston-Werner)"sv }, - { R"(dob)"sv, toml::date_time{ { 1979, 5, 27 }, { 7, 32 }, { -8, 0 } } }, - } }, - { R"(database)"sv, - toml::table{ - { R"(server)"sv, R"(192.168.1.1)"sv }, - { R"(ports)"sv, - toml::array{ - 8001, - 8001, - 8002, - } }, - { R"(connection_max)"sv, 5000 }, - { R"(enabled)"sv, true }, - } }, - { R"(servers)"sv, - toml::table{ - { R"(alpha)"sv, - toml::table{ - { R"(ip)"sv, R"(10.0.0.1)"sv }, - { R"(dc)"sv, R"(eqdc10)"sv }, - } }, - { R"(beta)"sv, - toml::table{ - { R"(ip)"sv, R"(10.0.0.2)"sv }, - { R"(dc)"sv, R"(eqdc10)"sv }, - } }, - } }, - { R"(clients)"sv, - toml::table{ - { R"(data)"sv, - toml::array{ - toml::array{ - R"(gamma)"sv, - R"(delta)"sv, - }, - toml::array{ - 1, - 2, - }, - } }, - { R"(hosts)"sv, - toml::array{ - R"(alpha)"sv, - R"(omega)"sv, - } }, - } }, - }; - REQUIRE(tbl == expected); - }); - - parsing_should_succeed(FILE_LINE_ARGS, - spec_string_basic_multiline_1, - [](toml::table&& tbl) // spec-string-basic-multiline-1 - { - const auto expected = toml::table{ - { R"(str1)"sv, R"(Roses are red + } }, + }; + REQUIRE(tbl == expected); + }); + } + + SECTION("spec-string-basic-multiline-1") + { + parsing_should_succeed(FILE_LINE_ARGS, + spec_string_basic_multiline_1, + [](toml::table&& tbl) // spec-string-basic-multiline-1 + { + const auto expected = toml::table{ + { R"(str1)"sv, R"(Roses are red Violets are blue)"sv }, - }; - REQUIRE(tbl == expected); - }); + }; + REQUIRE(tbl == expected); + }); + } - parsing_should_succeed(FILE_LINE_ARGS, - spec_string_basic_multiline_2, - [](toml::table&& tbl) // spec-string-basic-multiline-2 - { - const auto expected = toml::table{ - { R"(str)"sv, R"(The quick brown fox jumps over the lazy dog.)"sv }, - }; - REQUIRE(tbl == expected); - }); + SECTION("spec-string-basic-multiline-2") + { + parsing_should_succeed(FILE_LINE_ARGS, + spec_string_basic_multiline_2, + [](toml::table&& tbl) // spec-string-basic-multiline-2 + { + const auto expected = toml::table{ + { R"(str)"sv, R"(The quick brown fox jumps over the lazy dog.)"sv }, + }; + REQUIRE(tbl == expected); + }); + } - parsing_should_succeed(FILE_LINE_ARGS, - spec_string_basic_multiline_3, - [](toml::table&& tbl) // spec-string-basic-multiline-3 - { - const auto expected = toml::table{ - { R"(str)"sv, R"(The quick brown fox jumps over the lazy dog.)"sv }, - }; - REQUIRE(tbl == expected); - }); + SECTION("spec-string-basic-multiline-3") + { + parsing_should_succeed(FILE_LINE_ARGS, + spec_string_basic_multiline_3, + [](toml::table&& tbl) // spec-string-basic-multiline-3 + { + const auto expected = toml::table{ + { R"(str)"sv, R"(The quick brown fox jumps over the lazy dog.)"sv }, + }; + REQUIRE(tbl == expected); + }); + } - parsing_should_succeed(FILE_LINE_ARGS, - spec_string_basic_multiline_4, - [](toml::table&& tbl) // spec-string-basic-multiline-4 - { - const auto expected = toml::table{ - { R"(a)"sv, R"(abcdef)"sv }, - }; - REQUIRE(tbl == expected); - }); + SECTION("spec-string-basic-multiline-4") + { + parsing_should_succeed(FILE_LINE_ARGS, + spec_string_basic_multiline_4, + [](toml::table&& tbl) // spec-string-basic-multiline-4 + { + const auto expected = toml::table{ + { R"(a)"sv, R"(abcdef)"sv }, + }; + REQUIRE(tbl == expected); + }); + } - parsing_should_succeed(FILE_LINE_ARGS, - spec_string_basic_multiline_5, - [](toml::table&& tbl) // spec-string-basic-multiline-5 - { - const auto expected = toml::table{ - { R"(ml-escaped-nl)"sv, R"( foo bar \ + SECTION("spec-string-basic-multiline-5") + { + parsing_should_succeed(FILE_LINE_ARGS, + spec_string_basic_multiline_5, + [](toml::table&& tbl) // spec-string-basic-multiline-5 + { + const auto expected = toml::table{ + { R"(ml-escaped-nl)"sv, R"( foo bar \ baz \quux)"sv }, - }; - REQUIRE(tbl == expected); - }); + }; + REQUIRE(tbl == expected); + }); + } - parsing_should_succeed(FILE_LINE_ARGS, - spec_string_basic_multiline_6, - [](toml::table&& tbl) // spec-string-basic-multiline-6 - { - const auto expected = toml::table{ - { R"(str4)"sv, R"(Here are two quotation marks: "". Simple enough.)"sv }, - }; - REQUIRE(tbl == expected); - }); + SECTION("spec-string-basic-multiline-6") + { + parsing_should_succeed(FILE_LINE_ARGS, + spec_string_basic_multiline_6, + [](toml::table&& tbl) // spec-string-basic-multiline-6 + { + const auto expected = toml::table{ + { R"(str4)"sv, R"(Here are two quotation marks: "". Simple enough.)"sv }, + }; + REQUIRE(tbl == expected); + }); + } - parsing_should_succeed(FILE_LINE_ARGS, - spec_string_basic_multiline_7, - [](toml::table&& tbl) // spec-string-basic-multiline-7 - { - const auto expected = toml::table{ - { R"(str5)"sv, R"(Here are three quotation marks: """.)"sv }, - }; - REQUIRE(tbl == expected); - }); + SECTION("spec-string-basic-multiline-7") + { + parsing_should_succeed(FILE_LINE_ARGS, + spec_string_basic_multiline_7, + [](toml::table&& tbl) // spec-string-basic-multiline-7 + { + const auto expected = toml::table{ + { R"(str5)"sv, R"(Here are three quotation marks: """.)"sv }, + }; + REQUIRE(tbl == expected); + }); + } - parsing_should_succeed(FILE_LINE_ARGS, - spec_string_basic_multiline_8, - [](toml::table&& tbl) // spec-string-basic-multiline-8 - { - const auto expected = toml::table{ - { R"(str6)"sv, R"(Here are fifteen quotation marks: """"""""""""""".)"sv }, - }; - REQUIRE(tbl == expected); - }); + SECTION("spec-string-basic-multiline-8") + { + parsing_should_succeed(FILE_LINE_ARGS, + spec_string_basic_multiline_8, + [](toml::table&& tbl) // spec-string-basic-multiline-8 + { + const auto expected = toml::table{ + { R"(str6)"sv, R"(Here are fifteen quotation marks: """"""""""""""".)"sv }, + }; + REQUIRE(tbl == expected); + }); + } - parsing_should_succeed(FILE_LINE_ARGS, - spec_string_basic_multiline_9, - [](toml::table&& tbl) // spec-string-basic-multiline-9 - { - const auto expected = toml::table{ - { R"(str7)"sv, R"("This," she said, "is just a pointless statement.")"sv }, - }; - REQUIRE(tbl == expected); - }); + SECTION("spec-string-basic-multiline-9") + { + parsing_should_succeed(FILE_LINE_ARGS, + spec_string_basic_multiline_9, + [](toml::table&& tbl) // spec-string-basic-multiline-9 + { + const auto expected = toml::table{ + { R"(str7)"sv, R"("This," she said, "is just a pointless statement.")"sv }, + }; + REQUIRE(tbl == expected); + }); + } - parsing_should_succeed(FILE_LINE_ARGS, - spec_string_basic_tab_multiline, - [](toml::table&& tbl) // spec-string-basic-tab-multiline - { - const auto expected = toml::table{ - { R"(str)"sv, R"(This is a tab)"sv }, - }; - REQUIRE(tbl == expected); - }); + SECTION("spec-string-basic-tab-multiline") + { + parsing_should_succeed(FILE_LINE_ARGS, + spec_string_basic_tab_multiline, + [](toml::table&& tbl) // spec-string-basic-tab-multiline + { + const auto expected = toml::table{ + { R"(str)"sv, R"(This is a tab)"sv }, + }; + REQUIRE(tbl == expected); + }); + } - parsing_should_succeed(FILE_LINE_ARGS, - spec_string_basic_tab, - [](toml::table&& tbl) // spec-string-basic-tab - { - const auto expected = toml::table{ - { R"(str)"sv, R"(This is a tab)"sv }, - }; - REQUIRE(tbl == expected); - }); + SECTION("spec-string-basic-tab") + { + parsing_should_succeed(FILE_LINE_ARGS, + spec_string_basic_tab, + [](toml::table&& tbl) // spec-string-basic-tab + { + const auto expected = toml::table{ + { R"(str)"sv, R"(This is a tab)"sv }, + }; + REQUIRE(tbl == expected); + }); + } - parsing_should_succeed(FILE_LINE_ARGS, - spec_string_escape_1, - [](toml::table&& tbl) // spec-string-escape-1 - { - const auto expected = toml::table{ - { R"(a)"sv, "\x08"sv }, - }; - REQUIRE(tbl == expected); - }); + SECTION("spec-string-escape-1") + { + parsing_should_succeed(FILE_LINE_ARGS, + spec_string_escape_1, + [](toml::table&& tbl) // spec-string-escape-1 + { + const auto expected = toml::table{ + { R"(a)"sv, "\x08"sv }, + }; + REQUIRE(tbl == expected); + }); + } - parsing_should_succeed(FILE_LINE_ARGS, - spec_string_escape_2, - [](toml::table&& tbl) // spec-string-escape-2 - { - const auto expected = toml::table{ - { R"(a)"sv, R"( )"sv }, - }; - REQUIRE(tbl == expected); - }); + SECTION("spec-string-escape-2") + { + parsing_should_succeed(FILE_LINE_ARGS, + spec_string_escape_2, + [](toml::table&& tbl) // spec-string-escape-2 + { + const auto expected = toml::table{ + { R"(a)"sv, R"( )"sv }, + }; + REQUIRE(tbl == expected); + }); + } - parsing_should_succeed(FILE_LINE_ARGS, - spec_string_escape_3, - [](toml::table&& tbl) // spec-string-escape-3 - { - const auto expected = toml::table{ - { R"(a)"sv, R"( + SECTION("spec-string-escape-3") + { + parsing_should_succeed(FILE_LINE_ARGS, + spec_string_escape_3, + [](toml::table&& tbl) // spec-string-escape-3 + { + const auto expected = toml::table{ + { R"(a)"sv, R"( )"sv }, - }; - REQUIRE(tbl == expected); - }); + }; + REQUIRE(tbl == expected); + }); + } - parsing_should_succeed(FILE_LINE_ARGS, - spec_string_escape_4, - [](toml::table&& tbl) // spec-string-escape-4 - { - const auto expected = toml::table{ - { R"(a)"sv, "\f"sv }, - }; - REQUIRE(tbl == expected); - }); + SECTION("spec-string-escape-4") + { + parsing_should_succeed(FILE_LINE_ARGS, + spec_string_escape_4, + [](toml::table&& tbl) // spec-string-escape-4 + { + const auto expected = toml::table{ + { R"(a)"sv, "\f"sv }, + }; + REQUIRE(tbl == expected); + }); + } - parsing_should_succeed(FILE_LINE_ARGS, - spec_string_escape_5, - [](toml::table&& tbl) // spec-string-escape-5 - { - const auto expected = toml::table{ - { R"(a)"sv, "\r"sv }, - }; - REQUIRE(tbl == expected); - }); + SECTION("spec-string-escape-5") + { + parsing_should_succeed(FILE_LINE_ARGS, + spec_string_escape_5, + [](toml::table&& tbl) // spec-string-escape-5 + { + const auto expected = toml::table{ + { R"(a)"sv, "\r"sv }, + }; + REQUIRE(tbl == expected); + }); + } - parsing_should_succeed(FILE_LINE_ARGS, - spec_string_escape_6, - [](toml::table&& tbl) // spec-string-escape-6 - { - const auto expected = toml::table{ - { R"(a)"sv, R"(")"sv }, - }; - REQUIRE(tbl == expected); - }); + SECTION("spec-string-escape-6") + { + parsing_should_succeed(FILE_LINE_ARGS, + spec_string_escape_6, + [](toml::table&& tbl) // spec-string-escape-6 + { + const auto expected = toml::table{ + { R"(a)"sv, R"(")"sv }, + }; + REQUIRE(tbl == expected); + }); + } - parsing_should_succeed(FILE_LINE_ARGS, - spec_string_escape_7, - [](toml::table&& tbl) // spec-string-escape-7 - { - const auto expected = toml::table{ - { R"(a)"sv, R"(\)"sv }, - }; - REQUIRE(tbl == expected); - }); + SECTION("spec-string-escape-7") + { + parsing_should_succeed(FILE_LINE_ARGS, + spec_string_escape_7, + [](toml::table&& tbl) // spec-string-escape-7 + { + const auto expected = toml::table{ + { R"(a)"sv, R"(\)"sv }, + }; + REQUIRE(tbl == expected); + }); + } - parsing_should_succeed(FILE_LINE_ARGS, - spec_string_escape_8, - [](toml::table&& tbl) // spec-string-escape-8 - { - const auto expected = toml::table{ - { R"(a)"sv, "\x00"sv }, - }; - REQUIRE(tbl == expected); - }); + SECTION("spec-string-escape-8") + { + parsing_should_succeed(FILE_LINE_ARGS, + spec_string_escape_8, + [](toml::table&& tbl) // spec-string-escape-8 + { + const auto expected = toml::table{ + { R"(a)"sv, "\x00"sv }, + }; + REQUIRE(tbl == expected); + }); + } - parsing_should_succeed(FILE_LINE_ARGS, - spec_string_escape_9, - [](toml::table&& tbl) // spec-string-escape-9 - { - const auto expected = toml::table{ - { R"(a)"sv, "\x00"sv }, - }; - REQUIRE(tbl == expected); - }); + SECTION("spec-string-escape-9") + { + parsing_should_succeed(FILE_LINE_ARGS, + spec_string_escape_9, + [](toml::table&& tbl) // spec-string-escape-9 + { + const auto expected = toml::table{ + { R"(a)"sv, "\x00"sv }, + }; + REQUIRE(tbl == expected); + }); + } - parsing_should_succeed(FILE_LINE_ARGS, - spec_string_literal_1, - [](toml::table&& tbl) // spec-string-literal-1 - { - const auto expected = toml::table{ - { R"(winpath)"sv, R"(C:\Users\nodejs\templates)"sv }, - }; - REQUIRE(tbl == expected); - }); + SECTION("spec-string-literal-1") + { + parsing_should_succeed(FILE_LINE_ARGS, + spec_string_literal_1, + [](toml::table&& tbl) // spec-string-literal-1 + { + const auto expected = toml::table{ + { R"(winpath)"sv, R"(C:\Users\nodejs\templates)"sv }, + }; + REQUIRE(tbl == expected); + }); + } - parsing_should_succeed(FILE_LINE_ARGS, - spec_string_literal_2, - [](toml::table&& tbl) // spec-string-literal-2 - { - const auto expected = toml::table{ - { R"(winpath2)"sv, R"(\\ServerX\admin$\system32\)"sv }, - }; - REQUIRE(tbl == expected); - }); + SECTION("spec-string-literal-2") + { + parsing_should_succeed(FILE_LINE_ARGS, + spec_string_literal_2, + [](toml::table&& tbl) // spec-string-literal-2 + { + const auto expected = toml::table{ + { R"(winpath2)"sv, R"(\\ServerX\admin$\system32\)"sv }, + }; + REQUIRE(tbl == expected); + }); + } - parsing_should_succeed(FILE_LINE_ARGS, - spec_string_literal_3, - [](toml::table&& tbl) // spec-string-literal-3 - { - const auto expected = toml::table{ - { R"(quoted)"sv, R"(Tom "Dubs" Preston-Werner)"sv }, - }; - REQUIRE(tbl == expected); - }); + SECTION("spec-string-literal-3") + { + parsing_should_succeed(FILE_LINE_ARGS, + spec_string_literal_3, + [](toml::table&& tbl) // spec-string-literal-3 + { + const auto expected = toml::table{ + { R"(quoted)"sv, R"(Tom "Dubs" Preston-Werner)"sv }, + }; + REQUIRE(tbl == expected); + }); + } - parsing_should_succeed(FILE_LINE_ARGS, - spec_string_literal_4, - [](toml::table&& tbl) // spec-string-literal-4 - { - const auto expected = toml::table{ - { R"(regex)"sv, R"(<\i\c*\s*>)"sv }, - }; - REQUIRE(tbl == expected); - }); + SECTION("spec-string-literal-4") + { + parsing_should_succeed(FILE_LINE_ARGS, + spec_string_literal_4, + [](toml::table&& tbl) // spec-string-literal-4 + { + const auto expected = toml::table{ + { R"(regex)"sv, R"(<\i\c*\s*>)"sv }, + }; + REQUIRE(tbl == expected); + }); + } - parsing_should_succeed(FILE_LINE_ARGS, - spec_string_literal_multiline_1, - [](toml::table&& tbl) // spec-string-literal-multiline-1 - { - const auto expected = toml::table{ - { R"(regex2)"sv, R"(I [dw]on't need \d{2} apples)"sv }, - }; - REQUIRE(tbl == expected); - }); + SECTION("spec-string-literal-multiline-1") + { + parsing_should_succeed(FILE_LINE_ARGS, + spec_string_literal_multiline_1, + [](toml::table&& tbl) // spec-string-literal-multiline-1 + { + const auto expected = toml::table{ + { R"(regex2)"sv, R"(I [dw]on't need \d{2} apples)"sv }, + }; + REQUIRE(tbl == expected); + }); + } - parsing_should_succeed(FILE_LINE_ARGS, - spec_string_literal_multiline_2, - [](toml::table&& tbl) // spec-string-literal-multiline-2 - { - const auto expected = toml::table{ - { R"(lines)"sv, R"(The first newline is + SECTION("spec-string-literal-multiline-2") + { + parsing_should_succeed(FILE_LINE_ARGS, + spec_string_literal_multiline_2, + [](toml::table&& tbl) // spec-string-literal-multiline-2 + { + const auto expected = toml::table{ + { R"(lines)"sv, R"(The first newline is trimmed in raw strings. All other whitespace is preserved. )"sv }, - }; - REQUIRE(tbl == expected); - }); + }; + REQUIRE(tbl == expected); + }); + } - parsing_should_succeed(FILE_LINE_ARGS, - spec_string_literal_multiline_3, - [](toml::table&& tbl) // spec-string-literal-multiline-3 - { - const auto expected = toml::table{ - { R"(quot15)"sv, R"(Here are fifteen quotation marks: """"""""""""""")"sv }, - }; - REQUIRE(tbl == expected); - }); + SECTION("spec-string-literal-multiline-3") + { + parsing_should_succeed(FILE_LINE_ARGS, + spec_string_literal_multiline_3, + [](toml::table&& tbl) // spec-string-literal-multiline-3 + { + const auto expected = toml::table{ + { R"(quot15)"sv, R"(Here are fifteen quotation marks: """"""""""""""")"sv }, + }; + REQUIRE(tbl == expected); + }); + } - parsing_should_succeed(FILE_LINE_ARGS, - spec_string_literal_multiline_4, - [](toml::table&& tbl) // spec-string-literal-multiline-4 - { - const auto expected = toml::table{ - { R"(str)"sv, R"('That,' she said, 'is still pointless.')"sv }, - }; - REQUIRE(tbl == expected); - }); + SECTION("spec-string-literal-multiline-4") + { + parsing_should_succeed(FILE_LINE_ARGS, + spec_string_literal_multiline_4, + [](toml::table&& tbl) // spec-string-literal-multiline-4 + { + const auto expected = toml::table{ + { R"(str)"sv, R"('That,' she said, 'is still pointless.')"sv }, + }; + REQUIRE(tbl == expected); + }); + } - parsing_should_succeed(FILE_LINE_ARGS, - spec_table_1, - [](toml::table&& tbl) // spec-table-1 - { - const auto expected = toml::table{ - { R"(table-1)"sv, - toml::table{ - { R"(key1)"sv, R"(some string)"sv }, - { R"(key2)"sv, 123 }, - } }, - { R"(table-2)"sv, - toml::table{ - { R"(key1)"sv, R"(another string)"sv }, - { R"(key2)"sv, 456 }, - } }, - }; - REQUIRE(tbl == expected); - }); + SECTION("spec-table-1") + { + parsing_should_succeed(FILE_LINE_ARGS, + spec_table_1, + [](toml::table&& tbl) // spec-table-1 + { + const auto expected = toml::table{ + { R"(table-1)"sv, + toml::table{ + { R"(key1)"sv, R"(some string)"sv }, + { R"(key2)"sv, 123 }, + } }, + { R"(table-2)"sv, + toml::table{ + { R"(key1)"sv, R"(another string)"sv }, + { R"(key2)"sv, 456 }, + } }, + }; + REQUIRE(tbl == expected); + }); + } - parsing_should_succeed(FILE_LINE_ARGS, - spec_table_2, - [](toml::table&& tbl) // spec-table-2 - { - const auto expected = toml::table{ - { R"(dog)"sv, - toml::table{ - { R"(tater.man)"sv, - toml::table{ - { R"(type)"sv, - toml::table{ - { R"(name)"sv, R"(pug)"sv }, - } }, - } }, - } }, - }; - REQUIRE(tbl == expected); - }); + SECTION("spec-table-2") + { + parsing_should_succeed(FILE_LINE_ARGS, + spec_table_2, + [](toml::table&& tbl) // spec-table-2 + { + const auto expected = toml::table{ + { R"(dog)"sv, + toml::table{ + { R"(tater.man)"sv, + toml::table{ + { R"(type)"sv, + toml::table{ + { R"(name)"sv, R"(pug)"sv }, + } }, + } }, + } }, + }; + REQUIRE(tbl == expected); + }); + } - parsing_should_succeed(FILE_LINE_ARGS, - spec_table_3, - [](toml::table&& tbl) // spec-table-3 - { - const auto expected = toml::table{ - { R"(a)"sv, - toml::table{ - { R"(b)"sv, - toml::table{ - { R"(c)"sv, toml::table{} }, - } }, - } }, - }; - REQUIRE(tbl == expected); - }); + SECTION("spec-table-3") + { + parsing_should_succeed(FILE_LINE_ARGS, + spec_table_3, + [](toml::table&& tbl) // spec-table-3 + { + const auto expected = toml::table{ + { R"(a)"sv, + toml::table{ + { R"(b)"sv, + toml::table{ + { R"(c)"sv, toml::table{} }, + } }, + } }, + }; + REQUIRE(tbl == expected); + }); + } - parsing_should_succeed(FILE_LINE_ARGS, - spec_table_4, - [](toml::table&& tbl) // spec-table-4 - { - const auto expected = toml::table{ - { R"(d)"sv, - toml::table{ - { R"(e)"sv, - toml::table{ - { R"(f)"sv, toml::table{} }, - } }, - } }, - }; - REQUIRE(tbl == expected); - }); + SECTION("spec-table-4") + { + parsing_should_succeed(FILE_LINE_ARGS, + spec_table_4, + [](toml::table&& tbl) // spec-table-4 + { + const auto expected = toml::table{ + { R"(d)"sv, + toml::table{ + { R"(e)"sv, + toml::table{ + { R"(f)"sv, toml::table{} }, + } }, + } }, + }; + REQUIRE(tbl == expected); + }); + } - parsing_should_succeed(FILE_LINE_ARGS, - spec_table_5, - [](toml::table&& tbl) // spec-table-5 - { - const auto expected = toml::table{ - { R"(g)"sv, - toml::table{ - { R"(h)"sv, - toml::table{ - { R"(i)"sv, toml::table{} }, - } }, - } }, - }; - REQUIRE(tbl == expected); - }); + SECTION("spec-table-5") + { + parsing_should_succeed(FILE_LINE_ARGS, + spec_table_5, + [](toml::table&& tbl) // spec-table-5 + { + const auto expected = toml::table{ + { R"(g)"sv, + toml::table{ + { R"(h)"sv, + toml::table{ + { R"(i)"sv, toml::table{} }, + } }, + } }, + }; + REQUIRE(tbl == expected); + }); + } - parsing_should_succeed(FILE_LINE_ARGS, - spec_table_7, - [](toml::table&& tbl) // spec-table-7 - { - const auto expected = toml::table{ - { R"(x)"sv, - toml::table{ - { R"(y)"sv, - toml::table{ - { R"(z)"sv, - toml::table{ - { R"(w)"sv, toml::table{} }, - } }, - } }, - } }, - }; - REQUIRE(tbl == expected); - }); + SECTION("spec-table-7") + { + parsing_should_succeed(FILE_LINE_ARGS, + spec_table_7, + [](toml::table&& tbl) // spec-table-7 + { + const auto expected = toml::table{ + { R"(x)"sv, + toml::table{ + { R"(y)"sv, + toml::table{ + { R"(z)"sv, + toml::table{ + { R"(w)"sv, toml::table{} }, + } }, + } }, + } }, + }; + REQUIRE(tbl == expected); + }); + } - parsing_should_succeed(FILE_LINE_ARGS, - spec_table_8, - [](toml::table&& tbl) // spec-table-8 - { - const auto expected = toml::table{ - { R"(fruit)"sv, - toml::table{ - { R"(apple)"sv, - toml::table{ - { R"(color)"sv, R"(red)"sv }, - { R"(taste)"sv, - toml::table{ - { R"(sweet)"sv, true }, - } }, - { R"(texture)"sv, - toml::table{ - { R"(smooth)"sv, true }, - } }, - } }, - } }, - }; - REQUIRE(tbl == expected); - }); + SECTION("spec-table-8") + { + parsing_should_succeed(FILE_LINE_ARGS, + spec_table_8, + [](toml::table&& tbl) // spec-table-8 + { + const auto expected = toml::table{ + { R"(fruit)"sv, + toml::table{ + { R"(apple)"sv, + toml::table{ + { R"(color)"sv, R"(red)"sv }, + { R"(taste)"sv, + toml::table{ + { R"(sweet)"sv, true }, + } }, + { R"(texture)"sv, + toml::table{ + { R"(smooth)"sv, true }, + } }, + } }, + } }, + }; + REQUIRE(tbl == expected); + }); + } - parsing_should_succeed(FILE_LINE_ARGS, - spec_table_inline_1, - [](toml::table&& tbl) // spec-table-inline-1 - { - const auto expected = toml::table{ - { R"(name)"sv, - toml::table{ - { R"(first)"sv, R"(Tom)"sv }, - { R"(last)"sv, R"(Preston-Werner)"sv }, - } }, - }; - REQUIRE(tbl == expected); - }); + SECTION("spec-table-inline-1") + { + parsing_should_succeed(FILE_LINE_ARGS, + spec_table_inline_1, + [](toml::table&& tbl) // spec-table-inline-1 + { + const auto expected = toml::table{ + { R"(name)"sv, + toml::table{ + { R"(first)"sv, R"(Tom)"sv }, + { R"(last)"sv, R"(Preston-Werner)"sv }, + } }, + }; + REQUIRE(tbl == expected); + }); + } - parsing_should_succeed(FILE_LINE_ARGS, - spec_table_inline_2, - [](toml::table&& tbl) // spec-table-inline-2 - { - const auto expected = toml::table{ - { R"(point)"sv, - toml::table{ - { R"(x)"sv, 1 }, - { R"(y)"sv, 2 }, - } }, - }; - REQUIRE(tbl == expected); - }); + SECTION("spec-table-inline-2") + { + parsing_should_succeed(FILE_LINE_ARGS, + spec_table_inline_2, + [](toml::table&& tbl) // spec-table-inline-2 + { + const auto expected = toml::table{ + { R"(point)"sv, + toml::table{ + { R"(x)"sv, 1 }, + { R"(y)"sv, 2 }, + } }, + }; + REQUIRE(tbl == expected); + }); + } - parsing_should_succeed(FILE_LINE_ARGS, - spec_table_inline_3, - [](toml::table&& tbl) // spec-table-inline-3 - { - const auto expected = toml::table{ - { R"(animal)"sv, - toml::table{ - { R"(type)"sv, - toml::table{ - { R"(name)"sv, R"(pug)"sv }, - } }, - } }, - }; - REQUIRE(tbl == expected); - }); + SECTION("spec-table-inline-3") + { + parsing_should_succeed(FILE_LINE_ARGS, + spec_table_inline_3, + [](toml::table&& tbl) // spec-table-inline-3 + { + const auto expected = toml::table{ + { R"(animal)"sv, + toml::table{ + { R"(type)"sv, + toml::table{ + { R"(name)"sv, R"(pug)"sv }, + } }, + } }, + }; + REQUIRE(tbl == expected); + }); + } - parsing_should_succeed(FILE_LINE_ARGS, - spec_table, - [](toml::table&& tbl) // spec-table - { - const auto expected = toml::table{ - { R"(table)"sv, toml::table{} }, - }; - REQUIRE(tbl == expected); - }); + SECTION("spec-table") + { + parsing_should_succeed(FILE_LINE_ARGS, + spec_table, + [](toml::table&& tbl) // spec-table + { + const auto expected = toml::table{ + { R"(table)"sv, toml::table{} }, + }; + REQUIRE(tbl == expected); + }); + } - parsing_should_succeed(FILE_LINE_ARGS, - spec_time_1, - [](toml::table&& tbl) // spec-time-1 - { - const auto expected = toml::table{ - { R"(lt1)"sv, toml::time{ 7, 32 } }, - }; - REQUIRE(tbl == expected); - }); + SECTION("spec-time-1") + { + parsing_should_succeed(FILE_LINE_ARGS, + spec_time_1, + [](toml::table&& tbl) // spec-time-1 + { + const auto expected = toml::table{ + { R"(lt1)"sv, toml::time{ 7, 32 } }, + }; + REQUIRE(tbl == expected); + }); + } #if UNICODE_LITERALS_OK - parsing_should_succeed(FILE_LINE_ARGS, - spec_quoted_basic_keys_1, - [](toml::table&& tbl) // spec-quoted-basic-keys-1 - { - const auto expected = toml::table{ - { R"(ʎǝʞ)"sv, R"(value)"sv }, - }; - REQUIRE(tbl == expected); - }); + SECTION("spec-quoted-basic-keys-1") + { + parsing_should_succeed(FILE_LINE_ARGS, + spec_quoted_basic_keys_1, + [](toml::table&& tbl) // spec-quoted-basic-keys-1 + { + const auto expected = toml::table{ + { R"(ʎǝʞ)"sv, R"(value)"sv }, + }; + REQUIRE(tbl == expected); + }); + } - parsing_should_succeed(FILE_LINE_ARGS, - spec_string_basic, - [](toml::table&& tbl) // spec-string-basic - { - const auto expected = toml::table{ - { R"(str)"sv, R"(I'm a string. "You can quote me". Name José + SECTION("spec-string-basic") + { + parsing_should_succeed(FILE_LINE_ARGS, + spec_string_basic, + [](toml::table&& tbl) // spec-string-basic + { + const auto expected = toml::table{ + { R"(str)"sv, R"(I'm a string. "You can quote me". Name José Location SF.)"sv }, - }; - REQUIRE(tbl == expected); - }); + }; + REQUIRE(tbl == expected); + }); + } - parsing_should_succeed(FILE_LINE_ARGS, - spec_table_6, - [](toml::table&& tbl) // spec-table-6 - { - const auto expected = toml::table{ - { R"(j)"sv, - toml::table{ - { R"(ʞ)"sv, - toml::table{ - { R"(l)"sv, toml::table{} }, - } }, - } }, - }; - REQUIRE(tbl == expected); - }); + SECTION("spec-table-6") + { + parsing_should_succeed(FILE_LINE_ARGS, + spec_table_6, + [](toml::table&& tbl) // spec-table-6 + { + const auto expected = toml::table{ + { R"(j)"sv, + toml::table{ + { R"(ʞ)"sv, + toml::table{ + { R"(l)"sv, toml::table{} }, + } }, + } }, + }; + REQUIRE(tbl == expected); + }); + } #endif // UNICODE_LITERALS_OK } diff --git a/tests/user_feedback.cpp b/tests/user_feedback.cpp index 1590936..b754280 100644 --- a/tests/user_feedback.cpp +++ b/tests/user_feedback.cpp @@ -382,4 +382,15 @@ b = [] parse_expected_value(FILE_LINE_ARGS, "6.9342"sv, 6.9342); parse_expected_value(FILE_LINE_ARGS, "-995.9214"sv, -995.9214); } + + SECTION("tomlplusplus/issues/187") // https://github.com/marzer/tomlplusplus/issues/187 + { + parsing_should_succeed(FILE_LINE_ARGS, R"( + [[a.b]] + x = 1 + + [a] + y = 2 + )"sv); + } } diff --git a/toml.hpp b/toml.hpp index 1301c15..dd12734 100644 --- a/toml.hpp +++ b/toml.hpp @@ -541,7 +541,7 @@ __pragma(warning(push)) \ static_assert(true) -#if TOML_HAS_INCLUDE() +#if TOML_HAS_INCLUDE() #pragma warning(push, 0) #include #pragma warning(pop) @@ -1115,12 +1115,12 @@ TOML_DISABLE_SUGGEST_ATTR_WARNINGS; #pragma warning(disable : 4251) // dll exports for std lib types #endif #elif TOML_CLANG -#pragma clang diagnostic ignored "-Wheader-hygiene" +TOML_PRAGMA_CLANG(diagnostic ignored "-Wheader-hygiene") #if TOML_CLANG >= 12 -#pragma clang diagnostic ignored "-Wc++20-extensions" +TOML_PRAGMA_CLANG(diagnostic ignored "-Wc++20-extensions") #endif -#if TOML_CLANG == 13 && !defined(__APPLE__) -#pragma clang diagnostic ignored "-Wreserved-identifier" +#if TOML_CLANG == 13 +TOML_PRAGMA_CLANG(diagnostic ignored "-Wreserved-identifier") #endif #endif @@ -14262,14 +14262,21 @@ TOML_IMPL_NAMESPACE_START } // range check - if TOML_UNLIKELY(result > static_cast((std::numeric_limits::max)()) + (sign < 0 ? 1ull : 0ull)) + static constexpr auto i64_max = static_cast((std::numeric_limits::max)()); + if TOML_UNLIKELY(result > i64_max + (sign < 0 ? 1u : 0u)) set_error_and_return_default("'"sv, traits::full_prefix, std::string_view{ digits, length }, "' is not representable in 64 bits"sv); if constexpr (traits::is_signed) + { + // avoid signed multiply UB when parsing INT64_MIN + if TOML_UNLIKELY(sign < 0 && result == i64_max + 1u) + return (std::numeric_limits::min)(); + return static_cast(result) * sign; + } else return static_cast(result); } @@ -15251,13 +15258,28 @@ TOML_IMPL_NAMESPACE_START else if (auto tbl = matching_node.as_table(); !is_arr && tbl && !implicit_tables.empty()) { - if (auto found = impl::find(implicit_tables.begin(), implicit_tables.end(), tbl); - found && (tbl->empty() || tbl->is_homogeneous
())) + if (auto found = impl::find(implicit_tables.begin(), implicit_tables.end(), tbl); found) { - implicit_tables.erase(implicit_tables.cbegin() + (found - implicit_tables.data())); - tbl->source_.begin = header_begin_pos; - tbl->source_.end = header_end_pos; - return tbl; + bool ok = true; + if (!tbl->empty()) + { + for (auto& [_, child] : *tbl) + { + if (!child.is_table() && !child.is_array_of_tables()) + { + ok = false; + break; + } + } + } + + if (ok) + { + implicit_tables.erase(implicit_tables.cbegin() + (found - implicit_tables.data())); + tbl->source_.begin = header_begin_pos; + tbl->source_.end = header_end_pos; + return tbl; + } } } diff --git a/tools/generate_conformance_tests.py b/tools/generate_conformance_tests.py index 45eeaed..a0bc83f 100755 --- a/tools/generate_conformance_tests.py +++ b/tools/generate_conformance_tests.py @@ -470,6 +470,10 @@ def load_burnsushi_tests(tests): )) add_condition(tests['valid']['burntsushi'], 'TOML_LANG_UNRELEASED', ( 'string-escape-esc', # \e in strings + 'datetime-no-seconds', # omitting seconds from date-times + 'inline-table-newline', + 'key-unicode', + 'string-hex-escape' )) tests['invalid']['burntsushi'] = load_tests(Path(root_dir, 'invalid'), False) @@ -575,6 +579,8 @@ def write_test_file(name, all_tests): write('') write(f'#if {condition}'); for test in tests: + write('') + write(f'\tSECTION("{test.name()}") {{') write('') expected = test.expected() if isinstance(expected, bool): @@ -589,6 +595,9 @@ def write_test_file(name, all_tests): write(f'\t\tconst auto expected = {s};') write('\t\tREQUIRE(tbl == expected);') write('\t});') + write('') + write('\t}') + write('') if condition != '': write('') write(f'#endif // {condition}');