diff --git a/external/toml-test b/external/toml-test index 269931e..51f2e53 160000 --- a/external/toml-test +++ b/external/toml-test @@ -1 +1 @@ -Subproject commit 269931e74e3fef9d81729fe0f351f21f65cfce4b +Subproject commit 51f2e538628727ca749e10701aaf8d53a4d81bac diff --git a/include/toml++/toml_parser.hpp b/include/toml++/toml_parser.hpp index ccac940..e0f8a1d 100644 --- a/include/toml++/toml_parser.hpp +++ b/include/toml++/toml_parser.hpp @@ -51,7 +51,7 @@ TOML_ANON_NAMESPACE_START } template struct parse_integer_traits; - template <> struct parse_integer_traits<2> final + template <> struct parse_integer_traits<2> { static constexpr auto scope_qualifier = "binary integer"sv; static constexpr auto is_digit = ::toml::impl::is_binary_digit; @@ -60,7 +60,7 @@ TOML_ANON_NAMESPACE_START static constexpr auto prefix_codepoint = U'b'; static constexpr auto prefix = "b"sv; }; - template <> struct parse_integer_traits<8> final + template <> struct parse_integer_traits<8> { static constexpr auto scope_qualifier = "octal integer"sv; static constexpr auto is_digit = ::toml::impl::is_octal_digit; @@ -69,14 +69,14 @@ TOML_ANON_NAMESPACE_START static constexpr auto prefix_codepoint = U'o'; static constexpr auto prefix = "o"sv; }; - template <> struct parse_integer_traits<10> final + template <> struct parse_integer_traits<10> { static constexpr auto scope_qualifier = "decimal integer"sv; static constexpr auto is_digit = ::toml::impl::is_decimal_digit; static constexpr auto is_signed = true; static constexpr auto buffer_length = 19; //strlen("9223372036854775807") }; - template <> struct parse_integer_traits<16> final + template <> struct parse_integer_traits<16> { static constexpr auto scope_qualifier = "hexadecimal integer"sv; static constexpr auto is_digit = ::toml::impl::is_hexadecimal_digit; @@ -198,7 +198,7 @@ TOML_ANON_NAMESPACE_START } } - struct error_builder final + struct error_builder { static constexpr std::size_t buf_size = 512; char buf[buf_size]; @@ -242,7 +242,7 @@ TOML_ANON_NAMESPACE_START error_builder& operator=(error_builder&&) = delete; }; - struct parse_scope final + struct parse_scope { std::string_view& storage_; std::string_view parent_; @@ -330,18 +330,19 @@ TOML_ANON_NAMESPACE_START } }; - struct parsed_key final + struct parsed_key { + toml::source_position position; std::vector segments; }; - struct parsed_key_value_pair final + struct parsed_key_value_pair { parsed_key key; node_ptr value; }; - struct parse_depth_counter final + struct parse_depth_counter { size_t& depth_; @@ -363,6 +364,11 @@ TOML_ANON_NAMESPACE_START parse_depth_counter& operator=(parse_depth_counter&&) = delete; }; + struct parsed_string + { + std::string value; + bool was_multi_line; + }; } TOML_ANON_NAMESPACE_END; @@ -389,8 +395,8 @@ TOML_IMPL_NAMESPACE_START #if TOML_EXCEPTIONS #define is_error() false #define return_after_error(...) TOML_UNREACHABLE - #define assert_not_error() (void)0 - #define return_if_error(...) (void)0 + #define assert_not_error() static_assert(true) + #define return_if_error(...) static_assert(true) #define return_if_error_or_eof(...) return_if_eof(__VA_ARGS__) #else #define is_error() !!err @@ -400,6 +406,25 @@ TOML_IMPL_NAMESPACE_START #define return_if_error_or_eof(...) do { if (is_eof() || is_error()) return __VA_ARGS__; } while(false) #endif + #if defined(TOML_BREAK_AT_PARSE_ERRORS) && TOML_BREAK_AT_PARSE_ERRORS + #if defined(__has_builtin) + #if __has_builtin(__builtin_debugtrap) + #define parse_error_break() __builtin_debugtrap() + #elif __has_builtin(__debugbreak) + #define parse_error_break() __debugbreak() + #endif + #endif + #ifndef parse_error_break + #if TOML_MSVC || TOML_ICC + #define parse_error_break() __debugbreak() + #else + #define parse_error_break() TOML_ASSERT(false) + #endif + #endif + #else + #define parse_error_break() static_assert(true) + #endif + #define set_error_and_return(ret, ...) \ do { if (!is_error()) set_error(__VA_ARGS__); return_after_error(ret); } while(false) @@ -421,7 +446,7 @@ TOML_IMPL_NAMESPACE_START TOML_ABI_NAMESPACE_BOOL(TOML_EXCEPTIONS, ex, noex); - class parser final + class parser { private: static constexpr size_t max_nested_values = TOML_MAX_NESTED_VALUES; @@ -463,6 +488,8 @@ TOML_IMPL_NAMESPACE_START error_builder builder{ current_scope }; (builder.append(reason), ...); + parse_error_break(); + #if TOML_EXCEPTIONS builder.finish(pos, reader.source_path()); #else @@ -1031,12 +1058,6 @@ TOML_IMPL_NAMESPACE_START set_error_and_return_default("encountered end-of-file"sv); } - struct parsed_string final - { - std::string value; - bool was_multi_line; - }; - [[nodiscard]] TOML_NEVER_INLINE parsed_string parse_string() TOML_MAY_THROW @@ -2427,6 +2448,7 @@ TOML_IMPL_NAMESPACE_START push_parse_scope("key"sv); parsed_key key; + key.position = current_position(); recording_whitespace = false; while (!is_error()) @@ -2528,7 +2550,7 @@ TOML_IMPL_NAMESPACE_START assert_or_assume(*cp == U'['); push_parse_scope("table header"sv); - const auto header_begin_pos = cp->position; + const source_position header_begin_pos = cp->position; source_position header_end_pos; parsed_key key; bool is_arr = false; @@ -2687,7 +2709,7 @@ TOML_IMPL_NAMESPACE_START && !implicit_tables.empty()) { auto tbl = &matching_node->ref_cast(); - if (auto found = find(implicit_tables, tbl)) + if (auto found = find(implicit_tables, tbl); found && (tbl->empty() || tbl->is_homogeneous
())) { implicit_tables.erase(implicit_tables.cbegin() + (found - implicit_tables.data())); tbl->source_.begin = header_begin_pos; @@ -2698,13 +2720,19 @@ TOML_IMPL_NAMESPACE_START //if we get here it's a redefinition error. if (!is_arr && matching_node->type() == node_type::table) - set_error_and_return_default("cannot redefine existing table '"sv, to_sv(recording_buffer), "'"sv); + { + set_error_at(header_begin_pos, "cannot redefine existing table '"sv, to_sv(recording_buffer), "'"sv); + return_after_error({}); + } else - set_error_and_return_default( + { + set_error_at(header_begin_pos, "cannot redefine existing "sv, to_sv(matching_node->type()), " '"sv, to_sv(recording_buffer), "' as "sv, is_arr ? "array-of-tables"sv : "table"sv ); + return_after_error({}); + } } } @@ -2735,9 +2763,11 @@ TOML_IMPL_NAMESPACE_START dotted_key_tables.push_back(&child->ref_cast
()); child->source_ = kvp.value.get()->source_; } - else if (!child->is_table() - || !(find(dotted_key_tables, &child->ref_cast
()) || find(implicit_tables, &child->ref_cast
()))) - set_error("cannot redefine existing "sv, to_sv(child->type()), " as dotted key-value pair"sv); + else if (!child->is_table() || !( + find(dotted_key_tables, &child->ref_cast
()) + || find(implicit_tables, &child->ref_cast
()) + )) + set_error_at(kvp.key.position, "cannot redefine existing "sv, to_sv(child->type()), " as dotted key-value pair"sv); else child->source_.end = kvp.value.get()->source_.end; @@ -3135,6 +3165,7 @@ TOML_IMPL_NAMESPACE_START #undef advance_and_return_if_error #undef advance_and_return_if_error_or_eof #undef assert_or_assume + #undef parse_error_break } TOML_IMPL_NAMESPACE_END; diff --git a/tests/conformance_burntsushi_invalid.cpp b/tests/conformance_burntsushi_invalid.cpp index b1930e1..cc72d8b 100644 --- a/tests/conformance_burntsushi_invalid.cpp +++ b/tests/conformance_burntsushi_invalid.cpp @@ -17,11 +17,11 @@ namespace static constexpr auto array_no_close_table_2 = R"(x = [{ key = 42 #)"sv; static constexpr auto array_no_close_table = R"(x = [{ key = 42)"sv; static constexpr auto array_no_close = R"(long_array = [ 1, 2, 3)"sv; - static constexpr auto array_of_tables_1 = R"(# INVALID TOML DOC + static constexpr auto array_tables_1 = R"(# INVALID TOML DOC fruit = [] [[fruit]] # Not allowed)"sv; - static constexpr auto array_of_tables_2 = R"(# INVALID TOML DOC + static constexpr auto array_tables_2 = R"(# INVALID TOML DOC [[fruit]] name = "apple" @@ -31,6 +31,19 @@ fruit = [] # This table conflicts with the previous table [fruit.variety] name = "granny smith")"sv; + static constexpr auto array_text_after_array_entries = R"(array = [ + "Is there life after an array separator?", No + "Entry" +])"sv; + static constexpr auto array_text_before_array_separator = R"(array = [ + "Is there life before an array separator?" No, + "Entry" +])"sv; + static constexpr auto array_text_in_array = R"(array = [ + "Entry 1", + I don't belong, + "Entry 2", +])"sv; static constexpr auto bool_mixed_case = R"(valid = False)"sv; static constexpr auto bool_wrong_case_false = R"(b = FALSE)"sv; @@ -48,23 +61,6 @@ fruit = [] #endif // !TOML_LANG_UNRELEASED - static constexpr auto duplicate_key_table = R"([fruit] -type = "apple" - -[fruit.type] -apple = "yes")"sv; - static constexpr auto duplicate_keys = R"(dupe = false -dupe = true)"sv; - static constexpr auto duplicate_table_array = R"([tbl] -[[tbl]])"sv; - static constexpr auto duplicate_table_array2 = R"([[tbl]] -[tbl])"sv; - static constexpr auto duplicate_tables = R"([a] -[a])"sv; - - static constexpr auto empty_implicit_table = R"([naughty..naughty])"sv; - static constexpr auto empty_table = R"([])"sv; - static constexpr auto float_double_point_1 = R"(double-point-1 = 0..1)"sv; static constexpr auto float_double_point_2 = R"(double-point-2 = 0.1.2)"sv; static constexpr auto float_exp_double_e_1 = R"(exp-double-e-1 = 1ee2)"sv; @@ -110,6 +106,10 @@ simple = { a = 1 b=2})"sv; static constexpr auto inline_table_linebreak_3 = R"(t = {a=1 ,b=2})"sv; + static constexpr auto inline_table_linebreak_4 = R"(json_like = { + first = "Tom", + last = "Preston-Werner" +})"sv; static constexpr auto inline_table_trailing_comma = R"(# A terminating comma (also called trailing comma) is not permitted after the # last key/value pair in an inline table abc = { abc = 123, })"sv; @@ -139,6 +139,7 @@ abc = { abc = 123, })"sv; static constexpr auto integer_positive_bin = R"(positive-bin = +0b11010110)"sv; static constexpr auto integer_positive_hex = R"(positive-hex = +0xff)"sv; static constexpr auto integer_positive_oct = R"(positive-oct = +0o99)"sv; + static constexpr auto integer_text_after_integer = R"(answer = 42 the ultimate answer?)"sv; static constexpr auto integer_trailing_us_bin = R"(trailing-us-bin = 0b1_)"sv; static constexpr auto integer_trailing_us_hex = R"(trailing-us-hex = 0x1_)"sv; static constexpr auto integer_trailing_us_oct = R"(trailing-us-oct = 0o1_)"sv; @@ -155,6 +156,8 @@ abc = { abc = 123, })"sv; a.b = 1 # Tries to access it as table: error a.b.c = 2)"sv; + static constexpr auto key_duplicate_keys = R"(dupe = false +dupe = true)"sv; static constexpr auto key_duplicate = R"(# DO NOT DO THIS name = "Tom" name = "Pradyun")"sv; @@ -185,23 +188,6 @@ key""" = 1)"sv; #endif // !TOML_LANG_UNRELEASED && UNICODE_LITERALS_OK - static constexpr auto llbrace = R"([ [table]])"sv; - -#if !TOML_LANG_UNRELEASED - - static constexpr auto multi_line_inline_table = R"(json_like = { - first = "Tom", - last = "Preston-Werner" -})"sv; - -#endif // !TOML_LANG_UNRELEASED - - static constexpr auto multi_line_string_no_close_2 = R"(x=""")"sv; - static constexpr auto multi_line_string_no_close = R"(invalid = """ - this will fail)"sv; - - static constexpr auto rrbrace = R"([[table] ])"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; @@ -223,9 +209,13 @@ second line")"sv; static constexpr auto string_multiline_escape_space = R"(a = """ foo \ \n bar""")"sv; + static constexpr auto string_multiline_no_close_2 = R"(x=""")"sv; + static constexpr auto string_multiline_no_close = R"(invalid = """ + this will fail)"sv; static constexpr auto string_multiline_quotes_1 = R"(a = """6 quotes: """""")"sv; static constexpr auto string_multiline_quotes_2 = R"(a = """6 quotes: """""")"sv; static constexpr auto string_no_close = R"(no-ending-quote = "One time, at band camp)"sv; + static constexpr auto string_text_after_string = R"(string = "Is there life after strings?" No.)"sv; static constexpr auto string_wrong_close = R"(bad-ending-quote = "double and single')"sv; #if !TOML_LANG_UNRELEASED @@ -252,13 +242,24 @@ 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_table = R"([fruit] +type = "apple" + +[fruit.type] +apple = "yes")"sv; + static constexpr auto table_duplicate_table_array = R"([tbl] +[[tbl]])"sv; + static constexpr auto table_duplicate_table_array2 = R"([[tbl]] +[tbl])"sv; static constexpr auto table_duplicate = R"([a] b = 1 [a] c = 2)"sv; + static constexpr auto table_empty_implicit_table = R"([naughty..naughty])"sv; static constexpr auto table_empty = R"([])"sv; static constexpr auto table_equals_sign = R"([name=bad])"sv; + static constexpr auto table_llbrace = R"([ [table]])"sv; static constexpr auto table_nested_brackets_close = R"([a]b] zyx = 42)"sv; static constexpr auto table_nested_brackets_open = R"([a[b] @@ -271,368 +272,345 @@ b = 1 [a.b] c = 2)"sv; + static constexpr auto table_rrbrace = R"([[table] ])"sv; + static constexpr auto table_text_after_table = R"([error] this shouldn't be here)"sv; static constexpr auto table_whitespace = R"([invalid key])"sv; static constexpr auto table_with_pound = R"([key#group] answer = 42)"sv; - - static constexpr auto text_after_array_entries = R"(array = [ - "Is there life after an array separator?", No - "Entry" -])"sv; - static constexpr auto text_after_integer = R"(answer = 42 the ultimate answer?)"sv; - static constexpr auto text_after_string = R"(string = "Is there life after strings?" No.)"sv; - static constexpr auto text_after_table = R"([error] this shouldn't be here)"sv; - static constexpr auto text_before_array_separator = R"(array = [ - "Is there life before an array separator?" No, - "Entry" -])"sv; - static constexpr auto text_in_array = R"(array = [ - "Entry 1", - I don't belong, - "Entry 2", -])"sv; } TOML_ENABLE_WARNINGS; TEST_CASE("conformance - burntsushi/invalid") { - parsing_should_fail(FILE_LINE_ARGS, 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); + 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); + 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); + parsing_should_fail(FILE_LINE_ARGS, array_no_close_table); // array-no-close-table - parsing_should_fail(FILE_LINE_ARGS, array_no_close); + parsing_should_fail(FILE_LINE_ARGS, array_no_close); // array-no-close - parsing_should_fail(FILE_LINE_ARGS, array_of_tables_1); + parsing_should_fail(FILE_LINE_ARGS, array_tables_1); // array-tables-1 - parsing_should_fail(FILE_LINE_ARGS, array_of_tables_2); + parsing_should_fail(FILE_LINE_ARGS, array_tables_2); // array-tables-2 - parsing_should_fail(FILE_LINE_ARGS, bool_mixed_case); + parsing_should_fail(FILE_LINE_ARGS, array_text_after_array_entries); // array-text-after-array-entries - parsing_should_fail(FILE_LINE_ARGS, bool_wrong_case_false); + parsing_should_fail(FILE_LINE_ARGS, array_text_before_array_separator); // array-text-before-array-separator - parsing_should_fail(FILE_LINE_ARGS, bool_wrong_case_true); + parsing_should_fail(FILE_LINE_ARGS, array_text_in_array); // array-text-in-array - parsing_should_fail(FILE_LINE_ARGS, datetime_impossible_date); + parsing_should_fail(FILE_LINE_ARGS, bool_mixed_case); // bool-mixed-case - parsing_should_fail(FILE_LINE_ARGS, datetime_no_leads_with_milli); + parsing_should_fail(FILE_LINE_ARGS, bool_wrong_case_false); // bool-wrong-case-false - parsing_should_fail(FILE_LINE_ARGS, datetime_no_leads); + parsing_should_fail(FILE_LINE_ARGS, bool_wrong_case_true); // bool-wrong-case-true - parsing_should_fail(FILE_LINE_ARGS, datetime_no_t); + parsing_should_fail(FILE_LINE_ARGS, datetime_impossible_date); // datetime-impossible-date - parsing_should_fail(FILE_LINE_ARGS, datetime_trailing_t); + 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 + + parsing_should_fail(FILE_LINE_ARGS, datetime_no_t); // datetime-no-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); + parsing_should_fail(FILE_LINE_ARGS, datetime_no_secs); // datetime-no-secs #endif // !TOML_LANG_UNRELEASED - parsing_should_fail(FILE_LINE_ARGS, duplicate_key_table); + parsing_should_fail(FILE_LINE_ARGS, float_double_point_1); // float-double-point-1 - parsing_should_fail(FILE_LINE_ARGS, duplicate_keys); + parsing_should_fail(FILE_LINE_ARGS, float_double_point_2); // float-double-point-2 - parsing_should_fail(FILE_LINE_ARGS, duplicate_table_array); + parsing_should_fail(FILE_LINE_ARGS, float_exp_double_e_1); // float-exp-double-e-1 - parsing_should_fail(FILE_LINE_ARGS, duplicate_table_array2); + parsing_should_fail(FILE_LINE_ARGS, float_exp_double_e_2); // float-exp-double-e-2 - parsing_should_fail(FILE_LINE_ARGS, duplicate_tables); + parsing_should_fail(FILE_LINE_ARGS, float_exp_double_us); // float-exp-double-us - parsing_should_fail(FILE_LINE_ARGS, empty_implicit_table); + parsing_should_fail(FILE_LINE_ARGS, float_exp_leading_us); // float-exp-leading-us - parsing_should_fail(FILE_LINE_ARGS, empty_table); + parsing_should_fail(FILE_LINE_ARGS, float_exp_point_1); // float-exp-point-1 - parsing_should_fail(FILE_LINE_ARGS, float_double_point_1); + parsing_should_fail(FILE_LINE_ARGS, float_exp_point_2); // float-exp-point-2 - parsing_should_fail(FILE_LINE_ARGS, float_double_point_2); + parsing_should_fail(FILE_LINE_ARGS, float_exp_trailing_us); // float-exp-trailing-us - parsing_should_fail(FILE_LINE_ARGS, float_exp_double_e_1); + parsing_should_fail(FILE_LINE_ARGS, float_inf_incomplete_1); // float-inf-incomplete-1 - parsing_should_fail(FILE_LINE_ARGS, float_exp_double_e_2); + parsing_should_fail(FILE_LINE_ARGS, float_inf_incomplete_2); // float-inf-incomplete-2 - parsing_should_fail(FILE_LINE_ARGS, float_exp_double_us); + parsing_should_fail(FILE_LINE_ARGS, float_inf_incomplete_3); // float-inf-incomplete-3 - parsing_should_fail(FILE_LINE_ARGS, float_exp_leading_us); + parsing_should_fail(FILE_LINE_ARGS, float_inf_underscore); // float-inf_underscore - parsing_should_fail(FILE_LINE_ARGS, float_exp_point_1); + parsing_should_fail(FILE_LINE_ARGS, float_leading_point_neg); // float-leading-point-neg - parsing_should_fail(FILE_LINE_ARGS, float_exp_point_2); + parsing_should_fail(FILE_LINE_ARGS, float_leading_point_plus); // float-leading-point-plus - parsing_should_fail(FILE_LINE_ARGS, float_exp_trailing_us); + parsing_should_fail(FILE_LINE_ARGS, float_leading_point); // float-leading-point - parsing_should_fail(FILE_LINE_ARGS, float_inf_incomplete_1); + parsing_should_fail(FILE_LINE_ARGS, float_leading_us); // float-leading-us - parsing_should_fail(FILE_LINE_ARGS, float_inf_incomplete_2); + parsing_should_fail(FILE_LINE_ARGS, float_leading_zero_neg); // float-leading-zero-neg - parsing_should_fail(FILE_LINE_ARGS, float_inf_incomplete_3); + parsing_should_fail(FILE_LINE_ARGS, float_leading_zero_plus); // float-leading-zero-plus - parsing_should_fail(FILE_LINE_ARGS, float_inf_underscore); + parsing_should_fail(FILE_LINE_ARGS, float_leading_zero); // float-leading-zero - parsing_should_fail(FILE_LINE_ARGS, float_leading_point_neg); + parsing_should_fail(FILE_LINE_ARGS, float_nan_incomplete_1); // float-nan-incomplete-1 - parsing_should_fail(FILE_LINE_ARGS, float_leading_point_plus); + parsing_should_fail(FILE_LINE_ARGS, float_nan_incomplete_2); // float-nan-incomplete-2 - parsing_should_fail(FILE_LINE_ARGS, float_leading_point); + parsing_should_fail(FILE_LINE_ARGS, float_nan_incomplete_3); // float-nan-incomplete-3 - parsing_should_fail(FILE_LINE_ARGS, float_leading_us); + parsing_should_fail(FILE_LINE_ARGS, float_nan_underscore); // float-nan_underscore - parsing_should_fail(FILE_LINE_ARGS, float_leading_zero_neg); + parsing_should_fail(FILE_LINE_ARGS, float_trailing_point_min); // float-trailing-point-min - parsing_should_fail(FILE_LINE_ARGS, float_leading_zero_plus); + parsing_should_fail(FILE_LINE_ARGS, float_trailing_point_plus); // float-trailing-point-plus - parsing_should_fail(FILE_LINE_ARGS, float_leading_zero); + parsing_should_fail(FILE_LINE_ARGS, float_trailing_point); // float-trailing-point - parsing_should_fail(FILE_LINE_ARGS, float_nan_incomplete_1); + parsing_should_fail(FILE_LINE_ARGS, float_trailing_us); // float-trailing-us - parsing_should_fail(FILE_LINE_ARGS, float_nan_incomplete_2); + parsing_should_fail(FILE_LINE_ARGS, float_us_after_point); // float-us-after-point - parsing_should_fail(FILE_LINE_ARGS, float_nan_incomplete_3); + parsing_should_fail(FILE_LINE_ARGS, float_us_before_point); // float-us-before-point - parsing_should_fail(FILE_LINE_ARGS, float_nan_underscore); + parsing_should_fail(FILE_LINE_ARGS, inline_table_double_comma); // inline-table-double-comma - parsing_should_fail(FILE_LINE_ARGS, float_trailing_point_min); + parsing_should_fail(FILE_LINE_ARGS, inline_table_empty); // inline-table-empty - parsing_should_fail(FILE_LINE_ARGS, float_trailing_point_plus); - - parsing_should_fail(FILE_LINE_ARGS, float_trailing_point); - - parsing_should_fail(FILE_LINE_ARGS, float_trailing_us); - - parsing_should_fail(FILE_LINE_ARGS, float_us_after_point); - - parsing_should_fail(FILE_LINE_ARGS, float_us_before_point); - - parsing_should_fail(FILE_LINE_ARGS, inline_table_double_comma); - - parsing_should_fail(FILE_LINE_ARGS, inline_table_empty); - - parsing_should_fail(FILE_LINE_ARGS, inline_table_no_comma); + parsing_should_fail(FILE_LINE_ARGS, inline_table_no_comma); // inline-table-no-comma #if !TOML_LANG_UNRELEASED - parsing_should_fail(FILE_LINE_ARGS, 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); + parsing_should_fail(FILE_LINE_ARGS, inline_table_linebreak_2); // inline-table-linebreak-2 - parsing_should_fail(FILE_LINE_ARGS, 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_trailing_comma); + 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 #endif // !TOML_LANG_UNRELEASED - parsing_should_fail(FILE_LINE_ARGS, integer_capital_bin); + parsing_should_fail(FILE_LINE_ARGS, integer_capital_bin); // integer-capital-bin - parsing_should_fail(FILE_LINE_ARGS, integer_capital_hex); + parsing_should_fail(FILE_LINE_ARGS, integer_capital_hex); // integer-capital-hex - parsing_should_fail(FILE_LINE_ARGS, 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); + parsing_should_fail(FILE_LINE_ARGS, integer_double_sign_nex); // integer-double-sign-nex - parsing_should_fail(FILE_LINE_ARGS, 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); + parsing_should_fail(FILE_LINE_ARGS, integer_double_us); // integer-double-us - parsing_should_fail(FILE_LINE_ARGS, integer_invalid_bin); + parsing_should_fail(FILE_LINE_ARGS, integer_invalid_bin); // integer-invalid-bin - parsing_should_fail(FILE_LINE_ARGS, integer_invalid_hex); + parsing_should_fail(FILE_LINE_ARGS, integer_invalid_hex); // integer-invalid-hex - parsing_should_fail(FILE_LINE_ARGS, 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); + parsing_should_fail(FILE_LINE_ARGS, integer_leading_us_bin); // integer-leading-us-bin - parsing_should_fail(FILE_LINE_ARGS, 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); + parsing_should_fail(FILE_LINE_ARGS, integer_leading_us_oct); // integer-leading-us-oct - parsing_should_fail(FILE_LINE_ARGS, 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); + parsing_should_fail(FILE_LINE_ARGS, integer_leading_zero_1); // integer-leading-zero-1 - parsing_should_fail(FILE_LINE_ARGS, 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_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); + parsing_should_fail(FILE_LINE_ARGS, integer_leading_zero_sign_2); // integer-leading-zero-sign-2 - parsing_should_fail(FILE_LINE_ARGS, integer_negative_bin); + parsing_should_fail(FILE_LINE_ARGS, integer_negative_bin); // integer-negative-bin - parsing_should_fail(FILE_LINE_ARGS, integer_negative_hex); + parsing_should_fail(FILE_LINE_ARGS, integer_negative_hex); // integer-negative-hex - parsing_should_fail(FILE_LINE_ARGS, integer_negative_oct); + parsing_should_fail(FILE_LINE_ARGS, integer_negative_oct); // integer-negative-oct - parsing_should_fail(FILE_LINE_ARGS, integer_positive_bin); + parsing_should_fail(FILE_LINE_ARGS, integer_positive_bin); // integer-positive-bin - parsing_should_fail(FILE_LINE_ARGS, integer_positive_hex); + parsing_should_fail(FILE_LINE_ARGS, integer_positive_hex); // integer-positive-hex - parsing_should_fail(FILE_LINE_ARGS, integer_positive_oct); + parsing_should_fail(FILE_LINE_ARGS, integer_positive_oct); // integer-positive-oct - parsing_should_fail(FILE_LINE_ARGS, integer_trailing_us_bin); + parsing_should_fail(FILE_LINE_ARGS, integer_text_after_integer); // integer-text-after-integer - parsing_should_fail(FILE_LINE_ARGS, integer_trailing_us_hex); + parsing_should_fail(FILE_LINE_ARGS, integer_trailing_us_bin); // integer-trailing-us-bin - parsing_should_fail(FILE_LINE_ARGS, integer_trailing_us_oct); + parsing_should_fail(FILE_LINE_ARGS, integer_trailing_us_hex); // integer-trailing-us-hex - parsing_should_fail(FILE_LINE_ARGS, integer_trailing_us); + parsing_should_fail(FILE_LINE_ARGS, integer_trailing_us_oct); // integer-trailing-us-oct - parsing_should_fail(FILE_LINE_ARGS, integer_us_after_bin); + parsing_should_fail(FILE_LINE_ARGS, integer_trailing_us); // integer-trailing-us - parsing_should_fail(FILE_LINE_ARGS, integer_us_after_hex); + parsing_should_fail(FILE_LINE_ARGS, integer_us_after_bin); // integer-us-after-bin - parsing_should_fail(FILE_LINE_ARGS, integer_us_after_oct); + parsing_should_fail(FILE_LINE_ARGS, integer_us_after_hex); // integer-us-after-hex - parsing_should_fail(FILE_LINE_ARGS, key_after_array); + parsing_should_fail(FILE_LINE_ARGS, integer_us_after_oct); // integer-us-after-oct - parsing_should_fail(FILE_LINE_ARGS, key_after_table); + parsing_should_fail(FILE_LINE_ARGS, key_after_array); // key-after-array - parsing_should_fail(FILE_LINE_ARGS, key_after_value); + parsing_should_fail(FILE_LINE_ARGS, key_after_table); // key-after-table - parsing_should_fail(FILE_LINE_ARGS, key_bare_invalid_character); + parsing_should_fail(FILE_LINE_ARGS, key_after_value); // key-after-value - parsing_should_fail(FILE_LINE_ARGS, key_dotted_redefine_table); + parsing_should_fail(FILE_LINE_ARGS, key_bare_invalid_character); // key-bare-invalid-character - parsing_should_fail(FILE_LINE_ARGS, key_duplicate); + parsing_should_fail(FILE_LINE_ARGS, key_dotted_redefine_table); // key-dotted-redefine-table - parsing_should_fail(FILE_LINE_ARGS, key_empty); + parsing_should_fail(FILE_LINE_ARGS, key_duplicate_keys); // key-duplicate-keys - parsing_should_fail(FILE_LINE_ARGS, key_escape); + parsing_should_fail(FILE_LINE_ARGS, key_duplicate); // key-duplicate - parsing_should_fail(FILE_LINE_ARGS, key_hash); + parsing_should_fail(FILE_LINE_ARGS, key_empty); // key-empty - parsing_should_fail(FILE_LINE_ARGS, key_multiline); + parsing_should_fail(FILE_LINE_ARGS, key_escape); // key-escape - parsing_should_fail(FILE_LINE_ARGS, key_newline); + parsing_should_fail(FILE_LINE_ARGS, key_hash); // key-hash - parsing_should_fail(FILE_LINE_ARGS, key_no_eol); + parsing_should_fail(FILE_LINE_ARGS, key_multiline); // key-multiline - parsing_should_fail(FILE_LINE_ARGS, key_open_bracket); + parsing_should_fail(FILE_LINE_ARGS, key_newline); // key-newline - parsing_should_fail(FILE_LINE_ARGS, key_partial_quoted); + parsing_should_fail(FILE_LINE_ARGS, key_no_eol); // key-no-eol - parsing_should_fail(FILE_LINE_ARGS, key_single_open_bracket); + parsing_should_fail(FILE_LINE_ARGS, key_open_bracket); // key-open-bracket - parsing_should_fail(FILE_LINE_ARGS, key_space); + parsing_should_fail(FILE_LINE_ARGS, key_partial_quoted); // key-partial-quoted - parsing_should_fail(FILE_LINE_ARGS, key_start_bracket); + parsing_should_fail(FILE_LINE_ARGS, key_single_open_bracket); // key-single-open-bracket - parsing_should_fail(FILE_LINE_ARGS, key_two_equals); + parsing_should_fail(FILE_LINE_ARGS, key_space); // key-space - parsing_should_fail(FILE_LINE_ARGS, key_two_equals2); + parsing_should_fail(FILE_LINE_ARGS, key_start_bracket); // key-start-bracket - parsing_should_fail(FILE_LINE_ARGS, key_two_equals3); + parsing_should_fail(FILE_LINE_ARGS, key_two_equals); // key-two-equals - parsing_should_fail(FILE_LINE_ARGS, key_without_value_1); + parsing_should_fail(FILE_LINE_ARGS, key_two_equals2); // key-two-equals2 - parsing_should_fail(FILE_LINE_ARGS, key_without_value_2); + 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 + + parsing_should_fail(FILE_LINE_ARGS, key_without_value_2); // key-without-value-2 #if !TOML_LANG_UNRELEASED && UNICODE_LITERALS_OK - parsing_should_fail(FILE_LINE_ARGS, 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, llbrace); + parsing_should_fail(FILE_LINE_ARGS, string_bad_byte_escape); // string-bad-byte-escape + + parsing_should_fail(FILE_LINE_ARGS, string_bad_codepoint); // string-bad-codepoint + + parsing_should_fail(FILE_LINE_ARGS, string_bad_concat); // string-bad-concat + + parsing_should_fail(FILE_LINE_ARGS, string_bad_escape); // string-bad-escape + + parsing_should_fail(FILE_LINE_ARGS, string_bad_multiline); // string-bad-multiline + + parsing_should_fail(FILE_LINE_ARGS, string_bad_slash_escape); // string-bad-slash-escape + + parsing_should_fail(FILE_LINE_ARGS, string_bad_uni_esc); // string-bad-uni-esc + + 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 + + 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 + + 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 + + parsing_should_fail(FILE_LINE_ARGS, string_basic_unknown_escape); // string-basic-unknown-escape + + parsing_should_fail(FILE_LINE_ARGS, string_literal_multiline_quotes_1); // string-literal-multiline-quotes-1 + + parsing_should_fail(FILE_LINE_ARGS, string_literal_multiline_quotes_2); // string-literal-multiline-quotes-2 + + parsing_should_fail(FILE_LINE_ARGS, string_missing_quotes); // string-missing-quotes + + parsing_should_fail(FILE_LINE_ARGS, string_multiline_escape_space); // string-multiline-escape-space + + parsing_should_fail(FILE_LINE_ARGS, string_multiline_no_close_2); // string-multiline-no-close-2 + + parsing_should_fail(FILE_LINE_ARGS, string_multiline_no_close); // string-multiline-no-close + + parsing_should_fail(FILE_LINE_ARGS, string_multiline_quotes_1); // string-multiline-quotes-1 + + parsing_should_fail(FILE_LINE_ARGS, string_multiline_quotes_2); // string-multiline-quotes-2 + + parsing_should_fail(FILE_LINE_ARGS, string_no_close); // string-no-close + + parsing_should_fail(FILE_LINE_ARGS, string_text_after_string); // string-text-after-string + + parsing_should_fail(FILE_LINE_ARGS, string_wrong_close); // string-wrong-close #if !TOML_LANG_UNRELEASED - parsing_should_fail(FILE_LINE_ARGS, multi_line_inline_table); + parsing_should_fail(FILE_LINE_ARGS, string_basic_byte_escapes); // string-basic-byte-escapes #endif // !TOML_LANG_UNRELEASED - parsing_should_fail(FILE_LINE_ARGS, multi_line_string_no_close_2); + parsing_should_fail(FILE_LINE_ARGS, table_array_empty); // table-array-empty - parsing_should_fail(FILE_LINE_ARGS, multi_line_string_no_close); + parsing_should_fail(FILE_LINE_ARGS, table_array_implicit); // table-array-implicit - parsing_should_fail(FILE_LINE_ARGS, rrbrace); + parsing_should_fail(FILE_LINE_ARGS, table_array_missing_bracket); // table-array-missing-bracket - parsing_should_fail(FILE_LINE_ARGS, string_bad_byte_escape); + parsing_should_fail(FILE_LINE_ARGS, table_duplicate_key_table); // table-duplicate-key-table - parsing_should_fail(FILE_LINE_ARGS, string_bad_codepoint); + parsing_should_fail(FILE_LINE_ARGS, table_duplicate_table_array); // table-duplicate-table-array - parsing_should_fail(FILE_LINE_ARGS, string_bad_concat); + parsing_should_fail(FILE_LINE_ARGS, table_duplicate_table_array2); // table-duplicate-table-array2 - parsing_should_fail(FILE_LINE_ARGS, string_bad_escape); + parsing_should_fail(FILE_LINE_ARGS, table_duplicate); // table-duplicate - parsing_should_fail(FILE_LINE_ARGS, string_bad_multiline); + parsing_should_fail(FILE_LINE_ARGS, table_empty_implicit_table); // table-empty-implicit-table - parsing_should_fail(FILE_LINE_ARGS, string_bad_slash_escape); + parsing_should_fail(FILE_LINE_ARGS, table_empty); // table-empty - parsing_should_fail(FILE_LINE_ARGS, string_bad_uni_esc); + parsing_should_fail(FILE_LINE_ARGS, table_equals_sign); // table-equals-sign - parsing_should_fail(FILE_LINE_ARGS, string_basic_multiline_out_of_range_unicode_escape_1); + parsing_should_fail(FILE_LINE_ARGS, table_llbrace); // table-llbrace - parsing_should_fail(FILE_LINE_ARGS, string_basic_multiline_out_of_range_unicode_escape_2); + parsing_should_fail(FILE_LINE_ARGS, table_nested_brackets_close); // table-nested-brackets-close - parsing_should_fail(FILE_LINE_ARGS, string_basic_multiline_quotes); + parsing_should_fail(FILE_LINE_ARGS, table_nested_brackets_open); // table-nested-brackets-open - parsing_should_fail(FILE_LINE_ARGS, string_basic_multiline_unknown_escape); + parsing_should_fail(FILE_LINE_ARGS, table_quoted_no_close); // table-quoted-no-close - parsing_should_fail(FILE_LINE_ARGS, string_basic_out_of_range_unicode_escape_1); + parsing_should_fail(FILE_LINE_ARGS, table_redefine); // table-redefine - parsing_should_fail(FILE_LINE_ARGS, string_basic_out_of_range_unicode_escape_2); + parsing_should_fail(FILE_LINE_ARGS, table_rrbrace); // table-rrbrace - parsing_should_fail(FILE_LINE_ARGS, string_basic_unknown_escape); + parsing_should_fail(FILE_LINE_ARGS, table_text_after_table); // table-text-after-table - parsing_should_fail(FILE_LINE_ARGS, string_literal_multiline_quotes_1); + parsing_should_fail(FILE_LINE_ARGS, table_whitespace); // table-whitespace - parsing_should_fail(FILE_LINE_ARGS, string_literal_multiline_quotes_2); - - parsing_should_fail(FILE_LINE_ARGS, string_missing_quotes); - - parsing_should_fail(FILE_LINE_ARGS, string_multiline_escape_space); - - parsing_should_fail(FILE_LINE_ARGS, string_multiline_quotes_1); - - parsing_should_fail(FILE_LINE_ARGS, string_multiline_quotes_2); - - parsing_should_fail(FILE_LINE_ARGS, string_no_close); - - parsing_should_fail(FILE_LINE_ARGS, string_wrong_close); - -#if !TOML_LANG_UNRELEASED - - parsing_should_fail(FILE_LINE_ARGS, string_basic_byte_escapes); - -#endif // !TOML_LANG_UNRELEASED - - parsing_should_fail(FILE_LINE_ARGS, table_array_empty); - - parsing_should_fail(FILE_LINE_ARGS, table_array_implicit); - - parsing_should_fail(FILE_LINE_ARGS, table_array_missing_bracket); - - parsing_should_fail(FILE_LINE_ARGS, table_duplicate); - - parsing_should_fail(FILE_LINE_ARGS, table_empty); - - parsing_should_fail(FILE_LINE_ARGS, table_equals_sign); - - parsing_should_fail(FILE_LINE_ARGS, table_nested_brackets_close); - - parsing_should_fail(FILE_LINE_ARGS, table_nested_brackets_open); - - parsing_should_fail(FILE_LINE_ARGS, table_quoted_no_close); - - parsing_should_fail(FILE_LINE_ARGS, table_redefine); - - parsing_should_fail(FILE_LINE_ARGS, table_whitespace); - - parsing_should_fail(FILE_LINE_ARGS, table_with_pound); - - parsing_should_fail(FILE_LINE_ARGS, text_after_array_entries); - - parsing_should_fail(FILE_LINE_ARGS, text_after_integer); - - parsing_should_fail(FILE_LINE_ARGS, text_after_string); - - parsing_should_fail(FILE_LINE_ARGS, text_after_table); - - parsing_should_fail(FILE_LINE_ARGS, text_before_array_separator); - - parsing_should_fail(FILE_LINE_ARGS, text_in_array); + 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 65d2e44..d94c421 100644 --- a/tests/conformance_burntsushi_valid.cpp +++ b/tests/conformance_burntsushi_valid.cpp @@ -12,6 +12,18 @@ TOML_DISABLE_WARNINGS; // unused variable spam namespace { + static constexpr auto array_array = R"(ints = [1, 2, 3, ] +floats = [1.1, 2.1, 3.1] +strings = ["a", "b", "c"] +dates = [ + 1987-07-05T17:45:00Z, + 1979-05-27T07:32:00Z, + 2006-06-01T11:00:00Z, +] +comments = [ + 1, + 2, #this is ok +])"sv; static constexpr auto array_bool = R"(a = [true, false])"sv; static constexpr auto array_empty = R"(thevoid = [[[[[]]]]])"sv; static constexpr auto array_hetergeneous = R"(mixed = [[1, 2], ["a", "b"], [1.1, 2.1]])"sv; @@ -42,20 +54,8 @@ namespace ])"sv; static constexpr auto array_strings = R"(string_array = [ "all", 'strings', """are the same""", '''type'''])"sv; static constexpr auto array_table_array_string_backslash = R"(foo = [ { bar="\"{{baz}}\""} ])"sv; - static constexpr auto array_ = R"(ints = [1, 2, 3, ] -floats = [1.1, 2.1, 3.1] -strings = ["a", "b", "c"] -dates = [ - 1987-07-05T17:45:00Z, - 1979-05-27T07:32:00Z, - 2006-06-01T11:00:00Z, -] -comments = [ - 1, - 2, #this is ok -])"sv; - static constexpr auto bool_ = R"(t = true + static constexpr auto bool_bool = R"(t = true f = false)"sv; static constexpr auto comment_at_eof = R"(# This is a full-line comment @@ -85,7 +85,10 @@ more = [ # Comment # Evil. # Evil. # ] Did I fool you? -] # Hopefully not.)"sv; +] # Hopefully not. + +# Make sure the space between the datetime and "#" isn't lexed. +d = 1979-05-27T07:32:12-07:00 # c)"sv; static constexpr auto comment_tricky = R"([section]#attached comment #[notsection] one = "11"#cmt @@ -116,17 +119,22 @@ arr5 = [[[[#["#"], ] tbl1 = { "#" = '}#'}#}})"sv; + 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; static constexpr auto datetime_local_time = R"(besttimeever = 17:45:00 milliseconds = 10:32:00.555)"sv; - static constexpr auto datetime_local = R"(bestdayever = 1987-07-05T17:45:00 -milliseconds = 1977-12-21T10:32:00.555 -bestdayever_with_space = 1987-07-05 17:45:00)"sv; - static constexpr auto datetime_timezone = R"(bestdayever = 2017-06-06T12:34:56-05:00)"sv; - static constexpr auto datetime = R"(bestdayever = 1987-07-05T17:45:00Z -numoffset = 1977-06-28T07:32:00-05:00 -milliseconds = 1977-12-21T10:32:00.555+07:00 -bestdayever_with_space = 1987-07-05 17:45:00Z)"sv; + static constexpr auto datetime_local = R"(local = 1987-07-05T17:45:00 +milli = 1977-12-21T10:32:00.555 +space = 1987-07-05 17:45:00)"sv; + static constexpr auto datetime_milliseconds = R"(utc1 = 1987-07-05T17:45:56.123456Z +utc2 = 1987-07-05T17:45:56.6Z +wita1 = 1987-07-05T17:45:56.123456+08:00 +wita2 = 1987-07-05T17:45:56.6+08:00)"sv; + static constexpr auto datetime_timezone = R"(utc = 1987-07-05T17:45:56Z +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; static constexpr auto empty_file = R"()"sv; @@ -144,6 +152,10 @@ zero = 3e0 pointlower = 3.1e2 pointupper = 3.1E2 minustenth = -1E-1)"sv; + static constexpr auto float_float = R"(pi = 3.14 +pospi = +3.14 +negpi = -3.14 +zero-intpart = 0.123)"sv; static constexpr auto float_inf_and_nan = R"(# We don't encode +nan and -nan back with the signs; many languages don't # support a sign on NaN (it doesn't really make much sense). nan = nan @@ -164,10 +176,6 @@ f4 = 0e0 f5 = 0e00 f6 = +0e0 f7 = -0e0)"sv; - static constexpr auto float_ = R"(pi = 3.14 -pospi = +3.14 -negpi = -3.14 -zero-intpart = 0.123)"sv; static constexpr auto implicit_and_explicit_after = R"([a.b.c] answer = 42 @@ -193,6 +201,11 @@ empty_in_array2 = [{},{not_empty=1}] many_empty = [{},{},{}] nested_empty = {"empty"={}})"sv; static constexpr auto inline_table_end_in_bool = R"(black = { python=">3.6", version=">=18.9b0", allow_prereleases=true })"sv; + static constexpr auto inline_table_inline_table = R"(name = { first = "Tom", last = "Preston-Werner" } +point = { x = 1, y = 2 } +simple = { a = 1 } +str-key = { "a" = 1 } +table-array = [{ "a" = 1 }, { "b" = 2 }])"sv; static constexpr auto inline_table_multiline = R"(tbl_multiline = { a = 1, b = """ multiline """, c = """and yet @@ -207,12 +220,39 @@ arr_tbl_tbl = [ { tbl = { one = 1 } } ] arr_arr_tbl_empty = [ [ {} ] ] arr_arr_tbl_val = [ [ { one = 1 } ] ] arr_arr_tbls = [ [ { one = 1 }, { two = 2 } ] ])"sv; - static constexpr auto inline_table = R"(name = { first = "Tom", last = "Preston-Werner" } -point = { x = 1, y = 2 } -simple = { a = 1 } -str-key = { "a" = 1 } -table-array = [{ "a" = 1 }, { "b" = 2 }])"sv; +#if !TOML_MSVC + + static constexpr auto inline_table_key_dotted = R"(inline = {a.b = 42} + +many.dots.here.dot.dot.dot = {a.b.c = 1, a.b.d = 2} + +a = { a.b = 1 } +b = { "a"."b" = 1 } +c = { a . b = 1 } +d = { 'a' . "b" = 1 } +e = {a.b=1} + +[tbl] +a.b.c = {d.e=1} + +[tbl.x] +a.b.c = {d.e=1} + +[[arr]] +t = {a.b=1} +T = {a.b=1} + +[[arr]] +t = {a.b=2} +T = {a.b=2})"sv; + +#endif // !TOML_MSVC + + static constexpr auto integer_integer = R"(answer = 42 +posanswer = +42 +neganswer = -42 +zero = 0)"sv; static constexpr auto integer_literals = R"(bin1 = 0b11010110 bin2 = 0b1_0_1 @@ -243,10 +283,6 @@ a3 = 0o00000 b1 = 0b0 b2 = 0b00 b3 = 0b00000)"sv; - static constexpr auto integer = R"(answer = 42 -posanswer = +42 -neganswer = -42 -zero = 0)"sv; #if UNICODE_LITERALS_OK @@ -312,6 +348,7 @@ a.b.c=3 a.b.d=4)"sv; static constexpr auto key_empty = R"("" = "blank")"sv; static constexpr auto key_equals_nospace = R"(answer=42)"sv; + static constexpr auto key_numeric_dotted = R"(1.2 = 3)"sv; static constexpr auto key_numeric = R"(1 = 1)"sv; static constexpr auto key_quoted_dots = R"(plain = 1 "with.dot" = 2 @@ -330,44 +367,11 @@ true = 1 inf = 100000000 nan = "ceci n'est pas un nombre")"sv; - static constexpr auto multiline_string_quotes = R"(# Make sure that quotes inside multiline strings are allowed, including right -# after the opening '''/""" and before the closing '''/""" - -lit_one = ''''one quote'''' -lit_two = '''''two quotes''''' -lit_one_space = ''' 'one quote' ''' -lit_two_space = ''' ''two quotes'' ''' - -one = """"one quote"""" -two = """""two quotes""""" -one_space = """ "one quote" """ -two_space = """ ""two quotes"" """ - -mismatch1 = """aaa'''bbb""" -mismatch2 = '''aaa"""bbb''')"sv; - static constexpr auto newline_crlf = R"(os = "DOS" newline = "crlf")"sv; static constexpr auto newline_lf = R"(os = "unix" newline = "lf")"sv; - static constexpr auto raw_multiline_string = R"(oneline = '''This string has a ' quote character.''' -firstnl = ''' -This string has a ' quote character.''' -multiline = ''' -This string -has ' a quote character -and more than -one newline -in it.''')"sv; - static constexpr auto raw_string = R"(backspace = 'This string has a \b backspace character.' -tab = 'This string has a \t 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.' -slash = 'This string has a \/ slash character.' -backslash = 'This string has a \\ backslash character.')"sv; - static constexpr auto spec_example_1_compact = R"(#Useless spaces eliminated. title="TOML Example" [owner] @@ -428,12 +432,43 @@ hosts = [ 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; + static constexpr auto string_multiline_quotes = R"(# Make sure that quotes inside multiline strings are allowed, including right +# after the opening '''/""" and before the closing '''/""" + +lit_one = ''''one quote'''' +lit_two = '''''two quotes''''' +lit_one_space = ''' 'one quote' ''' +lit_two_space = ''' ''two quotes'' ''' + +one = """"one quote"""" +two = """""two quotes""""" +one_space = """ "one quote" """ +two_space = """ ""two quotes"" """ + +mismatch1 = """aaa'''bbb""" +mismatch2 = '''aaa"""bbb''')"sv; static constexpr auto string_nl = R"(nl_mid = "val\nue" nl_end = """value\n""" lit_nl_end = '''value\n''' lit_nl_mid = 'val\nue' lit_nl_uni = 'val\ue')"sv; + static constexpr auto string_raw_multiline = R"(oneline = '''This string has a ' quote character.''' +firstnl = ''' +This string has a ' quote character.''' +multiline = ''' +This string +has ' a quote character +and more than +one newline +in it.''')"sv; + static constexpr auto string_raw = R"(backspace = 'This string has a \b backspace character.' +tab = 'This string has a \t 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.' +slash = 'This string has a \/ slash character.' +backslash = 'This string has a \\ backslash character.')"sv; static constexpr auto string_simple = R"(answer = "You are not drinking enough whisky.")"sv; static constexpr auto string_with_pound = R"(pound = "We see no # comments here." poundcomment = "But there are # some comments here." # Did I # mess you up?)"sv; @@ -502,6 +537,13 @@ last_name = "Springsteen")"sv; [a.b.c] d = "val1")"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] [a.b])"sv; @@ -530,7 +572,9 @@ answer = 42)"sv; [a.' x '] [ d.e.f ] [ g . h . i ] -[ j . "ʞ" . 'l' ])"sv; +[ j . "ʞ" . 'l' ] + +[x.1.2])"sv; #endif // UNICODE_LITERALS_OK } @@ -539,254 +583,7 @@ TOML_ENABLE_WARNINGS; TEST_CASE("conformance - burntsushi/valid") { - parsing_should_succeed(FILE_LINE_ARGS, array_bool, [](toml::table&& tbl) - { - 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) - { - 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) - { - 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_mixed_int_array, [](toml::table&& tbl) - { - const auto expected = toml::table{{ - { - R"(arrays-and-ints)"sv, toml::array{ - 1, - toml::array{ - R"(Arrays are not integers.)"sv, - }, - } - }, - }}; - REQUIRE(tbl == expected); - }); - - parsing_should_succeed(FILE_LINE_ARGS, array_mixed_int_float, [](toml::table&& tbl) - { - const auto expected = toml::table{{ - { - R"(ints-and-floats)"sv, toml::array{ - 1, - 1.1, - } - }, - }}; - REQUIRE(tbl == expected); - }); - - parsing_should_succeed(FILE_LINE_ARGS, array_mixed_int_string, [](toml::table&& tbl) - { - const auto expected = toml::table{{ - { - R"(strings-and-ints)"sv, toml::array{ - R"(hi)"sv, - 42, - } - }, - }}; - REQUIRE(tbl == expected); - }); - - parsing_should_succeed(FILE_LINE_ARGS, array_mixed_string_table, [](toml::table&& tbl) - { - 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 }, - }}, - } - }, - }}; - REQUIRE(tbl == expected); - }); - - parsing_should_succeed(FILE_LINE_ARGS, array_nested_double, [](toml::table&& tbl) - { - 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); - }); - - parsing_should_succeed(FILE_LINE_ARGS, array_nested_inline_table, [](toml::table&& tbl) - { - 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) - { - const auto expected = toml::table{{ - { - R"(nest)"sv, toml::array{ - toml::array{ - R"(a)"sv, - }, - toml::array{ - R"(b)"sv, - }, - } - }, - }}; - REQUIRE(tbl == expected); - }); - - parsing_should_succeed(FILE_LINE_ARGS, array_nospaces, [](toml::table&& tbl) - { - const auto expected = toml::table{{ - { - R"(ints)"sv, toml::array{ - 1, - 2, - 3, - } - }, - }}; - REQUIRE(tbl == expected); - }); - - parsing_should_succeed(FILE_LINE_ARGS, array_string_quote_comma_2, [](toml::table&& tbl) - { - const auto expected = toml::table{{ - { - R"(title)"sv, toml::array{ - R"( ", )"sv, - } - }, - }}; - REQUIRE(tbl == expected); - }); - - parsing_should_succeed(FILE_LINE_ARGS, array_string_quote_comma, [](toml::table&& tbl) - { - 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_with_comma, [](toml::table&& tbl) - { - 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_strings, [](toml::table&& tbl) - { - 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_table_array_string_backslash, [](toml::table&& tbl) - { - 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_, [](toml::table&& tbl) + parsing_should_succeed(FILE_LINE_ARGS, array_array, [](toml::table&& tbl) // array-array { const auto expected = toml::table{{ { @@ -827,7 +624,254 @@ TEST_CASE("conformance - burntsushi/valid") REQUIRE(tbl == expected); }); - parsing_should_succeed(FILE_LINE_ARGS, bool_, [](toml::table&& tbl) + 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{ + 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_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); + }); + + 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); + }); + + 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); + }); + + 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 }, + }}, + } + }, + }}; + 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{ + toml::array{ + R"(a)"sv, + }, + toml::array{ + 1, + 2, + toml::array{ + 3, + }, + }, + }}, + } + }, + }}; + 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{ + toml::array{ + R"(a)"sv, + }, + toml::array{ + R"(b)"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); + }); + + 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); + }); + + 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_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_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_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, bool_bool, [](toml::table&& tbl) // bool-bool { const auto expected = toml::table{{ { R"(f)"sv, false }, @@ -836,7 +880,7 @@ TEST_CASE("conformance - burntsushi/valid") REQUIRE(tbl == expected); }); - parsing_should_succeed(FILE_LINE_ARGS, comment_at_eof, [](toml::table&& tbl) + 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 }, @@ -844,7 +888,7 @@ TEST_CASE("conformance - burntsushi/valid") REQUIRE(tbl == expected); }); - parsing_should_succeed(FILE_LINE_ARGS, comment_at_eof2, [](toml::table&& tbl) + 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 }, @@ -852,12 +896,13 @@ TEST_CASE("conformance - burntsushi/valid") REQUIRE(tbl == expected); }); - parsing_should_succeed(FILE_LINE_ARGS, comment_everywhere, [](toml::table&& tbl) + 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"(d)"sv, toml::date_time{ { 1979, 5, 27 }, { 7, 32, 12, 0u }, { -7, 0 } } }, { R"(more)"sv, toml::array{ 42, @@ -870,7 +915,7 @@ TEST_CASE("conformance - burntsushi/valid") REQUIRE(tbl == expected); }); - parsing_should_succeed(FILE_LINE_ARGS, comment_tricky, [](toml::table&& tbl) + parsing_should_succeed(FILE_LINE_ARGS, comment_tricky, [](toml::table&& tbl) // comment-tricky { const auto expected = toml::table{{ { @@ -930,7 +975,16 @@ TEST_CASE("conformance - burntsushi/valid") REQUIRE(tbl == expected); }); - parsing_should_succeed(FILE_LINE_ARGS, datetime_local_date, [](toml::table&& tbl) + 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, 0u }, { 0, 0 } } }, + { R"(space)"sv, toml::date_time{ { 1987, 7, 5 }, { 17, 45, 0, 0u }, { 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 } }, @@ -938,7 +992,7 @@ TEST_CASE("conformance - burntsushi/valid") REQUIRE(tbl == expected); }); - parsing_should_succeed(FILE_LINE_ARGS, datetime_local_time, [](toml::table&& tbl) + 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, 0, 0 } }, @@ -947,42 +1001,45 @@ TEST_CASE("conformance - burntsushi/valid") REQUIRE(tbl == expected); }); - parsing_should_succeed(FILE_LINE_ARGS, datetime_local, [](toml::table&& tbl) + parsing_should_succeed(FILE_LINE_ARGS, datetime_local, [](toml::table&& tbl) // datetime-local { const auto expected = toml::table{{ - { R"(bestdayever)"sv, toml::date_time{ { 1987, 7, 5 }, { 17, 45, 0, 0u } } }, - { R"(bestdayever_with_space)"sv, toml::date_time{ { 1987, 7, 5 }, { 17, 45, 0, 0u } } }, - { R"(milliseconds)"sv, toml::date_time{ { 1977, 12, 21 }, { 10, 32, 0, 555000000u } } }, + { R"(local)"sv, toml::date_time{ { 1987, 7, 5 }, { 17, 45, 0, 0u } } }, + { R"(milli)"sv, toml::date_time{ { 1977, 12, 21 }, { 10, 32, 0, 555000000u } } }, + { R"(space)"sv, toml::date_time{ { 1987, 7, 5 }, { 17, 45, 0, 0u } } }, }}; REQUIRE(tbl == expected); }); - parsing_should_succeed(FILE_LINE_ARGS, datetime_timezone, [](toml::table&& tbl) + parsing_should_succeed(FILE_LINE_ARGS, datetime_milliseconds, [](toml::table&& tbl) // datetime-milliseconds { const auto expected = toml::table{{ - { R"(bestdayever)"sv, toml::date_time{ { 2017, 6, 6 }, { 12, 34, 56, 0u }, { -5, 0 } } }, + { R"(utc1)"sv, toml::date_time{ { 1987, 7, 5 }, { 17, 45, 56, 123456000u }, { 0, 0 } } }, + { R"(utc2)"sv, toml::date_time{ { 1987, 7, 5 }, { 17, 45, 56, 600000000u }, { 0, 0 } } }, + { R"(wita1)"sv, toml::date_time{ { 1987, 7, 5 }, { 17, 45, 56, 123456000u }, { 8, 0 } } }, + { R"(wita2)"sv, toml::date_time{ { 1987, 7, 5 }, { 17, 45, 56, 600000000u }, { 8, 0 } } }, }}; REQUIRE(tbl == expected); }); - parsing_should_succeed(FILE_LINE_ARGS, datetime, [](toml::table&& tbl) + parsing_should_succeed(FILE_LINE_ARGS, datetime_timezone, [](toml::table&& tbl) // datetime-timezone { const auto expected = toml::table{{ - { R"(bestdayever)"sv, toml::date_time{ { 1987, 7, 5 }, { 17, 45, 0, 0u }, { 0, 0 } } }, - { R"(bestdayever_with_space)"sv, toml::date_time{ { 1987, 7, 5 }, { 17, 45, 0, 0u }, { 0, 0 } } }, - { R"(milliseconds)"sv, toml::date_time{ { 1977, 12, 21 }, { 10, 32, 0, 555000000u }, { 7, 0 } } }, - { R"(numoffset)"sv, toml::date_time{ { 1977, 6, 28 }, { 7, 32, 0, 0u }, { -5, 0 } } }, + { R"(nzdt)"sv, toml::date_time{ { 1987, 7, 5 }, { 17, 45, 56, 0u }, { 13, 0 } } }, + { R"(nzst)"sv, toml::date_time{ { 1987, 7, 5 }, { 17, 45, 56, 0u }, { 12, 0 } } }, + { R"(pdt)"sv, toml::date_time{ { 1987, 7, 5 }, { 17, 45, 56, 0u }, { -5, 0 } } }, + { R"(utc)"sv, toml::date_time{ { 1987, 7, 5 }, { 17, 45, 56, 0u }, { 0, 0 } } }, }}; REQUIRE(tbl == expected); }); - parsing_should_succeed(FILE_LINE_ARGS, empty_file, [](toml::table&& tbl) + 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) + 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, 0u }, { 0, 0 } } }, @@ -1002,7 +1059,7 @@ TEST_CASE("conformance - burntsushi/valid") REQUIRE(tbl == expected); }); - parsing_should_succeed(FILE_LINE_ARGS, float_exponent, [](toml::table&& tbl) + parsing_should_succeed(FILE_LINE_ARGS, float_exponent, [](toml::table&& tbl) // float-exponent { const auto expected = toml::table{{ { R"(lower)"sv, 300.0 }, @@ -1017,7 +1074,18 @@ TEST_CASE("conformance - burntsushi/valid") REQUIRE(tbl == expected); }); - parsing_should_succeed(FILE_LINE_ARGS, float_inf_and_nan, [](toml::table&& tbl) + 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() }, @@ -1030,7 +1098,7 @@ TEST_CASE("conformance - burntsushi/valid") REQUIRE(tbl == expected); }); - parsing_should_succeed(FILE_LINE_ARGS, float_long, [](toml::table&& tbl) + parsing_should_succeed(FILE_LINE_ARGS, float_long, [](toml::table&& tbl) // float-long { const auto expected = toml::table{{ { R"(longpi)"sv, 3.141592653589793 }, @@ -1039,7 +1107,7 @@ TEST_CASE("conformance - burntsushi/valid") REQUIRE(tbl == expected); }); - parsing_should_succeed(FILE_LINE_ARGS, float_underscore, [](toml::table&& tbl) + parsing_should_succeed(FILE_LINE_ARGS, float_underscore, [](toml::table&& tbl) // float-underscore { const auto expected = toml::table{{ { R"(after)"sv, 3141.5927 }, @@ -1049,7 +1117,7 @@ TEST_CASE("conformance - burntsushi/valid") REQUIRE(tbl == expected); }); - parsing_should_succeed(FILE_LINE_ARGS, float_zero, [](toml::table&& tbl) + parsing_should_succeed(FILE_LINE_ARGS, float_zero, [](toml::table&& tbl) // float-zero { const auto expected = toml::table{{ { R"(f1)"sv, 0.0 }, @@ -1063,18 +1131,7 @@ TEST_CASE("conformance - burntsushi/valid") REQUIRE(tbl == expected); }); - parsing_should_succeed(FILE_LINE_ARGS, float_, [](toml::table&& tbl) - { - 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, implicit_and_explicit_after, [](toml::table&& tbl) + parsing_should_succeed(FILE_LINE_ARGS, implicit_and_explicit_after, [](toml::table&& tbl) // implicit-and-explicit-after { const auto expected = toml::table{{ { @@ -1095,7 +1152,7 @@ TEST_CASE("conformance - burntsushi/valid") REQUIRE(tbl == expected); }); - parsing_should_succeed(FILE_LINE_ARGS, implicit_and_explicit_before, [](toml::table&& tbl) + parsing_should_succeed(FILE_LINE_ARGS, implicit_and_explicit_before, [](toml::table&& tbl) // implicit-and-explicit-before { const auto expected = toml::table{{ { @@ -1116,7 +1173,7 @@ TEST_CASE("conformance - burntsushi/valid") REQUIRE(tbl == expected); }); - parsing_should_succeed(FILE_LINE_ARGS, implicit_groups, [](toml::table&& tbl) + parsing_should_succeed(FILE_LINE_ARGS, implicit_groups, [](toml::table&& tbl) // implicit-groups { const auto expected = toml::table{{ { @@ -1136,7 +1193,7 @@ TEST_CASE("conformance - burntsushi/valid") REQUIRE(tbl == expected); }); - parsing_should_succeed(FILE_LINE_ARGS, inline_table_array, [](toml::table&& tbl) + parsing_should_succeed(FILE_LINE_ARGS, inline_table_array, [](toml::table&& tbl) // inline-table-array { const auto expected = toml::table{{ { @@ -1159,7 +1216,7 @@ TEST_CASE("conformance - burntsushi/valid") REQUIRE(tbl == expected); }); - parsing_should_succeed(FILE_LINE_ARGS, inline_table_bool, [](toml::table&& tbl) + parsing_should_succeed(FILE_LINE_ARGS, inline_table_bool, [](toml::table&& tbl) // inline-table-bool { const auto expected = toml::table{{ { @@ -1172,7 +1229,7 @@ TEST_CASE("conformance - burntsushi/valid") REQUIRE(tbl == expected); }); - parsing_should_succeed(FILE_LINE_ARGS, inline_table_empty, [](toml::table&& tbl) + 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{} }, @@ -1209,7 +1266,7 @@ TEST_CASE("conformance - burntsushi/valid") REQUIRE(tbl == expected); }); - parsing_should_succeed(FILE_LINE_ARGS, inline_table_end_in_bool, [](toml::table&& tbl) + parsing_should_succeed(FILE_LINE_ARGS, inline_table_end_in_bool, [](toml::table&& tbl) // inline-table-end-in-bool { const auto expected = toml::table{{ { @@ -1223,7 +1280,46 @@ TEST_CASE("conformance - burntsushi/valid") REQUIRE(tbl == expected); }); - parsing_should_succeed(FILE_LINE_ARGS, inline_table_multiline, [](toml::table&& tbl) + 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{{ { @@ -1240,7 +1336,7 @@ another line)"sv }, REQUIRE(tbl == expected); }); - parsing_should_succeed(FILE_LINE_ARGS, inline_table_nest, [](toml::table&& tbl) + parsing_should_succeed(FILE_LINE_ARGS, inline_table_nest, [](toml::table&& tbl) // inline-table-nest { const auto expected = toml::table{{ { @@ -1311,46 +1407,203 @@ another line)"sv }, REQUIRE(tbl == expected); }); - parsing_should_succeed(FILE_LINE_ARGS, inline_table, [](toml::table&& tbl) +#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"(name)"sv, toml::table{{ - { R"(first)"sv, R"(Tom)"sv }, - { R"(last)"sv, R"(Preston-Werner)"sv }, + R"(a)"sv, toml::table{{ + { + R"(a)"sv, toml::table{{ + { R"(b)"sv, 1 }, + }} + }, }} }, { - 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{ + R"(arr)"sv, toml::array{ toml::table{{ - { R"(a)"sv, 1 }, + { + 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"(b)"sv, 2 }, + { + 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); }); - parsing_should_succeed(FILE_LINE_ARGS, integer_literals, [](toml::table&& tbl) +#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 }, @@ -1366,7 +1619,7 @@ another line)"sv }, REQUIRE(tbl == expected); }); - parsing_should_succeed(FILE_LINE_ARGS, integer_long, [](toml::table&& tbl) + parsing_should_succeed(FILE_LINE_ARGS, integer_long, [](toml::table&& tbl) // integer-long { const auto expected = toml::table{{ { R"(int64-max)"sv, INT64_MAX }, @@ -1375,7 +1628,7 @@ another line)"sv }, REQUIRE(tbl == expected); }); - parsing_should_succeed(FILE_LINE_ARGS, integer_underscore, [](toml::table&& tbl) + parsing_should_succeed(FILE_LINE_ARGS, integer_underscore, [](toml::table&& tbl) // integer-underscore { const auto expected = toml::table{{ { R"(kilo)"sv, 1000 }, @@ -1384,7 +1637,7 @@ another line)"sv }, REQUIRE(tbl == expected); }); - parsing_should_succeed(FILE_LINE_ARGS, integer_zero, [](toml::table&& tbl) + parsing_should_succeed(FILE_LINE_ARGS, integer_zero, [](toml::table&& tbl) // integer-zero { const auto expected = toml::table{{ { R"(a2)"sv, 0 }, @@ -1403,20 +1656,9 @@ another line)"sv }, REQUIRE(tbl == expected); }); - parsing_should_succeed(FILE_LINE_ARGS, integer, [](toml::table&& tbl) - { - const auto expected = toml::table{{ - { R"(answer)"sv, 42 }, - { R"(neganswer)"sv, -42 }, - { R"(posanswer)"sv, 42 }, - { R"(zero)"sv, 0 }, - }}; - REQUIRE(tbl == expected); - }); - #if UNICODE_LITERALS_OK - parsing_should_succeed(FILE_LINE_ARGS, key_case_sensitive, [](toml::table&& tbl) + parsing_should_succeed(FILE_LINE_ARGS, key_case_sensitive, [](toml::table&& tbl) // key-case-sensitive { const auto expected = toml::table{{ { @@ -1439,7 +1681,7 @@ another line)"sv }, REQUIRE(tbl == expected); }); - parsing_should_succeed(FILE_LINE_ARGS, key_escapes, [](toml::table&& tbl) + parsing_should_succeed(FILE_LINE_ARGS, key_escapes, [](toml::table&& tbl) // key-escapes { const auto expected = toml::table{{ { R"( @@ -1463,7 +1705,7 @@ another line)"sv }, #endif // UNICODE_LITERALS_OK - parsing_should_succeed(FILE_LINE_ARGS, key_dotted, [](toml::table&& tbl) + parsing_should_succeed(FILE_LINE_ARGS, key_dotted, [](toml::table&& tbl) // key-dotted { const auto expected = toml::table{{ { @@ -1572,7 +1814,7 @@ another line)"sv }, REQUIRE(tbl == expected); }); - parsing_should_succeed(FILE_LINE_ARGS, key_empty, [](toml::table&& tbl) + parsing_should_succeed(FILE_LINE_ARGS, key_empty, [](toml::table&& tbl) // key-empty { const auto expected = toml::table{{ { R"()"sv, R"(blank)"sv }, @@ -1580,7 +1822,7 @@ another line)"sv }, REQUIRE(tbl == expected); }); - parsing_should_succeed(FILE_LINE_ARGS, key_equals_nospace, [](toml::table&& tbl) + parsing_should_succeed(FILE_LINE_ARGS, key_equals_nospace, [](toml::table&& tbl) // key-equals-nospace { const auto expected = toml::table{{ { R"(answer)"sv, 42 }, @@ -1588,7 +1830,19 @@ another line)"sv }, REQUIRE(tbl == expected); }); - parsing_should_succeed(FILE_LINE_ARGS, key_numeric, [](toml::table&& tbl) + 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); + }); + + parsing_should_succeed(FILE_LINE_ARGS, key_numeric, [](toml::table&& tbl) // key-numeric { const auto expected = toml::table{{ { R"(1)"sv, 1 }, @@ -1596,7 +1850,7 @@ another line)"sv }, REQUIRE(tbl == expected); }); - parsing_should_succeed(FILE_LINE_ARGS, key_quoted_dots, [](toml::table&& tbl) + parsing_should_succeed(FILE_LINE_ARGS, key_quoted_dots, [](toml::table&& tbl) // key-quoted-dots { const auto expected = toml::table{{ { R"(plain)"sv, 1 }, @@ -1621,7 +1875,7 @@ another line)"sv }, REQUIRE(tbl == expected); }); - parsing_should_succeed(FILE_LINE_ARGS, key_space, [](toml::table&& tbl) + parsing_should_succeed(FILE_LINE_ARGS, key_space, [](toml::table&& tbl) // key-space { const auto expected = toml::table{{ { R"(a b)"sv, 1 }, @@ -1629,7 +1883,7 @@ another line)"sv }, REQUIRE(tbl == expected); }); - parsing_should_succeed(FILE_LINE_ARGS, key_special_chars, [](toml::table&& tbl) + parsing_should_succeed(FILE_LINE_ARGS, key_special_chars, [](toml::table&& tbl) // key-special-chars { const auto expected = toml::table{{ { R"(~!@$^&*()_+-`1234567890[]|/?><.,;:')"sv, 1 }, @@ -1637,7 +1891,7 @@ another line)"sv }, REQUIRE(tbl == expected); }); - parsing_should_succeed(FILE_LINE_ARGS, key_special_word, [](toml::table&& tbl) + parsing_should_succeed(FILE_LINE_ARGS, key_special_word, [](toml::table&& tbl) // key-special-word { const auto expected = toml::table{{ { R"(false)"sv, false }, @@ -1648,7 +1902,181 @@ another line)"sv }, REQUIRE(tbl == expected); }); - parsing_should_succeed(FILE_LINE_ARGS, multiline_string_quotes, [](toml::table&& tbl) + 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, 0, 0u }, { -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, 0, 0u }, { -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, R"()"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_multiline_quotes, [](toml::table&& tbl) // string-multiline-quotes { const auto expected = toml::table{{ { R"(lit_one)"sv, R"('one quote')"sv }, @@ -1665,209 +2093,7 @@ another line)"sv }, REQUIRE(tbl == expected); }); - parsing_should_succeed(FILE_LINE_ARGS, newline_crlf, [](toml::table&& tbl) - { - 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) - { - 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, raw_multiline_string, [](toml::table&& tbl) - { - 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); - }); - - parsing_should_succeed(FILE_LINE_ARGS, raw_string, [](toml::table&& tbl) - { - 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); - }); - - parsing_should_succeed(FILE_LINE_ARGS, spec_example_1_compact, [](toml::table&& tbl) - { - 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, 0, 0u }, { -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) - { - 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, 0, 0u }, { -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) - { - 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) - { - const auto expected = toml::table{{ - { R"(answer)"sv, R"()"sv }, - }}; - REQUIRE(tbl == expected); - }); - - parsing_should_succeed(FILE_LINE_ARGS, string_escaped_escape, [](toml::table&& tbl) - { - const auto expected = toml::table{{ - { R"(answer)"sv, R"(\x64)"sv }, - }}; - REQUIRE(tbl == expected); - }); - - parsing_should_succeed(FILE_LINE_ARGS, string_nl, [](toml::table&& tbl) + 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 }, @@ -1881,7 +2107,35 @@ ue)"sv }, REQUIRE(tbl == expected); }); - parsing_should_succeed(FILE_LINE_ARGS, string_simple, [](toml::table&& tbl) + 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); + }); + + 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); + }); + + 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 }, @@ -1889,7 +2143,7 @@ ue)"sv }, REQUIRE(tbl == expected); }); - parsing_should_succeed(FILE_LINE_ARGS, string_with_pound, [](toml::table&& tbl) + 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 }, @@ -1900,7 +2154,7 @@ ue)"sv }, #if UNICODE_LITERALS_OK - parsing_should_succeed(FILE_LINE_ARGS, string_escape_tricky, [](toml::table&& tbl) + 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 }, @@ -1914,7 +2168,7 @@ ue)"sv }, REQUIRE(tbl == expected); }); - parsing_should_succeed(FILE_LINE_ARGS, string_unicode_escape, [](toml::table&& tbl) + 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 }, @@ -1923,7 +2177,7 @@ ue)"sv }, REQUIRE(tbl == expected); }); - parsing_should_succeed(FILE_LINE_ARGS, string_unicode_literal, [](toml::table&& tbl) + 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 }, @@ -1933,7 +2187,7 @@ ue)"sv }, #endif // UNICODE_LITERALS_OK - parsing_should_succeed(FILE_LINE_ARGS, table_array_implicit, [](toml::table&& tbl) + parsing_should_succeed(FILE_LINE_ARGS, table_array_implicit, [](toml::table&& tbl) // table-array-implicit { const auto expected = toml::table{{ { @@ -1951,7 +2205,7 @@ ue)"sv }, REQUIRE(tbl == expected); }); - parsing_should_succeed(FILE_LINE_ARGS, table_array_many, [](toml::table&& tbl) + parsing_should_succeed(FILE_LINE_ARGS, table_array_many, [](toml::table&& tbl) // table-array-many { const auto expected = toml::table{{ { @@ -1974,7 +2228,7 @@ ue)"sv }, REQUIRE(tbl == expected); }); - parsing_should_succeed(FILE_LINE_ARGS, table_array_nest, [](toml::table&& tbl) + parsing_should_succeed(FILE_LINE_ARGS, table_array_nest, [](toml::table&& tbl) // table-array-nest { const auto expected = toml::table{{ { @@ -2011,7 +2265,7 @@ ue)"sv }, REQUIRE(tbl == expected); }); - parsing_should_succeed(FILE_LINE_ARGS, table_array_one, [](toml::table&& tbl) + parsing_should_succeed(FILE_LINE_ARGS, table_array_one, [](toml::table&& tbl) // table-array-one { const auto expected = toml::table{{ { @@ -2026,7 +2280,7 @@ ue)"sv }, REQUIRE(tbl == expected); }); - parsing_should_succeed(FILE_LINE_ARGS, table_array_table_array, [](toml::table&& tbl) + parsing_should_succeed(FILE_LINE_ARGS, table_array_table_array, [](toml::table&& tbl) // table-array-table-array { const auto expected = toml::table{{ { @@ -2057,7 +2311,7 @@ ue)"sv }, REQUIRE(tbl == expected); }); - parsing_should_succeed(FILE_LINE_ARGS, table_empty, [](toml::table&& tbl) + parsing_should_succeed(FILE_LINE_ARGS, table_empty, [](toml::table&& tbl) // table-empty { const auto expected = toml::table{{ { R"(a)"sv, toml::table{} }, @@ -2065,7 +2319,18 @@ ue)"sv }, REQUIRE(tbl == expected); }); - parsing_should_succeed(FILE_LINE_ARGS, table_no_eol, [](toml::table&& tbl) + 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{} }, @@ -2073,7 +2338,7 @@ ue)"sv }, REQUIRE(tbl == expected); }); - parsing_should_succeed(FILE_LINE_ARGS, table_sub_empty, [](toml::table&& tbl) + parsing_should_succeed(FILE_LINE_ARGS, table_sub_empty, [](toml::table&& tbl) // table-sub-empty { const auto expected = toml::table{{ { @@ -2085,7 +2350,7 @@ ue)"sv }, REQUIRE(tbl == expected); }); - parsing_should_succeed(FILE_LINE_ARGS, table_whitespace, [](toml::table&& tbl) + parsing_should_succeed(FILE_LINE_ARGS, table_whitespace, [](toml::table&& tbl) // table-whitespace { const auto expected = toml::table{{ { R"(valid key)"sv, toml::table{} }, @@ -2093,7 +2358,7 @@ ue)"sv }, REQUIRE(tbl == expected); }); - parsing_should_succeed(FILE_LINE_ARGS, table_with_literal_string, [](toml::table&& tbl) + parsing_should_succeed(FILE_LINE_ARGS, table_with_literal_string, [](toml::table&& tbl) // table-with-literal-string { const auto expected = toml::table{{ { @@ -2113,7 +2378,7 @@ ue)"sv }, REQUIRE(tbl == expected); }); - parsing_should_succeed(FILE_LINE_ARGS, table_with_pound, [](toml::table&& tbl) + parsing_should_succeed(FILE_LINE_ARGS, table_with_pound, [](toml::table&& tbl) // table-with-pound { const auto expected = toml::table{{ { @@ -2125,7 +2390,7 @@ ue)"sv }, REQUIRE(tbl == expected); }); - parsing_should_succeed(FILE_LINE_ARGS, table_with_single_quotes, [](toml::table&& tbl) + parsing_should_succeed(FILE_LINE_ARGS, table_with_single_quotes, [](toml::table&& tbl) // table-with-single-quotes { const auto expected = toml::table{{ { @@ -2145,7 +2410,7 @@ ue)"sv }, REQUIRE(tbl == expected); }); - parsing_should_succeed(FILE_LINE_ARGS, table_without_super, [](toml::table&& tbl) + parsing_should_succeed(FILE_LINE_ARGS, table_without_super, [](toml::table&& tbl) // table-without-super { const auto expected = toml::table{{ { @@ -2167,7 +2432,7 @@ ue)"sv }, #if UNICODE_LITERALS_OK - parsing_should_succeed(FILE_LINE_ARGS, table_names, [](toml::table&& tbl) + parsing_should_succeed(FILE_LINE_ARGS, table_names, [](toml::table&& tbl) // table-names { const auto expected = toml::table{{ { @@ -2209,6 +2474,15 @@ ue)"sv }, }, }} }, + { + R"(x)"sv, toml::table{{ + { + R"(1)"sv, toml::table{{ + { R"(2)"sv, toml::table{} }, + }} + }, + }} + }, }}; REQUIRE(tbl == expected); }); diff --git a/tests/conformance_iarna_invalid.cpp b/tests/conformance_iarna_invalid.cpp index 948f3ab..06ef6b1 100644 --- a/tests/conformance_iarna_invalid.cpp +++ b/tests/conformance_iarna_invalid.cpp @@ -148,76 +148,76 @@ TOML_ENABLE_WARNINGS; TEST_CASE("conformance - iarna/invalid") { - parsing_should_fail(FILE_LINE_ARGS, 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); + parsing_should_fail(FILE_LINE_ARGS, array_of_tables_2); // array-of-tables-2 - parsing_should_fail(FILE_LINE_ARGS, bare_key_1); + parsing_should_fail(FILE_LINE_ARGS, bare_key_1); // bare-key-1 - parsing_should_fail(FILE_LINE_ARGS, bare_key_2); + parsing_should_fail(FILE_LINE_ARGS, bare_key_2); // bare-key-2 - parsing_should_fail(FILE_LINE_ARGS, bare_key_3); + parsing_should_fail(FILE_LINE_ARGS, bare_key_3); // bare-key-3 - parsing_should_fail(FILE_LINE_ARGS, 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); + 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); + 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); + parsing_should_fail(FILE_LINE_ARGS, int_0_padded); // int-0-padded - parsing_should_fail(FILE_LINE_ARGS, int_signed_bin); + parsing_should_fail(FILE_LINE_ARGS, int_signed_bin); // int-signed-bin - parsing_should_fail(FILE_LINE_ARGS, int_signed_hex); + parsing_should_fail(FILE_LINE_ARGS, int_signed_hex); // int-signed-hex - parsing_should_fail(FILE_LINE_ARGS, 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); + parsing_should_fail(FILE_LINE_ARGS, key_value_pair_1); // key-value-pair-1 - parsing_should_fail(FILE_LINE_ARGS, 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); + parsing_should_fail(FILE_LINE_ARGS, multiple_dot_key); // multiple-dot-key - parsing_should_fail(FILE_LINE_ARGS, multiple_key); + parsing_should_fail(FILE_LINE_ARGS, multiple_key); // multiple-key - parsing_should_fail(FILE_LINE_ARGS, no_key_name); + parsing_should_fail(FILE_LINE_ARGS, no_key_name); // no-key-name - parsing_should_fail(FILE_LINE_ARGS, 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); + 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); + 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); + 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); + 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); + 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); + 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); + parsing_should_fail(FILE_LINE_ARGS, string_basic_unknown_escape); // string-basic-unknown-escape - parsing_should_fail(FILE_LINE_ARGS, 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); + parsing_should_fail(FILE_LINE_ARGS, table_1); // table-1 - parsing_should_fail(FILE_LINE_ARGS, table_2); + parsing_should_fail(FILE_LINE_ARGS, table_2); // table-2 - parsing_should_fail(FILE_LINE_ARGS, table_3); + parsing_should_fail(FILE_LINE_ARGS, table_3); // table-3 - parsing_should_fail(FILE_LINE_ARGS, table_4); + parsing_should_fail(FILE_LINE_ARGS, table_4); // table-4 - parsing_should_fail(FILE_LINE_ARGS, table_invalid_1); + parsing_should_fail(FILE_LINE_ARGS, table_invalid_1); // table-invalid-1 - parsing_should_fail(FILE_LINE_ARGS, table_invalid_2); + parsing_should_fail(FILE_LINE_ARGS, table_invalid_2); // table-invalid-2 - parsing_should_fail(FILE_LINE_ARGS, table_invalid_3); + parsing_should_fail(FILE_LINE_ARGS, table_invalid_3); // table-invalid-3 - parsing_should_fail(FILE_LINE_ARGS, 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 1d63f95..801edd8 100644 --- a/tests/conformance_iarna_valid.cpp +++ b/tests/conformance_iarna_valid.cpp @@ -270,7 +270,7 @@ TOML_ENABLE_WARNINGS; TEST_CASE("conformance - iarna/valid") { - parsing_should_succeed(FILE_LINE_ARGS, spec_array_1, [](toml::table&& tbl) + parsing_should_succeed(FILE_LINE_ARGS, spec_array_1, [](toml::table&& tbl) // spec-array-1 { const auto expected = toml::table{{ { @@ -284,7 +284,7 @@ TEST_CASE("conformance - iarna/valid") REQUIRE(tbl == expected); }); - parsing_should_succeed(FILE_LINE_ARGS, spec_array_2, [](toml::table&& tbl) + parsing_should_succeed(FILE_LINE_ARGS, spec_array_2, [](toml::table&& tbl) // spec-array-2 { const auto expected = toml::table{{ { @@ -298,7 +298,7 @@ TEST_CASE("conformance - iarna/valid") REQUIRE(tbl == expected); }); - parsing_should_succeed(FILE_LINE_ARGS, spec_array_3, [](toml::table&& tbl) + parsing_should_succeed(FILE_LINE_ARGS, spec_array_3, [](toml::table&& tbl) // spec-array-3 { const auto expected = toml::table{{ { @@ -318,7 +318,7 @@ TEST_CASE("conformance - iarna/valid") REQUIRE(tbl == expected); }); - parsing_should_succeed(FILE_LINE_ARGS, spec_array_4, [](toml::table&& tbl) + parsing_should_succeed(FILE_LINE_ARGS, spec_array_4, [](toml::table&& tbl) // spec-array-4 { const auto expected = toml::table{{ { @@ -333,7 +333,7 @@ TEST_CASE("conformance - iarna/valid") REQUIRE(tbl == expected); }); - parsing_should_succeed(FILE_LINE_ARGS, spec_array_5, [](toml::table&& tbl) + parsing_should_succeed(FILE_LINE_ARGS, spec_array_5, [](toml::table&& tbl) // spec-array-5 { const auto expected = toml::table{{ { @@ -353,7 +353,7 @@ TEST_CASE("conformance - iarna/valid") REQUIRE(tbl == expected); }); - parsing_should_succeed(FILE_LINE_ARGS, spec_array_7, [](toml::table&& tbl) + parsing_should_succeed(FILE_LINE_ARGS, spec_array_7, [](toml::table&& tbl) // spec-array-7 { const auto expected = toml::table{{ { @@ -367,7 +367,7 @@ TEST_CASE("conformance - iarna/valid") REQUIRE(tbl == expected); }); - parsing_should_succeed(FILE_LINE_ARGS, spec_array_8, [](toml::table&& tbl) + parsing_should_succeed(FILE_LINE_ARGS, spec_array_8, [](toml::table&& tbl) // spec-array-8 { const auto expected = toml::table{{ { @@ -380,7 +380,7 @@ TEST_CASE("conformance - iarna/valid") REQUIRE(tbl == expected); }); - parsing_should_succeed(FILE_LINE_ARGS, spec_array_mixed_number_types, [](toml::table&& tbl) + parsing_should_succeed(FILE_LINE_ARGS, spec_array_mixed_number_types, [](toml::table&& tbl) // spec-array-mixed-number-types { const auto expected = toml::table{{ { @@ -397,7 +397,7 @@ TEST_CASE("conformance - iarna/valid") REQUIRE(tbl == expected); }); - parsing_should_succeed(FILE_LINE_ARGS, spec_array_more_mixed_types, [](toml::table&& tbl) + parsing_should_succeed(FILE_LINE_ARGS, spec_array_more_mixed_types, [](toml::table&& tbl) // spec-array-more-mixed-types { const auto expected = toml::table{{ { @@ -414,7 +414,7 @@ TEST_CASE("conformance - iarna/valid") REQUIRE(tbl == expected); }); - parsing_should_succeed(FILE_LINE_ARGS, spec_array_of_tables_1, [](toml::table&& tbl) + parsing_should_succeed(FILE_LINE_ARGS, spec_array_of_tables_1, [](toml::table&& tbl) // spec-array-of-tables-1 { const auto expected = toml::table{{ { @@ -435,7 +435,7 @@ TEST_CASE("conformance - iarna/valid") REQUIRE(tbl == expected); }); - parsing_should_succeed(FILE_LINE_ARGS, spec_array_of_tables_2, [](toml::table&& tbl) + parsing_should_succeed(FILE_LINE_ARGS, spec_array_of_tables_2, [](toml::table&& tbl) // spec-array-of-tables-2 { const auto expected = toml::table{{ { @@ -475,7 +475,7 @@ TEST_CASE("conformance - iarna/valid") REQUIRE(tbl == expected); }); - parsing_should_succeed(FILE_LINE_ARGS, spec_array_of_tables_3, [](toml::table&& tbl) + parsing_should_succeed(FILE_LINE_ARGS, spec_array_of_tables_3, [](toml::table&& tbl) // spec-array-of-tables-3 { const auto expected = toml::table{{ { @@ -501,7 +501,7 @@ TEST_CASE("conformance - iarna/valid") REQUIRE(tbl == expected); }); - parsing_should_succeed(FILE_LINE_ARGS, spec_boolean_1, [](toml::table&& tbl) + parsing_should_succeed(FILE_LINE_ARGS, spec_boolean_1, [](toml::table&& tbl) // spec-boolean-1 { const auto expected = toml::table{{ { R"(bool1)"sv, true }, @@ -509,7 +509,7 @@ TEST_CASE("conformance - iarna/valid") REQUIRE(tbl == expected); }); - parsing_should_succeed(FILE_LINE_ARGS, spec_boolean_2, [](toml::table&& tbl) + parsing_should_succeed(FILE_LINE_ARGS, spec_boolean_2, [](toml::table&& tbl) // spec-boolean-2 { const auto expected = toml::table{{ { R"(bool1)"sv, false }, @@ -517,7 +517,7 @@ TEST_CASE("conformance - iarna/valid") REQUIRE(tbl == expected); }); - parsing_should_succeed(FILE_LINE_ARGS, spec_case_sensitive, [](toml::table&& tbl) + parsing_should_succeed(FILE_LINE_ARGS, spec_case_sensitive, [](toml::table&& tbl) // spec-case-sensitive { const auto expected = toml::table{{ { R"(abc)"sv, 123 }, @@ -526,7 +526,7 @@ TEST_CASE("conformance - iarna/valid") REQUIRE(tbl == expected); }); - parsing_should_succeed(FILE_LINE_ARGS, spec_comment_mid_array, [](toml::table&& tbl) + parsing_should_succeed(FILE_LINE_ARGS, spec_comment_mid_array, [](toml::table&& tbl) // spec-comment-mid-array { const auto expected = toml::table{{ { @@ -539,7 +539,7 @@ TEST_CASE("conformance - iarna/valid") REQUIRE(tbl == expected); }); - parsing_should_succeed(FILE_LINE_ARGS, spec_comment_mid_string, [](toml::table&& tbl) + 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 }, @@ -547,7 +547,7 @@ TEST_CASE("conformance - iarna/valid") REQUIRE(tbl == expected); }); - parsing_should_succeed(FILE_LINE_ARGS, spec_comment_tab, [](toml::table&& tbl) + 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 }, @@ -555,7 +555,7 @@ TEST_CASE("conformance - iarna/valid") REQUIRE(tbl == expected); }); - parsing_should_succeed(FILE_LINE_ARGS, spec_comment, [](toml::table&& tbl) + parsing_should_succeed(FILE_LINE_ARGS, spec_comment, [](toml::table&& tbl) // spec-comment { const auto expected = toml::table{{ { R"(key)"sv, R"(value)"sv }, @@ -563,7 +563,7 @@ TEST_CASE("conformance - iarna/valid") REQUIRE(tbl == expected); }); - parsing_should_succeed(FILE_LINE_ARGS, spec_date_local_1, [](toml::table&& tbl) + 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 } }, @@ -571,7 +571,7 @@ TEST_CASE("conformance - iarna/valid") REQUIRE(tbl == expected); }); - parsing_should_succeed(FILE_LINE_ARGS, spec_date_time_1, [](toml::table&& tbl) + 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, 0u }, { 0, 0 } } }, @@ -579,7 +579,7 @@ TEST_CASE("conformance - iarna/valid") REQUIRE(tbl == expected); }); - parsing_should_succeed(FILE_LINE_ARGS, spec_date_time_2, [](toml::table&& tbl) + 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, 0, 0u }, { -7, 0 } } }, @@ -587,7 +587,7 @@ TEST_CASE("conformance - iarna/valid") REQUIRE(tbl == expected); }); - parsing_should_succeed(FILE_LINE_ARGS, spec_date_time_3, [](toml::table&& tbl) + 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, 999999000u }, { -7, 0 } } }, @@ -595,7 +595,7 @@ TEST_CASE("conformance - iarna/valid") REQUIRE(tbl == expected); }); - parsing_should_succeed(FILE_LINE_ARGS, spec_date_time_4, [](toml::table&& tbl) + 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, 0u }, { 0, 0 } } }, @@ -603,7 +603,7 @@ TEST_CASE("conformance - iarna/valid") REQUIRE(tbl == expected); }); - parsing_should_succeed(FILE_LINE_ARGS, spec_date_time_5, [](toml::table&& tbl) + 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, 123000000u }, { 0, 0 } } }, @@ -611,7 +611,7 @@ TEST_CASE("conformance - iarna/valid") REQUIRE(tbl == expected); }); - parsing_should_succeed(FILE_LINE_ARGS, spec_date_time_local_1, [](toml::table&& tbl) + 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, 0, 0u } } }, @@ -619,7 +619,7 @@ TEST_CASE("conformance - iarna/valid") REQUIRE(tbl == expected); }); - parsing_should_succeed(FILE_LINE_ARGS, spec_dotted_keys_1, [](toml::table&& tbl) + 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 }, @@ -638,7 +638,7 @@ TEST_CASE("conformance - iarna/valid") REQUIRE(tbl == expected); }); - parsing_should_succeed(FILE_LINE_ARGS, spec_dotted_keys_2, [](toml::table&& tbl) + parsing_should_succeed(FILE_LINE_ARGS, spec_dotted_keys_2, [](toml::table&& tbl) // spec-dotted-keys-2 { const auto expected = toml::table{{ { @@ -650,7 +650,7 @@ TEST_CASE("conformance - iarna/valid") REQUIRE(tbl == expected); }); - parsing_should_succeed(FILE_LINE_ARGS, spec_dotted_keys_3, [](toml::table&& tbl) + parsing_should_succeed(FILE_LINE_ARGS, spec_dotted_keys_3, [](toml::table&& tbl) // spec-dotted-keys-3 { const auto expected = toml::table{{ { @@ -662,7 +662,7 @@ TEST_CASE("conformance - iarna/valid") REQUIRE(tbl == expected); }); - parsing_should_succeed(FILE_LINE_ARGS, spec_empty_key_name_1, [](toml::table&& tbl) + parsing_should_succeed(FILE_LINE_ARGS, spec_empty_key_name_1, [](toml::table&& tbl) // spec-empty-key-name-1 { const auto expected = toml::table{{ { R"()"sv, R"(blank)"sv }, @@ -670,7 +670,7 @@ TEST_CASE("conformance - iarna/valid") REQUIRE(tbl == expected); }); - parsing_should_succeed(FILE_LINE_ARGS, spec_empty_key_name_2, [](toml::table&& tbl) + parsing_should_succeed(FILE_LINE_ARGS, spec_empty_key_name_2, [](toml::table&& tbl) // spec-empty-key-name-2 { const auto expected = toml::table{{ { R"()"sv, R"(blank)"sv }, @@ -678,7 +678,7 @@ TEST_CASE("conformance - iarna/valid") REQUIRE(tbl == expected); }); - parsing_should_succeed(FILE_LINE_ARGS, spec_extend_dotted_object_1, [](toml::table&& tbl) + parsing_should_succeed(FILE_LINE_ARGS, spec_extend_dotted_object_1, [](toml::table&& tbl) // spec-extend-dotted-object-1 { const auto expected = toml::table{{ { @@ -695,7 +695,7 @@ TEST_CASE("conformance - iarna/valid") REQUIRE(tbl == expected); }); - parsing_should_succeed(FILE_LINE_ARGS, spec_extend_dotted_object_2, [](toml::table&& tbl) + parsing_should_succeed(FILE_LINE_ARGS, spec_extend_dotted_object_2, [](toml::table&& tbl) // spec-extend-dotted-object-2 { const auto expected = toml::table{{ { @@ -716,7 +716,7 @@ TEST_CASE("conformance - iarna/valid") REQUIRE(tbl == expected); }); - parsing_should_succeed(FILE_LINE_ARGS, spec_extend_dotted_object_3, [](toml::table&& tbl) + parsing_should_succeed(FILE_LINE_ARGS, spec_extend_dotted_object_3, [](toml::table&& tbl) // spec-extend-dotted-object-3 { const auto expected = toml::table{{ { @@ -737,7 +737,7 @@ TEST_CASE("conformance - iarna/valid") REQUIRE(tbl == expected); }); - parsing_should_succeed(FILE_LINE_ARGS, spec_float_1, [](toml::table&& tbl) + 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 }, @@ -745,7 +745,7 @@ TEST_CASE("conformance - iarna/valid") REQUIRE(tbl == expected); }); - parsing_should_succeed(FILE_LINE_ARGS, spec_float_10, [](toml::table&& tbl) + 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() }, @@ -753,7 +753,7 @@ TEST_CASE("conformance - iarna/valid") REQUIRE(tbl == expected); }); - parsing_should_succeed(FILE_LINE_ARGS, spec_float_11, [](toml::table&& tbl) + 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() }, @@ -761,7 +761,7 @@ TEST_CASE("conformance - iarna/valid") REQUIRE(tbl == expected); }); - parsing_should_succeed(FILE_LINE_ARGS, spec_float_12, [](toml::table&& tbl) + 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() }, @@ -769,7 +769,7 @@ TEST_CASE("conformance - iarna/valid") REQUIRE(tbl == expected); }); - parsing_should_succeed(FILE_LINE_ARGS, spec_float_13, [](toml::table&& tbl) + 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() }, @@ -777,7 +777,7 @@ TEST_CASE("conformance - iarna/valid") REQUIRE(tbl == expected); }); - parsing_should_succeed(FILE_LINE_ARGS, spec_float_14, [](toml::table&& tbl) + 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() }, @@ -785,7 +785,7 @@ TEST_CASE("conformance - iarna/valid") REQUIRE(tbl == expected); }); - parsing_should_succeed(FILE_LINE_ARGS, spec_float_15, [](toml::table&& tbl) + 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() }, @@ -793,7 +793,7 @@ TEST_CASE("conformance - iarna/valid") REQUIRE(tbl == expected); }); - parsing_should_succeed(FILE_LINE_ARGS, spec_float_2, [](toml::table&& tbl) + 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 }, @@ -801,7 +801,7 @@ TEST_CASE("conformance - iarna/valid") REQUIRE(tbl == expected); }); - parsing_should_succeed(FILE_LINE_ARGS, spec_float_3, [](toml::table&& tbl) + 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 }, @@ -809,7 +809,7 @@ TEST_CASE("conformance - iarna/valid") REQUIRE(tbl == expected); }); - parsing_should_succeed(FILE_LINE_ARGS, spec_float_4, [](toml::table&& tbl) + 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 }, @@ -817,7 +817,7 @@ TEST_CASE("conformance - iarna/valid") REQUIRE(tbl == expected); }); - parsing_should_succeed(FILE_LINE_ARGS, spec_float_5, [](toml::table&& tbl) + 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 }, @@ -825,7 +825,7 @@ TEST_CASE("conformance - iarna/valid") REQUIRE(tbl == expected); }); - parsing_should_succeed(FILE_LINE_ARGS, spec_float_6, [](toml::table&& tbl) + 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 }, @@ -833,7 +833,7 @@ TEST_CASE("conformance - iarna/valid") REQUIRE(tbl == expected); }); - parsing_should_succeed(FILE_LINE_ARGS, spec_float_7, [](toml::table&& tbl) + 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 }, @@ -841,7 +841,7 @@ TEST_CASE("conformance - iarna/valid") REQUIRE(tbl == expected); }); - parsing_should_succeed(FILE_LINE_ARGS, spec_float_8, [](toml::table&& tbl) + 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 }, @@ -849,7 +849,7 @@ TEST_CASE("conformance - iarna/valid") REQUIRE(tbl == expected); }); - parsing_should_succeed(FILE_LINE_ARGS, spec_float_9, [](toml::table&& tbl) + 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 }, @@ -857,7 +857,7 @@ TEST_CASE("conformance - iarna/valid") REQUIRE(tbl == expected); }); - parsing_should_succeed(FILE_LINE_ARGS, spec_int_1, [](toml::table&& tbl) + parsing_should_succeed(FILE_LINE_ARGS, spec_int_1, [](toml::table&& tbl) // spec-int-1 { const auto expected = toml::table{{ { R"(int1)"sv, 99 }, @@ -865,7 +865,7 @@ TEST_CASE("conformance - iarna/valid") REQUIRE(tbl == expected); }); - parsing_should_succeed(FILE_LINE_ARGS, spec_int_2, [](toml::table&& tbl) + parsing_should_succeed(FILE_LINE_ARGS, spec_int_2, [](toml::table&& tbl) // spec-int-2 { const auto expected = toml::table{{ { R"(int2)"sv, 42 }, @@ -873,7 +873,7 @@ TEST_CASE("conformance - iarna/valid") REQUIRE(tbl == expected); }); - parsing_should_succeed(FILE_LINE_ARGS, spec_int_3, [](toml::table&& tbl) + parsing_should_succeed(FILE_LINE_ARGS, spec_int_3, [](toml::table&& tbl) // spec-int-3 { const auto expected = toml::table{{ { R"(int3)"sv, 0 }, @@ -881,7 +881,7 @@ TEST_CASE("conformance - iarna/valid") REQUIRE(tbl == expected); }); - parsing_should_succeed(FILE_LINE_ARGS, spec_int_3a, [](toml::table&& tbl) + parsing_should_succeed(FILE_LINE_ARGS, spec_int_3a, [](toml::table&& tbl) // spec-int-3a { const auto expected = toml::table{{ { R"(int3)"sv, 0 }, @@ -889,7 +889,7 @@ TEST_CASE("conformance - iarna/valid") REQUIRE(tbl == expected); }); - parsing_should_succeed(FILE_LINE_ARGS, spec_int_3b, [](toml::table&& tbl) + parsing_should_succeed(FILE_LINE_ARGS, spec_int_3b, [](toml::table&& tbl) // spec-int-3b { const auto expected = toml::table{{ { R"(int3)"sv, 0 }, @@ -897,7 +897,7 @@ TEST_CASE("conformance - iarna/valid") REQUIRE(tbl == expected); }); - parsing_should_succeed(FILE_LINE_ARGS, spec_int_4, [](toml::table&& tbl) + parsing_should_succeed(FILE_LINE_ARGS, spec_int_4, [](toml::table&& tbl) // spec-int-4 { const auto expected = toml::table{{ { R"(int4)"sv, -17 }, @@ -905,7 +905,7 @@ TEST_CASE("conformance - iarna/valid") REQUIRE(tbl == expected); }); - parsing_should_succeed(FILE_LINE_ARGS, spec_int_5, [](toml::table&& tbl) + parsing_should_succeed(FILE_LINE_ARGS, spec_int_5, [](toml::table&& tbl) // spec-int-5 { const auto expected = toml::table{{ { R"(int5)"sv, 1000 }, @@ -913,7 +913,7 @@ TEST_CASE("conformance - iarna/valid") REQUIRE(tbl == expected); }); - parsing_should_succeed(FILE_LINE_ARGS, spec_int_6, [](toml::table&& tbl) + parsing_should_succeed(FILE_LINE_ARGS, spec_int_6, [](toml::table&& tbl) // spec-int-6 { const auto expected = toml::table{{ { R"(int6)"sv, 5349221 }, @@ -921,7 +921,7 @@ TEST_CASE("conformance - iarna/valid") REQUIRE(tbl == expected); }); - parsing_should_succeed(FILE_LINE_ARGS, spec_int_7, [](toml::table&& tbl) + parsing_should_succeed(FILE_LINE_ARGS, spec_int_7, [](toml::table&& tbl) // spec-int-7 { const auto expected = toml::table{{ { R"(int7)"sv, 12345 }, @@ -929,7 +929,7 @@ TEST_CASE("conformance - iarna/valid") REQUIRE(tbl == expected); }); - parsing_should_succeed(FILE_LINE_ARGS, spec_int_bin1, [](toml::table&& tbl) + parsing_should_succeed(FILE_LINE_ARGS, spec_int_bin1, [](toml::table&& tbl) // spec-int-bin1 { const auto expected = toml::table{{ { R"(bin1)"sv, 214 }, @@ -937,7 +937,7 @@ TEST_CASE("conformance - iarna/valid") REQUIRE(tbl == expected); }); - parsing_should_succeed(FILE_LINE_ARGS, spec_int_hex1, [](toml::table&& tbl) + parsing_should_succeed(FILE_LINE_ARGS, spec_int_hex1, [](toml::table&& tbl) // spec-int-hex1 { const auto expected = toml::table{{ { R"(hex1)"sv, 3735928559 }, @@ -945,7 +945,7 @@ TEST_CASE("conformance - iarna/valid") REQUIRE(tbl == expected); }); - parsing_should_succeed(FILE_LINE_ARGS, spec_int_hex2, [](toml::table&& tbl) + parsing_should_succeed(FILE_LINE_ARGS, spec_int_hex2, [](toml::table&& tbl) // spec-int-hex2 { const auto expected = toml::table{{ { R"(hex2)"sv, 3735928559 }, @@ -953,7 +953,7 @@ TEST_CASE("conformance - iarna/valid") REQUIRE(tbl == expected); }); - parsing_should_succeed(FILE_LINE_ARGS, spec_int_hex3, [](toml::table&& tbl) + parsing_should_succeed(FILE_LINE_ARGS, spec_int_hex3, [](toml::table&& tbl) // spec-int-hex3 { const auto expected = toml::table{{ { R"(hex3)"sv, 3735928559 }, @@ -961,7 +961,7 @@ TEST_CASE("conformance - iarna/valid") REQUIRE(tbl == expected); }); - parsing_should_succeed(FILE_LINE_ARGS, spec_int_max, [](toml::table&& tbl) + parsing_should_succeed(FILE_LINE_ARGS, spec_int_max, [](toml::table&& tbl) // spec-int-max { const auto expected = toml::table{{ { R"(max)"sv, INT64_MAX }, @@ -969,7 +969,7 @@ TEST_CASE("conformance - iarna/valid") REQUIRE(tbl == expected); }); - parsing_should_succeed(FILE_LINE_ARGS, spec_int_min, [](toml::table&& tbl) + parsing_should_succeed(FILE_LINE_ARGS, spec_int_min, [](toml::table&& tbl) // spec-int-min { const auto expected = toml::table{{ { R"(min)"sv, INT64_MIN }, @@ -977,7 +977,7 @@ TEST_CASE("conformance - iarna/valid") REQUIRE(tbl == expected); }); - parsing_should_succeed(FILE_LINE_ARGS, spec_int_oct1, [](toml::table&& tbl) + parsing_should_succeed(FILE_LINE_ARGS, spec_int_oct1, [](toml::table&& tbl) // spec-int-oct1 { const auto expected = toml::table{{ { R"(oct1)"sv, 342391 }, @@ -985,7 +985,7 @@ TEST_CASE("conformance - iarna/valid") REQUIRE(tbl == expected); }); - parsing_should_succeed(FILE_LINE_ARGS, spec_int_oct2, [](toml::table&& tbl) + parsing_should_succeed(FILE_LINE_ARGS, spec_int_oct2, [](toml::table&& tbl) // spec-int-oct2 { const auto expected = toml::table{{ { R"(oct2)"sv, 493 }, @@ -993,7 +993,7 @@ TEST_CASE("conformance - iarna/valid") REQUIRE(tbl == expected); }); - parsing_should_succeed(FILE_LINE_ARGS, spec_key_value_pair_1, [](toml::table&& tbl) + 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 }, @@ -1001,7 +1001,7 @@ TEST_CASE("conformance - iarna/valid") REQUIRE(tbl == expected); }); - parsing_should_succeed(FILE_LINE_ARGS, spec_key_value_pair_2, [](toml::table&& tbl) + 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 }, @@ -1009,7 +1009,7 @@ TEST_CASE("conformance - iarna/valid") REQUIRE(tbl == expected); }); - parsing_should_succeed(FILE_LINE_ARGS, spec_key_value_pair_3, [](toml::table&& tbl) + 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 }, @@ -1017,7 +1017,7 @@ TEST_CASE("conformance - iarna/valid") REQUIRE(tbl == expected); }); - parsing_should_succeed(FILE_LINE_ARGS, spec_key_value_pair_4, [](toml::table&& tbl) + 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 }, @@ -1025,7 +1025,7 @@ TEST_CASE("conformance - iarna/valid") REQUIRE(tbl == expected); }); - parsing_should_succeed(FILE_LINE_ARGS, spec_key_value_pair_5, [](toml::table&& tbl) + 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 }, @@ -1033,7 +1033,7 @@ TEST_CASE("conformance - iarna/valid") REQUIRE(tbl == expected); }); - parsing_should_succeed(FILE_LINE_ARGS, spec_key_value_pair_6, [](toml::table&& tbl) + 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 }, @@ -1041,7 +1041,7 @@ TEST_CASE("conformance - iarna/valid") REQUIRE(tbl == expected); }); - parsing_should_succeed(FILE_LINE_ARGS, spec_key_value_pair_7, [](toml::table&& tbl) + 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 }, @@ -1049,7 +1049,7 @@ TEST_CASE("conformance - iarna/valid") REQUIRE(tbl == expected); }); - parsing_should_succeed(FILE_LINE_ARGS, spec_key_value_pair_8, [](toml::table&& tbl) + 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 }, @@ -1057,7 +1057,7 @@ TEST_CASE("conformance - iarna/valid") REQUIRE(tbl == expected); }); - parsing_should_succeed(FILE_LINE_ARGS, spec_key_value_pair_9, [](toml::table&& tbl) + parsing_should_succeed(FILE_LINE_ARGS, spec_key_value_pair_9, [](toml::table&& tbl) // spec-key-value-pair-9 { const auto expected = toml::table{{ { @@ -1069,7 +1069,7 @@ TEST_CASE("conformance - iarna/valid") REQUIRE(tbl == expected); }); - parsing_should_succeed(FILE_LINE_ARGS, spec_quoted_literal_keys_1, [](toml::table&& tbl) + 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 }, @@ -1077,7 +1077,7 @@ TEST_CASE("conformance - iarna/valid") REQUIRE(tbl == expected); }); - parsing_should_succeed(FILE_LINE_ARGS, spec_readme_example, [](toml::table&& tbl) + 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 }, @@ -1143,7 +1143,7 @@ TEST_CASE("conformance - iarna/valid") REQUIRE(tbl == expected); }); - parsing_should_succeed(FILE_LINE_ARGS, spec_string_basic_multiline_1, [](toml::table&& tbl) + 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 @@ -1152,7 +1152,7 @@ Violets are blue)"sv }, REQUIRE(tbl == expected); }); - parsing_should_succeed(FILE_LINE_ARGS, spec_string_basic_multiline_2, [](toml::table&& tbl) + 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 }, @@ -1160,7 +1160,7 @@ Violets are blue)"sv }, REQUIRE(tbl == expected); }); - parsing_should_succeed(FILE_LINE_ARGS, spec_string_basic_multiline_3, [](toml::table&& tbl) + 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 }, @@ -1168,7 +1168,7 @@ Violets are blue)"sv }, REQUIRE(tbl == expected); }); - parsing_should_succeed(FILE_LINE_ARGS, spec_string_basic_multiline_5, [](toml::table&& tbl) + 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 \ @@ -1177,7 +1177,7 @@ Violets are blue)"sv }, REQUIRE(tbl == expected); }); - parsing_should_succeed(FILE_LINE_ARGS, spec_string_basic_multiline_6, [](toml::table&& tbl) + 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 }, @@ -1185,7 +1185,7 @@ Violets are blue)"sv }, REQUIRE(tbl == expected); }); - parsing_should_succeed(FILE_LINE_ARGS, spec_string_basic_multiline_7, [](toml::table&& tbl) + 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 }, @@ -1193,7 +1193,7 @@ Violets are blue)"sv }, REQUIRE(tbl == expected); }); - parsing_should_succeed(FILE_LINE_ARGS, spec_string_basic_multiline_8, [](toml::table&& tbl) + 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 }, @@ -1201,7 +1201,7 @@ Violets are blue)"sv }, REQUIRE(tbl == expected); }); - parsing_should_succeed(FILE_LINE_ARGS, spec_string_basic_multiline_9, [](toml::table&& tbl) + 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 }, @@ -1209,7 +1209,7 @@ Violets are blue)"sv }, REQUIRE(tbl == expected); }); - parsing_should_succeed(FILE_LINE_ARGS, spec_string_basic_tab_multiline, [](toml::table&& tbl) + 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 }, @@ -1217,7 +1217,7 @@ Violets are blue)"sv }, REQUIRE(tbl == expected); }); - parsing_should_succeed(FILE_LINE_ARGS, spec_string_basic_tab, [](toml::table&& tbl) + 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 }, @@ -1225,7 +1225,7 @@ Violets are blue)"sv }, REQUIRE(tbl == expected); }); - parsing_should_succeed(FILE_LINE_ARGS, spec_string_literal_1, [](toml::table&& tbl) + 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 }, @@ -1233,7 +1233,7 @@ Violets are blue)"sv }, REQUIRE(tbl == expected); }); - parsing_should_succeed(FILE_LINE_ARGS, spec_string_literal_2, [](toml::table&& tbl) + 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 }, @@ -1241,7 +1241,7 @@ Violets are blue)"sv }, REQUIRE(tbl == expected); }); - parsing_should_succeed(FILE_LINE_ARGS, spec_string_literal_3, [](toml::table&& tbl) + 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 }, @@ -1249,7 +1249,7 @@ Violets are blue)"sv }, REQUIRE(tbl == expected); }); - parsing_should_succeed(FILE_LINE_ARGS, spec_string_literal_4, [](toml::table&& tbl) + 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 }, @@ -1257,7 +1257,7 @@ Violets are blue)"sv }, REQUIRE(tbl == expected); }); - parsing_should_succeed(FILE_LINE_ARGS, spec_string_literal_multiline_1, [](toml::table&& tbl) + 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 }, @@ -1265,7 +1265,7 @@ Violets are blue)"sv }, REQUIRE(tbl == expected); }); - parsing_should_succeed(FILE_LINE_ARGS, spec_string_literal_multiline_2, [](toml::table&& tbl) + 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 @@ -1277,7 +1277,7 @@ trimmed in raw strings. REQUIRE(tbl == expected); }); - parsing_should_succeed(FILE_LINE_ARGS, spec_string_literal_multiline_3, [](toml::table&& tbl) + 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 }, @@ -1285,7 +1285,7 @@ trimmed in raw strings. REQUIRE(tbl == expected); }); - parsing_should_succeed(FILE_LINE_ARGS, spec_string_literal_multiline_4, [](toml::table&& tbl) + 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 }, @@ -1293,7 +1293,7 @@ trimmed in raw strings. REQUIRE(tbl == expected); }); - parsing_should_succeed(FILE_LINE_ARGS, spec_table_1, [](toml::table&& tbl) + parsing_should_succeed(FILE_LINE_ARGS, spec_table_1, [](toml::table&& tbl) // spec-table-1 { const auto expected = toml::table{{ { @@ -1312,7 +1312,7 @@ trimmed in raw strings. REQUIRE(tbl == expected); }); - parsing_should_succeed(FILE_LINE_ARGS, spec_table_2, [](toml::table&& tbl) + parsing_should_succeed(FILE_LINE_ARGS, spec_table_2, [](toml::table&& tbl) // spec-table-2 { const auto expected = toml::table{{ { @@ -1332,7 +1332,7 @@ trimmed in raw strings. REQUIRE(tbl == expected); }); - parsing_should_succeed(FILE_LINE_ARGS, spec_table_3, [](toml::table&& tbl) + parsing_should_succeed(FILE_LINE_ARGS, spec_table_3, [](toml::table&& tbl) // spec-table-3 { const auto expected = toml::table{{ { @@ -1348,7 +1348,7 @@ trimmed in raw strings. REQUIRE(tbl == expected); }); - parsing_should_succeed(FILE_LINE_ARGS, spec_table_4, [](toml::table&& tbl) + parsing_should_succeed(FILE_LINE_ARGS, spec_table_4, [](toml::table&& tbl) // spec-table-4 { const auto expected = toml::table{{ { @@ -1364,7 +1364,7 @@ trimmed in raw strings. REQUIRE(tbl == expected); }); - parsing_should_succeed(FILE_LINE_ARGS, spec_table_5, [](toml::table&& tbl) + parsing_should_succeed(FILE_LINE_ARGS, spec_table_5, [](toml::table&& tbl) // spec-table-5 { const auto expected = toml::table{{ { @@ -1380,7 +1380,7 @@ trimmed in raw strings. REQUIRE(tbl == expected); }); - parsing_should_succeed(FILE_LINE_ARGS, spec_table_7, [](toml::table&& tbl) + parsing_should_succeed(FILE_LINE_ARGS, spec_table_7, [](toml::table&& tbl) // spec-table-7 { const auto expected = toml::table{{ { @@ -1400,7 +1400,7 @@ trimmed in raw strings. REQUIRE(tbl == expected); }); - parsing_should_succeed(FILE_LINE_ARGS, spec_table_8, [](toml::table&& tbl) + parsing_should_succeed(FILE_LINE_ARGS, spec_table_8, [](toml::table&& tbl) // spec-table-8 { const auto expected = toml::table{{ { @@ -1426,7 +1426,7 @@ trimmed in raw strings. REQUIRE(tbl == expected); }); - parsing_should_succeed(FILE_LINE_ARGS, spec_table_inline_1, [](toml::table&& tbl) + parsing_should_succeed(FILE_LINE_ARGS, spec_table_inline_1, [](toml::table&& tbl) // spec-table-inline-1 { const auto expected = toml::table{{ { @@ -1439,7 +1439,7 @@ trimmed in raw strings. REQUIRE(tbl == expected); }); - parsing_should_succeed(FILE_LINE_ARGS, spec_table_inline_2, [](toml::table&& tbl) + parsing_should_succeed(FILE_LINE_ARGS, spec_table_inline_2, [](toml::table&& tbl) // spec-table-inline-2 { const auto expected = toml::table{{ { @@ -1452,7 +1452,7 @@ trimmed in raw strings. REQUIRE(tbl == expected); }); - parsing_should_succeed(FILE_LINE_ARGS, spec_table_inline_3, [](toml::table&& tbl) + parsing_should_succeed(FILE_LINE_ARGS, spec_table_inline_3, [](toml::table&& tbl) // spec-table-inline-3 { const auto expected = toml::table{{ { @@ -1468,7 +1468,7 @@ trimmed in raw strings. REQUIRE(tbl == expected); }); - parsing_should_succeed(FILE_LINE_ARGS, spec_table, [](toml::table&& tbl) + parsing_should_succeed(FILE_LINE_ARGS, spec_table, [](toml::table&& tbl) // spec-table { const auto expected = toml::table{{ { R"(table)"sv, toml::table{} }, @@ -1476,7 +1476,7 @@ trimmed in raw strings. REQUIRE(tbl == expected); }); - parsing_should_succeed(FILE_LINE_ARGS, spec_time_1, [](toml::table&& tbl) + 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, 0, 0 } }, @@ -1486,7 +1486,7 @@ trimmed in raw strings. #if UNICODE_LITERALS_OK - parsing_should_succeed(FILE_LINE_ARGS, spec_quoted_basic_keys_1, [](toml::table&& tbl) + 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 }, @@ -1494,7 +1494,7 @@ trimmed in raw strings. REQUIRE(tbl == expected); }); - parsing_should_succeed(FILE_LINE_ARGS, spec_string_basic, [](toml::table&& tbl) + 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é @@ -1503,7 +1503,7 @@ Location SF.)"sv }, REQUIRE(tbl == expected); }); - parsing_should_succeed(FILE_LINE_ARGS, spec_table_6, [](toml::table&& tbl) + parsing_should_succeed(FILE_LINE_ARGS, spec_table_6, [](toml::table&& tbl) // spec-table-6 { const auto expected = toml::table{{ { diff --git a/tests/tests.cpp b/tests/tests.cpp index d358556..daf0252 100644 --- a/tests/tests.cpp +++ b/tests/tests.cpp @@ -112,20 +112,38 @@ bool parsing_should_succeed( bool parsing_should_fail( std::string_view test_file, uint32_t test_line, - std::string_view toml_str) + std::string_view toml_str, + source_index expected_failure_line, + source_index expected_failure_column) { INFO("["sv << test_file << ", line "sv << test_line << "] "sv << "parsing_should_fail(\""sv << toml_str << "\")"sv) #if TOML_EXCEPTIONS - static constexpr auto run_tests = [](auto&& fn) + static constexpr auto run_tests = [](source_index ex_line, source_index ex_col, auto&& fn) { try { fn(); } - catch (const parse_error&) + catch (const parse_error& err) { + if (ex_line != static_cast(-1) && err.source().begin.line != ex_line) + { + FORCE_FAIL("Expected parse_error at line "sv << ex_line + << ", actually occured at line "sv << err.source().begin.line + ); + return false; + } + + if (ex_col != static_cast(-1) && err.source().begin.column != ex_col) + { + FORCE_FAIL("Expected parse_error at column "sv << ex_col + << ", actually occured at column "sv << err.source().begin.column + ); + return false; + } + SUCCEED("parse_error thrown OK"sv); return true; } @@ -144,11 +162,11 @@ bool parsing_should_fail( return false; }; - auto result = run_tests([=]() + auto result = run_tests(expected_failure_line, expected_failure_column, [=]() { [[maybe_unused]] auto res = toml::parse(toml_str); }); - result = result && run_tests([=]() + result = result && run_tests(expected_failure_line, expected_failure_column, [=]() { std::stringstream ss; ss.write(toml_str.data(), static_cast(toml_str.length())); @@ -158,10 +176,24 @@ bool parsing_should_fail( #else - static constexpr auto run_tests = [](auto&& fn) + static constexpr auto run_tests = [](source_index ex_line, source_index ex_col, auto&& fn) { if (parse_result result = fn(); !result) { + if (ex_line != static_cast(-1) && result.error().source().begin.line != ex_line) + { + FORCE_FAIL("Expected parse_error at line "sv << ex_line + << ", actually occured at line "sv << result.error().source().begin.line + ); + } + + if (ex_col != static_cast(-1) && result.error().source().begin.column != ex_col) + { + FORCE_FAIL("Expected parse_error at column "sv << ex_col + << ", actually occured at column "sv << result.error().source().begin.column + ); + } + SUCCEED("parse_error generated OK"sv); return true; } @@ -169,8 +201,8 @@ bool parsing_should_fail( FORCE_FAIL("Expected parsing failure"sv); }; - return run_tests([=]() { return toml::parse(toml_str); }) - && run_tests([=]() + return run_tests(expected_failure_line, expected_failure_column, [=]() { return toml::parse(toml_str); }) + && run_tests(expected_failure_line, expected_failure_column, [=]() { std::stringstream ss; ss.write(toml_str.data(), static_cast(toml_str.length())); diff --git a/tests/tests.h b/tests/tests.h index 9bd870c..3d7221a 100644 --- a/tests/tests.h +++ b/tests/tests.h @@ -132,7 +132,9 @@ bool parsing_should_succeed( bool parsing_should_fail( std::string_view test_file, uint32_t test_line, - std::string_view toml_str); + std::string_view toml_str, + source_index expected_failure_line = static_cast(-1), + source_index expected_failure_column = static_cast(-1)); template inline bool parse_expected_value( diff --git a/tests/user_feedback.cpp b/tests/user_feedback.cpp index 3fdc147..8223d3c 100644 --- a/tests/user_feedback.cpp +++ b/tests/user_feedback.cpp @@ -176,5 +176,24 @@ b = [] parsing_should_fail(FILE_LINE_ARGS, std::string_view{ s }); } + SECTION("github/issues/112") // https://github.com/marzer/tomlplusplus/issues/112 + { + parsing_should_fail(FILE_LINE_ARGS, R"( + [a.b.c.d] + u = 6 + [a] + b.t = 8 + [a.b] # should cause redefinition error here + u = 0 + )", 6); + + parsing_should_fail(FILE_LINE_ARGS, R"( + [a] + b.t = 8 + [a.b] # should cause redefinition error here + u = 0 + )", 4); + } + } diff --git a/toml.hpp b/toml.hpp index 707d898..37aac0a 100644 --- a/toml.hpp +++ b/toml.hpp @@ -8744,7 +8744,7 @@ TOML_ANON_NAMESPACE_START } template struct parse_integer_traits; - template <> struct parse_integer_traits<2> final + template <> struct parse_integer_traits<2> { static constexpr auto scope_qualifier = "binary integer"sv; static constexpr auto is_digit = ::toml::impl::is_binary_digit; @@ -8753,7 +8753,7 @@ TOML_ANON_NAMESPACE_START static constexpr auto prefix_codepoint = U'b'; static constexpr auto prefix = "b"sv; }; - template <> struct parse_integer_traits<8> final + template <> struct parse_integer_traits<8> { static constexpr auto scope_qualifier = "octal integer"sv; static constexpr auto is_digit = ::toml::impl::is_octal_digit; @@ -8762,14 +8762,14 @@ TOML_ANON_NAMESPACE_START static constexpr auto prefix_codepoint = U'o'; static constexpr auto prefix = "o"sv; }; - template <> struct parse_integer_traits<10> final + template <> struct parse_integer_traits<10> { static constexpr auto scope_qualifier = "decimal integer"sv; static constexpr auto is_digit = ::toml::impl::is_decimal_digit; static constexpr auto is_signed = true; static constexpr auto buffer_length = 19; //strlen("9223372036854775807") }; - template <> struct parse_integer_traits<16> final + template <> struct parse_integer_traits<16> { static constexpr auto scope_qualifier = "hexadecimal integer"sv; static constexpr auto is_digit = ::toml::impl::is_hexadecimal_digit; @@ -8891,7 +8891,7 @@ TOML_ANON_NAMESPACE_START } } - struct error_builder final + struct error_builder { static constexpr std::size_t buf_size = 512; char buf[buf_size]; @@ -8935,7 +8935,7 @@ TOML_ANON_NAMESPACE_START error_builder& operator=(error_builder&&) = delete; }; - struct parse_scope final + struct parse_scope { std::string_view& storage_; std::string_view parent_; @@ -9023,18 +9023,19 @@ TOML_ANON_NAMESPACE_START } }; - struct parsed_key final + struct parsed_key { + toml::source_position position; std::vector segments; }; - struct parsed_key_value_pair final + struct parsed_key_value_pair { parsed_key key; node_ptr value; }; - struct parse_depth_counter final + struct parse_depth_counter { size_t& depth_; @@ -9056,6 +9057,11 @@ TOML_ANON_NAMESPACE_START parse_depth_counter& operator=(parse_depth_counter&&) = delete; }; + struct parsed_string + { + std::string value; + bool was_multi_line; + }; } TOML_ANON_NAMESPACE_END; @@ -9082,8 +9088,8 @@ TOML_IMPL_NAMESPACE_START #if TOML_EXCEPTIONS #define is_error() false #define return_after_error(...) TOML_UNREACHABLE - #define assert_not_error() (void)0 - #define return_if_error(...) (void)0 + #define assert_not_error() static_assert(true) + #define return_if_error(...) static_assert(true) #define return_if_error_or_eof(...) return_if_eof(__VA_ARGS__) #else #define is_error() !!err @@ -9093,6 +9099,25 @@ TOML_IMPL_NAMESPACE_START #define return_if_error_or_eof(...) do { if (is_eof() || is_error()) return __VA_ARGS__; } while(false) #endif + #if defined(TOML_BREAK_AT_PARSE_ERRORS) && TOML_BREAK_AT_PARSE_ERRORS + #if defined(__has_builtin) + #if __has_builtin(__builtin_debugtrap) + #define parse_error_break() __builtin_debugtrap() + #elif __has_builtin(__debugbreak) + #define parse_error_break() __debugbreak() + #endif + #endif + #ifndef parse_error_break + #if TOML_MSVC || TOML_ICC + #define parse_error_break() __debugbreak() + #else + #define parse_error_break() TOML_ASSERT(false) + #endif + #endif + #else + #define parse_error_break() static_assert(true) + #endif + #define set_error_and_return(ret, ...) \ do { if (!is_error()) set_error(__VA_ARGS__); return_after_error(ret); } while(false) @@ -9114,7 +9139,7 @@ TOML_IMPL_NAMESPACE_START TOML_ABI_NAMESPACE_BOOL(TOML_EXCEPTIONS, ex, noex); - class parser final + class parser { private: static constexpr size_t max_nested_values = TOML_MAX_NESTED_VALUES; @@ -9156,6 +9181,8 @@ TOML_IMPL_NAMESPACE_START error_builder builder{ current_scope }; (builder.append(reason), ...); + parse_error_break(); + #if TOML_EXCEPTIONS builder.finish(pos, reader.source_path()); #else @@ -9724,12 +9751,6 @@ TOML_IMPL_NAMESPACE_START set_error_and_return_default("encountered end-of-file"sv); } - struct parsed_string final - { - std::string value; - bool was_multi_line; - }; - [[nodiscard]] TOML_NEVER_INLINE parsed_string parse_string() TOML_MAY_THROW @@ -11118,6 +11139,7 @@ TOML_IMPL_NAMESPACE_START push_parse_scope("key"sv); parsed_key key; + key.position = current_position(); recording_whitespace = false; while (!is_error()) @@ -11219,7 +11241,7 @@ TOML_IMPL_NAMESPACE_START assert_or_assume(*cp == U'['); push_parse_scope("table header"sv); - const auto header_begin_pos = cp->position; + const source_position header_begin_pos = cp->position; source_position header_end_pos; parsed_key key; bool is_arr = false; @@ -11378,7 +11400,7 @@ TOML_IMPL_NAMESPACE_START && !implicit_tables.empty()) { auto tbl = &matching_node->ref_cast
(); - if (auto found = find(implicit_tables, tbl)) + if (auto found = find(implicit_tables, tbl); found && (tbl->empty() || tbl->is_homogeneous
())) { implicit_tables.erase(implicit_tables.cbegin() + (found - implicit_tables.data())); tbl->source_.begin = header_begin_pos; @@ -11389,13 +11411,19 @@ TOML_IMPL_NAMESPACE_START //if we get here it's a redefinition error. if (!is_arr && matching_node->type() == node_type::table) - set_error_and_return_default("cannot redefine existing table '"sv, to_sv(recording_buffer), "'"sv); + { + set_error_at(header_begin_pos, "cannot redefine existing table '"sv, to_sv(recording_buffer), "'"sv); + return_after_error({}); + } else - set_error_and_return_default( + { + set_error_at(header_begin_pos, "cannot redefine existing "sv, to_sv(matching_node->type()), " '"sv, to_sv(recording_buffer), "' as "sv, is_arr ? "array-of-tables"sv : "table"sv ); + return_after_error({}); + } } } @@ -11426,9 +11454,11 @@ TOML_IMPL_NAMESPACE_START dotted_key_tables.push_back(&child->ref_cast
()); child->source_ = kvp.value.get()->source_; } - else if (!child->is_table() - || !(find(dotted_key_tables, &child->ref_cast
()) || find(implicit_tables, &child->ref_cast
()))) - set_error("cannot redefine existing "sv, to_sv(child->type()), " as dotted key-value pair"sv); + else if (!child->is_table() || !( + find(dotted_key_tables, &child->ref_cast
()) + || find(implicit_tables, &child->ref_cast
()) + )) + set_error_at(kvp.key.position, "cannot redefine existing "sv, to_sv(child->type()), " as dotted key-value pair"sv); else child->source_.end = kvp.value.get()->source_.end; @@ -11823,6 +11853,7 @@ TOML_IMPL_NAMESPACE_START #undef advance_and_return_if_error #undef advance_and_return_if_error_or_eof #undef assert_or_assume + #undef parse_error_break } TOML_IMPL_NAMESPACE_END; diff --git a/tools/generate_conformance_tests.py b/tools/generate_conformance_tests.py index 86f46f3..8db5fc7 100644 --- a/tools/generate_conformance_tests.py +++ b/tools/generate_conformance_tests.py @@ -211,8 +211,8 @@ def python_to_tomlpp(node): class TomlTest: - def __init__(self, file_path, is_valid_case): - self.__name = file_path.stem + def __init__(self, file_path, name, is_valid_case): + self.__name = name self.__identifier = sanitize(self.__name) self.__group = self.__identifier.strip('_').split('_')[0] self.__data = utils.read_all_text_from_file(file_path, logger=True).strip() @@ -273,26 +273,28 @@ class TomlTest: def load_tests(source_folder, is_valid_set, ignore_list): source_folder = source_folder.resolve() utils.assert_existing_directory(source_folder) - files = utils.get_all_files(source_folder, all="*.toml") + files = utils.get_all_files(source_folder, all="*.toml", recursive=True) + strip_source_folder_len = len(str(source_folder)) + files = [(f, str(f)[strip_source_folder_len+1:-5].replace('\\', '-').replace('/', '-').strip()) for f in files] if ignore_list: files_ = [] - for f in files: + for f,n in files: ignored = False for ignore in ignore_list: if isinstance(ignore, str): - if f.stem == ignore: + if n == ignore: ignored = True break - elif ignore.fullmatch(f.stem) is not None: # regex + elif ignore.fullmatch(n) is not None: # regex ignored = True break if not ignored: - files_.append(f) + files_.append((f, n)) files = files_ tests = [] - for f in files: + for f,n in files: try: - tests.append(TomlTest(f, is_valid_set)) + tests.append(TomlTest(f, n, is_valid_set)) except Exception as e: print(rf'Error reading {f}, skipping...', file=sys.stderr) return tests @@ -319,13 +321,15 @@ def load_valid_inputs(tests, extern_root): tests['valid']['burntsushi'] = load_tests(Path(extern_root, 'toml-test', 'tests', 'valid'), True, ( # newline/escape handling tests. these get broken by I/O (I test them separately) 'string-escapes', - # causes MSVC to run out of heap space during compilation O_o - 'inline-table-key-dotted', # broken by the json reader 'key-alphanum', - # breaks clang: - 'multiline-string', + # whitespace after trailing slash in raw strings breaks GCC + 'string-multiline' )) + add_condition(tests['valid']['burntsushi'], '!TOML_MSVC', ( + 'inline-table-key-dotted', # causes MSVC to run out of heap space during compilation O_o + )) + tests['valid']['iarna'] = load_tests(Path(extern_root, 'toml-spec-tests', 'values'), True, ( # these are stress-tests for 'large' datasets. I test these separately. Having them inline in C++ code is insane. 'qa-array-inline-1000', @@ -345,7 +349,7 @@ def load_valid_inputs(tests, extern_root): 'spec-date-time-6', 'spec-date-time-local-2', 'spec-time-2', - # breaks gcc: + # whitespace after trailing slash in raw strings breaks GCC 'spec-string-basic-multiline-4', )) @@ -454,12 +458,12 @@ def write_test_file(name, all_tests): expected = test.expected() if isinstance(expected, bool): if expected: - write(f'\tparsing_should_succeed(FILE_LINE_ARGS, {test.identifier()});') + write(f'\tparsing_should_succeed(FILE_LINE_ARGS, {test.identifier()}); // {test.name()}') else: - write(f'\tparsing_should_fail(FILE_LINE_ARGS, {test.identifier()});') + write(f'\tparsing_should_fail(FILE_LINE_ARGS, {test.identifier()}); // {test.name()}') else: s = expected.render('\t\t') - write(f'\tparsing_should_succeed(FILE_LINE_ARGS, {test.identifier()}, [](toml::table&& tbl)') + write(f'\tparsing_should_succeed(FILE_LINE_ARGS, {test.identifier()}, [](toml::table&& tbl) // {test.name()}') write('\t{') write(f'\t\tconst auto expected = {s};') write('\t\tREQUIRE(tbl == expected);')