2020-07-05 15:08:28 +00:00
|
|
|
|
// This file is a part of toml++ and is subject to the the terms of the MIT license.
|
2021-01-02 15:48:47 +00:00
|
|
|
|
// Copyright (c) Mark Gillard <mark.gillard@outlook.com.au>
|
2020-07-05 15:08:28 +00:00
|
|
|
|
// See https://github.com/marzer/tomlplusplus/blob/master/LICENSE for the full license text.
|
|
|
|
|
// SPDX-License-Identifier: MIT
|
|
|
|
|
//-----
|
|
|
|
|
// this file was generated by generate_conformance_tests.py - do not modify it directly
|
|
|
|
|
|
|
|
|
|
#include "tests.h"
|
|
|
|
|
using namespace toml::impl;
|
|
|
|
|
|
2021-04-18 12:04:46 +00:00
|
|
|
|
TOML_DISABLE_WARNINGS; // unused variable spam
|
2020-07-05 15:08:28 +00:00
|
|
|
|
|
|
|
|
|
namespace
|
|
|
|
|
{
|
2021-09-04 09:24:47 +00:00
|
|
|
|
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;
|
2021-06-24 18:08:45 +00:00
|
|
|
|
static constexpr auto array_bool = R"(a = [true, false])"sv;
|
2020-07-05 15:08:28 +00:00
|
|
|
|
static constexpr auto array_empty = R"(thevoid = [[[[[]]]]])"sv;
|
2021-06-24 18:08:45 +00:00
|
|
|
|
static constexpr auto array_hetergeneous = R"(mixed = [[1, 2], ["a", "b"], [1.1, 2.1]])"sv;
|
2021-07-04 10:58:33 +00:00
|
|
|
|
static constexpr auto array_mixed_int_array = R"(arrays-and-ints = [1, ["Arrays are not integers."]])"sv;
|
|
|
|
|
static constexpr auto array_mixed_int_float = R"(ints-and-floats = [1, 1.1])"sv;
|
|
|
|
|
static constexpr auto array_mixed_int_string = R"(strings-and-ints = ["hi", 42])"sv;
|
|
|
|
|
static constexpr auto array_mixed_string_table = R"(contributors = [
|
2021-06-24 18:08:45 +00:00
|
|
|
|
"Foo Bar <foo@example.com>",
|
|
|
|
|
{ name = "Baz Qux", email = "bazqux@example.com", url = "https://example.com/bazqux" }
|
2021-07-04 10:58:33 +00:00
|
|
|
|
])"sv;
|
|
|
|
|
static constexpr auto array_nested_double = R"(nest = [
|
|
|
|
|
[
|
|
|
|
|
["a"],
|
|
|
|
|
[1, 2, [3]]
|
|
|
|
|
]
|
2021-06-24 18:08:45 +00:00
|
|
|
|
])"sv;
|
|
|
|
|
static constexpr auto array_nested_inline_table = R"(a = [ { b = {} } ])"sv;
|
|
|
|
|
static constexpr auto array_nested = R"(nest = [["a"], ["b"]])"sv;
|
2020-07-05 15:08:28 +00:00
|
|
|
|
static constexpr auto array_nospaces = R"(ints = [1,2,3])"sv;
|
|
|
|
|
static constexpr auto array_string_quote_comma_2 = R"(title = [ " \", ",])"sv;
|
|
|
|
|
static constexpr auto array_string_quote_comma = R"(title = [
|
|
|
|
|
"Client: \"XXXX\", Job: XXXX",
|
|
|
|
|
"Code: XXXX"
|
|
|
|
|
])"sv;
|
|
|
|
|
static constexpr auto array_string_with_comma = R"(title = [
|
|
|
|
|
"Client: XXXX, Job: XXXX",
|
|
|
|
|
"Code: XXXX"
|
|
|
|
|
])"sv;
|
2021-06-24 18:08:45 +00:00
|
|
|
|
static constexpr auto array_strings = R"(string_array = [ "all", 'strings', """are the same""", '''type'''])"sv;
|
2020-07-05 15:08:28 +00:00
|
|
|
|
static constexpr auto array_table_array_string_backslash = R"(foo = [ { bar="\"{{baz}}\""} ])"sv;
|
2021-06-24 18:08:45 +00:00
|
|
|
|
|
2021-09-04 09:24:47 +00:00
|
|
|
|
static constexpr auto bool_bool = R"(t = true
|
2020-07-05 15:08:28 +00:00
|
|
|
|
f = false)"sv;
|
2021-06-24 18:08:45 +00:00
|
|
|
|
|
|
|
|
|
static constexpr auto comment_at_eof = R"(# This is a full-line comment
|
2020-07-05 15:08:28 +00:00
|
|
|
|
key = "value" # This is a comment at the end of a line)"sv;
|
2021-06-24 18:08:45 +00:00
|
|
|
|
static constexpr auto comment_at_eof2 = R"(# This is a full-line comment
|
2020-07-05 15:08:28 +00:00
|
|
|
|
key = "value" # This is a comment at the end of a line)"sv;
|
2021-06-24 18:08:45 +00:00
|
|
|
|
static constexpr auto comment_everywhere = R"(# Top comment.
|
2020-07-05 15:08:28 +00:00
|
|
|
|
# Top comment.
|
|
|
|
|
# Top comment.
|
|
|
|
|
|
|
|
|
|
# [no-extraneous-groups-please]
|
|
|
|
|
|
|
|
|
|
[group] # Comment
|
|
|
|
|
answer = 42 # Comment
|
|
|
|
|
# no-extraneous-keys-please = 999
|
|
|
|
|
# Inbetween comment.
|
|
|
|
|
more = [ # Comment
|
|
|
|
|
# What about multiple # comments?
|
|
|
|
|
# Can you handle it?
|
|
|
|
|
#
|
|
|
|
|
# Evil.
|
|
|
|
|
# Evil.
|
|
|
|
|
42, 42, # Comments within arrays are fun.
|
|
|
|
|
# What about multiple # comments?
|
|
|
|
|
# Can you handle it?
|
|
|
|
|
#
|
|
|
|
|
# Evil.
|
|
|
|
|
# Evil.
|
|
|
|
|
# ] Did I fool you?
|
2021-09-04 09:24:47 +00:00
|
|
|
|
] # Hopefully not.
|
|
|
|
|
|
|
|
|
|
# Make sure the space between the datetime and "#" isn't lexed.
|
|
|
|
|
d = 1979-05-27T07:32:12-07:00 # c)"sv;
|
2021-06-24 18:08:45 +00:00
|
|
|
|
static constexpr auto comment_tricky = R"([section]#attached comment
|
|
|
|
|
#[notsection]
|
|
|
|
|
one = "11"#cmt
|
|
|
|
|
two = "22#"
|
|
|
|
|
three = '#'
|
|
|
|
|
|
|
|
|
|
four = """# no comment
|
|
|
|
|
# nor this
|
|
|
|
|
#also not comment"""#is_comment
|
|
|
|
|
|
|
|
|
|
five = 5.5#66
|
|
|
|
|
six = 6#7
|
|
|
|
|
8 = "eight"
|
|
|
|
|
#nine = 99
|
|
|
|
|
ten = 10e2#1
|
|
|
|
|
eleven = 1.11e1#23
|
|
|
|
|
|
|
|
|
|
["hash#tag"]
|
|
|
|
|
"#!" = "hash bang"
|
|
|
|
|
arr3 = [ "#", '#', """###""" ]
|
|
|
|
|
arr4 = [ 1,# 9, 9,
|
|
|
|
|
2#,9
|
|
|
|
|
,#9
|
|
|
|
|
3#]
|
|
|
|
|
,4]
|
|
|
|
|
arr5 = [[[[#["#"],
|
|
|
|
|
["#"]]]]#]
|
|
|
|
|
]
|
|
|
|
|
tbl1 = { "#" = '}#'}#}})"sv;
|
|
|
|
|
|
2021-09-04 09:24:47 +00:00
|
|
|
|
static constexpr auto datetime_datetime = R"(space = 1987-07-05 17:45:00Z
|
|
|
|
|
lower = 1987-07-05t17:45:00z)"sv;
|
2021-06-24 18:08:45 +00:00
|
|
|
|
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;
|
2021-09-04 09:24:47 +00:00
|
|
|
|
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;
|
2021-06-24 18:08:45 +00:00
|
|
|
|
|
|
|
|
|
static constexpr auto empty_file = R"()"sv;
|
|
|
|
|
|
2020-07-05 15:08:28 +00:00
|
|
|
|
static constexpr auto example = R"(best-day-ever = 1987-07-05T17:45:00Z
|
|
|
|
|
|
|
|
|
|
[numtheory]
|
|
|
|
|
boring = false
|
|
|
|
|
perfection = [6, 28, 496])"sv;
|
2021-06-24 18:08:45 +00:00
|
|
|
|
|
2020-07-05 15:08:28 +00:00
|
|
|
|
static constexpr auto float_exponent = R"(lower = 3e2
|
|
|
|
|
upper = 3E2
|
|
|
|
|
neg = 3e-2
|
|
|
|
|
pos = 3E+2
|
|
|
|
|
zero = 3e0
|
|
|
|
|
pointlower = 3.1e2
|
2021-06-24 18:08:45 +00:00
|
|
|
|
pointupper = 3.1E2
|
|
|
|
|
minustenth = -1E-1)"sv;
|
2021-09-04 09:24:47 +00:00
|
|
|
|
static constexpr auto float_float = R"(pi = 3.14
|
|
|
|
|
pospi = +3.14
|
|
|
|
|
negpi = -3.14
|
|
|
|
|
zero-intpart = 0.123)"sv;
|
2021-06-24 18:08:45 +00:00
|
|
|
|
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
|
|
|
|
|
nan_neg = -nan
|
|
|
|
|
nan_plus = +nan
|
|
|
|
|
infinity = inf
|
|
|
|
|
infinity_neg = -inf
|
|
|
|
|
infinity_plus = +inf)"sv;
|
|
|
|
|
static constexpr auto float_long = R"(longpi = 3.141592653589793
|
|
|
|
|
neglongpi = -3.141592653589793)"sv;
|
2020-07-05 15:08:28 +00:00
|
|
|
|
static constexpr auto float_underscore = R"(before = 3_141.5927
|
|
|
|
|
after = 3141.592_7
|
|
|
|
|
exponent = 3e1_4)"sv;
|
2021-06-24 18:08:45 +00:00
|
|
|
|
static constexpr auto float_zero = R"(f1 = 0.0
|
|
|
|
|
f2 = +0.0
|
|
|
|
|
f3 = -0.0
|
|
|
|
|
f4 = 0e0
|
|
|
|
|
f5 = 0e00
|
|
|
|
|
f6 = +0e0
|
|
|
|
|
f7 = -0e0)"sv;
|
|
|
|
|
|
2020-07-05 15:08:28 +00:00
|
|
|
|
static constexpr auto implicit_and_explicit_after = R"([a.b.c]
|
|
|
|
|
answer = 42
|
|
|
|
|
|
|
|
|
|
[a]
|
|
|
|
|
better = 43)"sv;
|
|
|
|
|
static constexpr auto implicit_and_explicit_before = R"([a]
|
|
|
|
|
better = 43
|
|
|
|
|
|
|
|
|
|
[a.b.c]
|
|
|
|
|
answer = 42)"sv;
|
|
|
|
|
static constexpr auto implicit_groups = R"([a.b.c]
|
|
|
|
|
answer = 42)"sv;
|
2021-06-24 18:08:45 +00:00
|
|
|
|
|
2020-07-05 15:08:28 +00:00
|
|
|
|
static constexpr auto inline_table_array = R"(people = [{first_name = "Bruce", last_name = "Springsteen"},
|
|
|
|
|
{first_name = "Eric", last_name = "Clapton"},
|
|
|
|
|
{first_name = "Bob", last_name = "Seger"}])"sv;
|
2021-06-24 18:08:45 +00:00
|
|
|
|
static constexpr auto inline_table_bool = R"(a = {a = true, b = false})"sv;
|
|
|
|
|
static constexpr auto inline_table_empty = R"(empty1 = {}
|
|
|
|
|
empty2 = { }
|
|
|
|
|
empty_in_array = [ { not_empty = 1 }, {} ]
|
|
|
|
|
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;
|
2021-09-04 09:24:47 +00:00
|
|
|
|
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;
|
2021-06-24 18:08:45 +00:00
|
|
|
|
static constexpr auto inline_table_multiline = R"(tbl_multiline = { a = 1, b = """
|
|
|
|
|
multiline
|
|
|
|
|
""", c = """and yet
|
|
|
|
|
another line""", d = 4 })"sv;
|
|
|
|
|
static constexpr auto inline_table_nest = R"(tbl_tbl_empty = { tbl_0 = {} }
|
|
|
|
|
tbl_tbl_val = { tbl_1 = { one = 1 } }
|
|
|
|
|
tbl_arr_tbl = { arr_tbl = [ { one = 1 } ] }
|
|
|
|
|
arr_tbl_tbl = [ { tbl = { one = 1 } } ]
|
|
|
|
|
|
|
|
|
|
# Array-of-array-of-table is interesting because it can only
|
|
|
|
|
# be represented in inline form.
|
|
|
|
|
arr_arr_tbl_empty = [ [ {} ] ]
|
|
|
|
|
arr_arr_tbl_val = [ [ { one = 1 } ] ]
|
|
|
|
|
arr_arr_tbls = [ [ { one = 1 }, { two = 2 } ] ])"sv;
|
|
|
|
|
|
2021-09-04 09:24:47 +00:00
|
|
|
|
#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;
|
2021-06-24 18:08:45 +00:00
|
|
|
|
static constexpr auto integer_literals = R"(bin1 = 0b11010110
|
|
|
|
|
bin2 = 0b1_0_1
|
|
|
|
|
|
|
|
|
|
oct1 = 0o01234567
|
|
|
|
|
oct2 = 0o755
|
|
|
|
|
oct3 = 0o7_6_5
|
|
|
|
|
|
|
|
|
|
hex1 = 0xDEADBEEF
|
|
|
|
|
hex2 = 0xdeadbeef
|
|
|
|
|
hex3 = 0xdead_beef
|
|
|
|
|
hex4 = 0x00987)"sv;
|
|
|
|
|
static constexpr auto integer_long = R"(int64-max = 9223372036854775807
|
|
|
|
|
int64-max-neg = -9223372036854775808)"sv;
|
|
|
|
|
static constexpr auto integer_underscore = R"(kilo = 1_000
|
|
|
|
|
x = 1_1_1_1)"sv;
|
|
|
|
|
static constexpr auto integer_zero = R"(d1 = 0
|
|
|
|
|
d2 = +0
|
|
|
|
|
d3 = -0
|
|
|
|
|
|
|
|
|
|
h1 = 0x0
|
|
|
|
|
h2 = 0x00
|
|
|
|
|
h3 = 0x00000
|
|
|
|
|
|
|
|
|
|
o1 = 0o0
|
|
|
|
|
a2 = 0o00
|
|
|
|
|
a3 = 0o00000
|
|
|
|
|
|
|
|
|
|
b1 = 0b0
|
|
|
|
|
b2 = 0b00
|
|
|
|
|
b3 = 0b00000)"sv;
|
|
|
|
|
|
|
|
|
|
#if UNICODE_LITERALS_OK
|
|
|
|
|
|
|
|
|
|
static constexpr auto key_case_sensitive = R"(sectioN = "NN"
|
|
|
|
|
|
|
|
|
|
[section]
|
|
|
|
|
name = "lower"
|
|
|
|
|
NAME = "upper"
|
|
|
|
|
Name = "capitalized"
|
|
|
|
|
|
|
|
|
|
[Section]
|
|
|
|
|
name = "different section!!"
|
|
|
|
|
"μ" = "greek small letter mu"
|
|
|
|
|
"Μ" = "greek capital letter MU"
|
|
|
|
|
M = "latin letter M")"sv;
|
|
|
|
|
static constexpr auto key_escapes = R"("\n" = "newline"
|
|
|
|
|
"\u00c0" = "latin capital letter A with grave"
|
|
|
|
|
"\"" = "just a quote"
|
|
|
|
|
|
|
|
|
|
["backsp\b\b"]
|
|
|
|
|
|
|
|
|
|
["\"quoted\""]
|
|
|
|
|
quote = true
|
|
|
|
|
|
|
|
|
|
["a.b"."\u00c0"])"sv;
|
|
|
|
|
|
|
|
|
|
#endif // UNICODE_LITERALS_OK
|
|
|
|
|
|
|
|
|
|
static constexpr auto key_dotted = R"(# Note: this file contains literal tab characters.
|
|
|
|
|
|
|
|
|
|
name.first = "Arthur"
|
|
|
|
|
"name".'last' = "Dent"
|
|
|
|
|
|
|
|
|
|
many.dots.here.dot.dot.dot = 42
|
|
|
|
|
|
|
|
|
|
# Space are ignored, and key parts can be quoted.
|
|
|
|
|
count.a = 1
|
|
|
|
|
count . b = 2
|
|
|
|
|
"count"."c" = 3
|
|
|
|
|
"count" . "d" = 4
|
|
|
|
|
'count'.'e' = 5
|
|
|
|
|
'count' . 'f' = 6
|
|
|
|
|
"count".'g' = 7
|
|
|
|
|
"count" . 'h' = 8
|
|
|
|
|
count.'i' = 9
|
|
|
|
|
count . 'j' = 10
|
|
|
|
|
"count".k = 11
|
|
|
|
|
"count" . l = 12
|
|
|
|
|
|
|
|
|
|
[tbl]
|
|
|
|
|
a.b.c = 42.666
|
|
|
|
|
|
|
|
|
|
[a.few.dots]
|
|
|
|
|
polka.dot = "again?"
|
|
|
|
|
polka.dance-with = "Dot"
|
|
|
|
|
|
|
|
|
|
[[arr]]
|
|
|
|
|
a.b.c=1
|
|
|
|
|
a.b.d=2
|
|
|
|
|
|
|
|
|
|
[[arr]]
|
|
|
|
|
a.b.c=3
|
|
|
|
|
a.b.d=4)"sv;
|
|
|
|
|
static constexpr auto key_empty = R"("" = "blank")"sv;
|
2020-07-05 15:08:28 +00:00
|
|
|
|
static constexpr auto key_equals_nospace = R"(answer=42)"sv;
|
2021-09-04 09:24:47 +00:00
|
|
|
|
static constexpr auto key_numeric_dotted = R"(1.2 = 3)"sv;
|
2020-07-05 15:08:28 +00:00
|
|
|
|
static constexpr auto key_numeric = R"(1 = 1)"sv;
|
2021-06-24 18:08:45 +00:00
|
|
|
|
static constexpr auto key_quoted_dots = R"(plain = 1
|
2020-07-05 15:08:28 +00:00
|
|
|
|
"with.dot" = 2
|
|
|
|
|
|
|
|
|
|
[plain_table]
|
|
|
|
|
plain = 3
|
|
|
|
|
"with.dot" = 4
|
|
|
|
|
|
|
|
|
|
[table.withdot]
|
|
|
|
|
plain = 5
|
|
|
|
|
"key.with.dots" = 6)"sv;
|
2021-06-24 18:08:45 +00:00
|
|
|
|
static constexpr auto key_space = R"("a b" = 1)"sv;
|
|
|
|
|
static constexpr auto key_special_chars = R"("~!@$^&*()_+-`1234567890[]|/?><.,;:'" = 1)"sv;
|
|
|
|
|
static constexpr auto key_special_word = R"(false = false
|
|
|
|
|
true = 1
|
|
|
|
|
inf = 100000000
|
|
|
|
|
nan = "ceci n'est pas un nombre")"sv;
|
|
|
|
|
|
2020-07-05 15:08:28 +00:00
|
|
|
|
static constexpr auto newline_crlf = R"(os = "DOS"
|
|
|
|
|
newline = "crlf")"sv;
|
|
|
|
|
static constexpr auto newline_lf = R"(os = "unix"
|
|
|
|
|
newline = "lf")"sv;
|
2021-06-24 18:08:45 +00:00
|
|
|
|
|
|
|
|
|
static constexpr auto spec_example_1_compact = R"(#Useless spaces eliminated.
|
|
|
|
|
title="TOML Example"
|
|
|
|
|
[owner]
|
|
|
|
|
name="Lance Uppercut"
|
|
|
|
|
dob=1979-05-27T07:32:00-08:00#First class dates
|
|
|
|
|
[database]
|
|
|
|
|
server="192.168.1.1"
|
|
|
|
|
ports=[8001,8001,8002]
|
|
|
|
|
connection_max=5000
|
|
|
|
|
enabled=true
|
|
|
|
|
[servers]
|
|
|
|
|
[servers.alpha]
|
|
|
|
|
ip="10.0.0.1"
|
|
|
|
|
dc="eqdc10"
|
|
|
|
|
[servers.beta]
|
|
|
|
|
ip="10.0.0.2"
|
|
|
|
|
dc="eqdc10"
|
|
|
|
|
[clients]
|
|
|
|
|
data=[["gamma","delta"],[1,2]]
|
|
|
|
|
hosts=[
|
|
|
|
|
"alpha",
|
|
|
|
|
"omega"
|
|
|
|
|
])"sv;
|
|
|
|
|
static constexpr auto spec_example_1 = R"(# This is a TOML document. Boom.
|
|
|
|
|
|
|
|
|
|
title = "TOML Example"
|
|
|
|
|
|
|
|
|
|
[owner]
|
|
|
|
|
name = "Lance Uppercut"
|
|
|
|
|
dob = 1979-05-27T07:32:00-08:00 # First class dates? Why not?
|
|
|
|
|
|
|
|
|
|
[database]
|
|
|
|
|
server = "192.168.1.1"
|
|
|
|
|
ports = [ 8001, 8001, 8002 ]
|
|
|
|
|
connection_max = 5000
|
|
|
|
|
enabled = true
|
|
|
|
|
|
|
|
|
|
[servers]
|
|
|
|
|
|
|
|
|
|
# You can indent as you please. Tabs or spaces. TOML don't care.
|
|
|
|
|
[servers.alpha]
|
|
|
|
|
ip = "10.0.0.1"
|
|
|
|
|
dc = "eqdc10"
|
|
|
|
|
|
|
|
|
|
[servers.beta]
|
|
|
|
|
ip = "10.0.0.2"
|
|
|
|
|
dc = "eqdc10"
|
|
|
|
|
|
|
|
|
|
[clients]
|
|
|
|
|
data = [ ["gamma", "delta"], [1, 2] ]
|
|
|
|
|
|
|
|
|
|
# Line breaks are OK when inside arrays
|
|
|
|
|
hosts = [
|
|
|
|
|
"alpha",
|
|
|
|
|
"omega"
|
|
|
|
|
])"sv;
|
|
|
|
|
|
|
|
|
|
static constexpr auto string_double_quote_escape = R"(test = "\"one\"")"sv;
|
2020-07-05 15:08:28 +00:00
|
|
|
|
static constexpr auto string_empty = R"(answer = "")"sv;
|
2021-06-24 18:08:45 +00:00
|
|
|
|
static constexpr auto string_escaped_escape = R"(answer = "\\x64")"sv;
|
2021-09-04 09:24:47 +00:00
|
|
|
|
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;
|
2021-09-07 17:02:00 +00:00
|
|
|
|
static constexpr auto string_multiline = R"(# NOTE: this file includes some literal tab characters.
|
|
|
|
|
|
|
|
|
|
multiline_empty_one = """"""
|
|
|
|
|
multiline_empty_two = """
|
|
|
|
|
"""
|
|
|
|
|
multiline_empty_three = """\
|
|
|
|
|
"""
|
|
|
|
|
multiline_empty_four = """\
|
|
|
|
|
\
|
|
|
|
|
\
|
|
|
|
|
"""
|
|
|
|
|
|
|
|
|
|
equivalent_one = "The quick brown fox jumps over the lazy dog."
|
|
|
|
|
equivalent_two = """
|
|
|
|
|
The quick brown \
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
fox jumps over \
|
|
|
|
|
the lazy dog."""
|
|
|
|
|
|
|
|
|
|
equivalent_three = """\
|
|
|
|
|
The quick brown \
|
|
|
|
|
fox jumps over \
|
|
|
|
|
the lazy dog.\
|
|
|
|
|
"""
|
|
|
|
|
|
|
|
|
|
whitespace-after-bs = """\
|
|
|
|
|
The quick brown \
|
|
|
|
|
fox jumps over \
|
|
|
|
|
the lazy dog.\
|
|
|
|
|
"""
|
|
|
|
|
|
|
|
|
|
no-space = """a\
|
|
|
|
|
b"""
|
|
|
|
|
|
|
|
|
|
keep-ws-before = """a \
|
|
|
|
|
b"""
|
|
|
|
|
|
|
|
|
|
escape-bs-1 = """a \\
|
|
|
|
|
b"""
|
|
|
|
|
|
|
|
|
|
escape-bs-2 = """a \\\
|
|
|
|
|
b"""
|
|
|
|
|
|
|
|
|
|
escape-bs-3 = """a \\\\
|
|
|
|
|
b""")"sv;
|
2020-07-05 15:08:28 +00:00
|
|
|
|
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;
|
2021-09-04 09:24:47 +00:00
|
|
|
|
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;
|
2020-07-05 15:08:28 +00:00
|
|
|
|
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;
|
2021-06-24 18:08:45 +00:00
|
|
|
|
|
|
|
|
|
#if UNICODE_LITERALS_OK
|
|
|
|
|
|
|
|
|
|
static constexpr auto string_escape_tricky = R"(end_esc = "String does not end here\" but ends here\\"
|
|
|
|
|
lit_end_esc = 'String ends here\'
|
|
|
|
|
|
|
|
|
|
multiline_unicode = """
|
|
|
|
|
\u00a0"""
|
|
|
|
|
|
|
|
|
|
multiline_not_unicode = """
|
|
|
|
|
\\u0041"""
|
|
|
|
|
|
|
|
|
|
multiline_end_esc = """When will it end? \"""...""\" should be here\""""
|
|
|
|
|
|
|
|
|
|
lit_multiline_not_unicode = '''
|
|
|
|
|
\u007f'''
|
|
|
|
|
|
|
|
|
|
lit_multiline_end = '''There is no escape\''')"sv;
|
|
|
|
|
static constexpr auto string_unicode_escape = R"(answer4 = "\u03B4"
|
|
|
|
|
answer8 = "\U000003B4")"sv;
|
|
|
|
|
static constexpr auto string_unicode_literal = R"(answer = "δ")"sv;
|
|
|
|
|
|
|
|
|
|
#endif // UNICODE_LITERALS_OK
|
|
|
|
|
|
2020-07-05 15:08:28 +00:00
|
|
|
|
static constexpr auto table_array_implicit = R"([[albums.songs]]
|
|
|
|
|
name = "Glory Days")"sv;
|
|
|
|
|
static constexpr auto table_array_many = R"([[people]]
|
|
|
|
|
first_name = "Bruce"
|
|
|
|
|
last_name = "Springsteen"
|
|
|
|
|
|
|
|
|
|
[[people]]
|
|
|
|
|
first_name = "Eric"
|
|
|
|
|
last_name = "Clapton"
|
|
|
|
|
|
|
|
|
|
[[people]]
|
|
|
|
|
first_name = "Bob"
|
|
|
|
|
last_name = "Seger")"sv;
|
|
|
|
|
static constexpr auto table_array_nest = R"([[albums]]
|
|
|
|
|
name = "Born to Run"
|
|
|
|
|
|
|
|
|
|
[[albums.songs]]
|
|
|
|
|
name = "Jungleland"
|
|
|
|
|
|
|
|
|
|
[[albums.songs]]
|
|
|
|
|
name = "Meeting Across the River"
|
|
|
|
|
|
|
|
|
|
[[albums]]
|
|
|
|
|
name = "Born in the USA"
|
|
|
|
|
|
|
|
|
|
[[albums.songs]]
|
|
|
|
|
name = "Glory Days"
|
|
|
|
|
|
|
|
|
|
[[albums.songs]]
|
|
|
|
|
name = "Dancing in the Dark")"sv;
|
|
|
|
|
static constexpr auto table_array_one = R"([[people]]
|
|
|
|
|
first_name = "Bruce"
|
|
|
|
|
last_name = "Springsteen")"sv;
|
|
|
|
|
static constexpr auto table_array_table_array = R"([[a]]
|
|
|
|
|
[[a.b]]
|
|
|
|
|
[a.b.c]
|
|
|
|
|
d = "val0"
|
|
|
|
|
[[a.b]]
|
|
|
|
|
[a.b.c]
|
|
|
|
|
d = "val1")"sv;
|
|
|
|
|
static constexpr auto table_empty = R"([a])"sv;
|
2021-09-04 09:24:47 +00:00
|
|
|
|
static constexpr auto table_keyword = R"([true]
|
|
|
|
|
|
|
|
|
|
[false]
|
|
|
|
|
|
|
|
|
|
[inf]
|
|
|
|
|
|
|
|
|
|
[nan])"sv;
|
2020-07-05 15:08:28 +00:00
|
|
|
|
static constexpr auto table_no_eol = R"([table])"sv;
|
|
|
|
|
static constexpr auto table_sub_empty = R"([a]
|
|
|
|
|
[a.b])"sv;
|
|
|
|
|
static constexpr auto table_whitespace = R"(["valid key"])"sv;
|
|
|
|
|
static constexpr auto table_with_literal_string = R"(['a']
|
|
|
|
|
[a.'"b"']
|
|
|
|
|
[a.'"b"'.c]
|
|
|
|
|
answer = 42)"sv;
|
|
|
|
|
static constexpr auto table_with_pound = R"(["key#group"]
|
|
|
|
|
answer = 42)"sv;
|
|
|
|
|
static constexpr auto table_with_single_quotes = R"(['a']
|
|
|
|
|
[a.'b']
|
|
|
|
|
[a.'b'.c]
|
|
|
|
|
answer = 42)"sv;
|
2020-10-09 05:50:15 +00:00
|
|
|
|
static constexpr auto table_without_super = R"(# [x] you
|
|
|
|
|
# [x.y] don't
|
|
|
|
|
# [x.y.z] need these
|
|
|
|
|
[x.y.z.w] # for this to work
|
|
|
|
|
[x] # defining a super-table afterwards is ok)"sv;
|
2021-06-24 18:08:45 +00:00
|
|
|
|
|
|
|
|
|
#if UNICODE_LITERALS_OK
|
|
|
|
|
|
|
|
|
|
static constexpr auto table_names = R"([a.b.c]
|
|
|
|
|
[a."b.c"]
|
|
|
|
|
[a.'d.e']
|
|
|
|
|
[a.' x ']
|
|
|
|
|
[ d.e.f ]
|
|
|
|
|
[ g . h . i ]
|
2021-09-04 09:24:47 +00:00
|
|
|
|
[ j . "ʞ" . 'l' ]
|
|
|
|
|
|
|
|
|
|
[x.1.2])"sv;
|
2021-06-24 18:08:45 +00:00
|
|
|
|
|
|
|
|
|
#endif // UNICODE_LITERALS_OK
|
2020-07-05 15:08:28 +00:00
|
|
|
|
}
|
|
|
|
|
|
2021-04-18 12:04:46 +00:00
|
|
|
|
TOML_ENABLE_WARNINGS;
|
2020-07-05 15:08:28 +00:00
|
|
|
|
|
|
|
|
|
TEST_CASE("conformance - burntsushi/valid")
|
|
|
|
|
{
|
2021-09-04 09:24:47 +00:00
|
|
|
|
parsing_should_succeed(FILE_LINE_ARGS, array_array, [](toml::table&& tbl) // array-array
|
|
|
|
|
{
|
|
|
|
|
const auto expected = toml::table{{
|
|
|
|
|
{
|
|
|
|
|
R"(comments)"sv, toml::array{
|
|
|
|
|
1,
|
|
|
|
|
2,
|
|
|
|
|
}
|
|
|
|
|
},
|
|
|
|
|
{
|
|
|
|
|
R"(dates)"sv, toml::array{
|
|
|
|
|
toml::date_time{ { 1987, 7, 5 }, { 17, 45, 0, 0u }, { 0, 0 } },
|
|
|
|
|
toml::date_time{ { 1979, 5, 27 }, { 7, 32, 0, 0u }, { 0, 0 } },
|
|
|
|
|
toml::date_time{ { 2006, 6, 1 }, { 11, 0, 0, 0u }, { 0, 0 } },
|
|
|
|
|
}
|
|
|
|
|
},
|
|
|
|
|
{
|
|
|
|
|
R"(floats)"sv, toml::array{
|
|
|
|
|
1.1,
|
|
|
|
|
2.1,
|
|
|
|
|
3.1,
|
|
|
|
|
}
|
|
|
|
|
},
|
|
|
|
|
{
|
|
|
|
|
R"(ints)"sv, toml::array{
|
|
|
|
|
1,
|
|
|
|
|
2,
|
|
|
|
|
3,
|
|
|
|
|
}
|
|
|
|
|
},
|
|
|
|
|
{
|
|
|
|
|
R"(strings)"sv, toml::array{
|
|
|
|
|
R"(a)"sv,
|
|
|
|
|
R"(b)"sv,
|
|
|
|
|
R"(c)"sv,
|
|
|
|
|
}
|
|
|
|
|
},
|
|
|
|
|
}};
|
|
|
|
|
REQUIRE(tbl == expected);
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
parsing_should_succeed(FILE_LINE_ARGS, array_bool, [](toml::table&& tbl) // array-bool
|
2021-06-24 18:08:45 +00:00
|
|
|
|
{
|
|
|
|
|
const auto expected = toml::table{{
|
|
|
|
|
{
|
|
|
|
|
R"(a)"sv, toml::array{
|
|
|
|
|
true,
|
|
|
|
|
false,
|
|
|
|
|
}
|
|
|
|
|
},
|
|
|
|
|
}};
|
|
|
|
|
REQUIRE(tbl == expected);
|
|
|
|
|
});
|
|
|
|
|
|
2021-09-04 09:24:47 +00:00
|
|
|
|
parsing_should_succeed(FILE_LINE_ARGS, array_empty, [](toml::table&& tbl) // array-empty
|
2020-07-05 15:08:28 +00:00
|
|
|
|
{
|
2021-06-24 18:08:45 +00:00
|
|
|
|
const auto expected = toml::table{{
|
2020-07-05 15:08:28 +00:00
|
|
|
|
{
|
2020-07-18 12:10:19 +00:00
|
|
|
|
R"(thevoid)"sv, toml::array{
|
2020-07-05 15:08:28 +00:00
|
|
|
|
toml::inserter{toml::array{
|
|
|
|
|
toml::inserter{toml::array{
|
|
|
|
|
toml::inserter{toml::array{
|
|
|
|
|
toml::inserter{toml::array{}},
|
|
|
|
|
}},
|
|
|
|
|
}},
|
|
|
|
|
}},
|
|
|
|
|
}
|
|
|
|
|
},
|
|
|
|
|
}};
|
|
|
|
|
REQUIRE(tbl == expected);
|
|
|
|
|
});
|
|
|
|
|
|
2021-09-04 09:24:47 +00:00
|
|
|
|
parsing_should_succeed(FILE_LINE_ARGS, array_hetergeneous, [](toml::table&& tbl) // array-hetergeneous
|
2021-06-24 18:08:45 +00:00
|
|
|
|
{
|
|
|
|
|
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);
|
|
|
|
|
});
|
|
|
|
|
|
2021-09-04 09:24:47 +00:00
|
|
|
|
parsing_should_succeed(FILE_LINE_ARGS, array_mixed_int_array, [](toml::table&& tbl) // array-mixed-int-array
|
2021-07-04 10:58:33 +00:00
|
|
|
|
{
|
|
|
|
|
const auto expected = toml::table{{
|
|
|
|
|
{
|
|
|
|
|
R"(arrays-and-ints)"sv, toml::array{
|
|
|
|
|
1,
|
|
|
|
|
toml::array{
|
|
|
|
|
R"(Arrays are not integers.)"sv,
|
|
|
|
|
},
|
|
|
|
|
}
|
|
|
|
|
},
|
|
|
|
|
}};
|
|
|
|
|
REQUIRE(tbl == expected);
|
|
|
|
|
});
|
|
|
|
|
|
2021-09-04 09:24:47 +00:00
|
|
|
|
parsing_should_succeed(FILE_LINE_ARGS, array_mixed_int_float, [](toml::table&& tbl) // array-mixed-int-float
|
2021-07-04 10:58:33 +00:00
|
|
|
|
{
|
|
|
|
|
const auto expected = toml::table{{
|
|
|
|
|
{
|
|
|
|
|
R"(ints-and-floats)"sv, toml::array{
|
|
|
|
|
1,
|
|
|
|
|
1.1,
|
|
|
|
|
}
|
|
|
|
|
},
|
|
|
|
|
}};
|
|
|
|
|
REQUIRE(tbl == expected);
|
|
|
|
|
});
|
|
|
|
|
|
2021-09-04 09:24:47 +00:00
|
|
|
|
parsing_should_succeed(FILE_LINE_ARGS, array_mixed_int_string, [](toml::table&& tbl) // array-mixed-int-string
|
2021-07-04 10:58:33 +00:00
|
|
|
|
{
|
|
|
|
|
const auto expected = toml::table{{
|
|
|
|
|
{
|
|
|
|
|
R"(strings-and-ints)"sv, toml::array{
|
|
|
|
|
R"(hi)"sv,
|
|
|
|
|
42,
|
|
|
|
|
}
|
|
|
|
|
},
|
|
|
|
|
}};
|
|
|
|
|
REQUIRE(tbl == expected);
|
|
|
|
|
});
|
|
|
|
|
|
2021-09-04 09:24:47 +00:00
|
|
|
|
parsing_should_succeed(FILE_LINE_ARGS, array_mixed_string_table, [](toml::table&& tbl) // array-mixed-string-table
|
2021-06-24 18:08:45 +00:00
|
|
|
|
{
|
|
|
|
|
const auto expected = toml::table{{
|
|
|
|
|
{
|
|
|
|
|
R"(contributors)"sv, toml::array{
|
|
|
|
|
R"(Foo Bar <foo@example.com>)"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 },
|
|
|
|
|
}},
|
|
|
|
|
}
|
|
|
|
|
},
|
2021-07-04 10:58:33 +00:00
|
|
|
|
}};
|
|
|
|
|
REQUIRE(tbl == expected);
|
|
|
|
|
});
|
|
|
|
|
|
2021-09-04 09:24:47 +00:00
|
|
|
|
parsing_should_succeed(FILE_LINE_ARGS, array_nested_double, [](toml::table&& tbl) // array-nested-double
|
2021-07-04 10:58:33 +00:00
|
|
|
|
{
|
|
|
|
|
const auto expected = toml::table{{
|
2021-06-24 18:08:45 +00:00
|
|
|
|
{
|
2021-07-04 10:58:33 +00:00
|
|
|
|
R"(nest)"sv, toml::array{
|
|
|
|
|
toml::inserter{toml::array{
|
|
|
|
|
toml::array{
|
|
|
|
|
R"(a)"sv,
|
|
|
|
|
},
|
|
|
|
|
toml::array{
|
|
|
|
|
1,
|
|
|
|
|
2,
|
|
|
|
|
toml::array{
|
|
|
|
|
3,
|
|
|
|
|
},
|
|
|
|
|
},
|
|
|
|
|
}},
|
2021-06-24 18:08:45 +00:00
|
|
|
|
}
|
|
|
|
|
},
|
|
|
|
|
}};
|
|
|
|
|
REQUIRE(tbl == expected);
|
|
|
|
|
});
|
|
|
|
|
|
2021-09-04 09:24:47 +00:00
|
|
|
|
parsing_should_succeed(FILE_LINE_ARGS, array_nested_inline_table, [](toml::table&& tbl) // array-nested-inline-table
|
2021-06-24 18:08:45 +00:00
|
|
|
|
{
|
|
|
|
|
const auto expected = toml::table{{
|
|
|
|
|
{
|
|
|
|
|
R"(a)"sv, toml::array{
|
|
|
|
|
toml::table{{
|
|
|
|
|
{ R"(b)"sv, toml::table{} },
|
|
|
|
|
}},
|
|
|
|
|
}
|
|
|
|
|
},
|
|
|
|
|
}};
|
|
|
|
|
REQUIRE(tbl == expected);
|
|
|
|
|
});
|
|
|
|
|
|
2021-09-04 09:24:47 +00:00
|
|
|
|
parsing_should_succeed(FILE_LINE_ARGS, array_nested, [](toml::table&& tbl) // array-nested
|
2021-06-24 18:08:45 +00:00
|
|
|
|
{
|
|
|
|
|
const auto expected = toml::table{{
|
|
|
|
|
{
|
|
|
|
|
R"(nest)"sv, toml::array{
|
|
|
|
|
toml::array{
|
|
|
|
|
R"(a)"sv,
|
|
|
|
|
},
|
|
|
|
|
toml::array{
|
|
|
|
|
R"(b)"sv,
|
|
|
|
|
},
|
|
|
|
|
}
|
|
|
|
|
},
|
|
|
|
|
}};
|
|
|
|
|
REQUIRE(tbl == expected);
|
|
|
|
|
});
|
|
|
|
|
|
2021-09-04 09:24:47 +00:00
|
|
|
|
parsing_should_succeed(FILE_LINE_ARGS, array_nospaces, [](toml::table&& tbl) // array-nospaces
|
2020-07-05 15:08:28 +00:00
|
|
|
|
{
|
2021-06-24 18:08:45 +00:00
|
|
|
|
const auto expected = toml::table{{
|
2020-07-05 15:08:28 +00:00
|
|
|
|
{
|
2020-07-18 12:10:19 +00:00
|
|
|
|
R"(ints)"sv, toml::array{
|
2020-07-05 15:08:28 +00:00
|
|
|
|
1,
|
|
|
|
|
2,
|
|
|
|
|
3,
|
|
|
|
|
}
|
|
|
|
|
},
|
|
|
|
|
}};
|
|
|
|
|
REQUIRE(tbl == expected);
|
|
|
|
|
});
|
|
|
|
|
|
2021-09-04 09:24:47 +00:00
|
|
|
|
parsing_should_succeed(FILE_LINE_ARGS, array_string_quote_comma_2, [](toml::table&& tbl) // array-string-quote-comma-2
|
2020-07-05 15:08:28 +00:00
|
|
|
|
{
|
2021-06-24 18:08:45 +00:00
|
|
|
|
const auto expected = toml::table{{
|
2020-07-05 15:08:28 +00:00
|
|
|
|
{
|
2020-07-18 12:10:19 +00:00
|
|
|
|
R"(title)"sv, toml::array{
|
|
|
|
|
R"( ", )"sv,
|
2020-07-05 15:08:28 +00:00
|
|
|
|
}
|
|
|
|
|
},
|
|
|
|
|
}};
|
|
|
|
|
REQUIRE(tbl == expected);
|
|
|
|
|
});
|
|
|
|
|
|
2021-09-04 09:24:47 +00:00
|
|
|
|
parsing_should_succeed(FILE_LINE_ARGS, array_string_quote_comma, [](toml::table&& tbl) // array-string-quote-comma
|
2020-07-05 15:08:28 +00:00
|
|
|
|
{
|
2021-06-24 18:08:45 +00:00
|
|
|
|
const auto expected = toml::table{{
|
2020-07-05 15:08:28 +00:00
|
|
|
|
{
|
2020-07-18 12:10:19 +00:00
|
|
|
|
R"(title)"sv, toml::array{
|
|
|
|
|
R"(Client: "XXXX", Job: XXXX)"sv,
|
|
|
|
|
R"(Code: XXXX)"sv,
|
2020-07-05 15:08:28 +00:00
|
|
|
|
}
|
|
|
|
|
},
|
|
|
|
|
}};
|
|
|
|
|
REQUIRE(tbl == expected);
|
|
|
|
|
});
|
|
|
|
|
|
2021-09-04 09:24:47 +00:00
|
|
|
|
parsing_should_succeed(FILE_LINE_ARGS, array_string_with_comma, [](toml::table&& tbl) // array-string-with-comma
|
2020-07-05 15:08:28 +00:00
|
|
|
|
{
|
2021-06-24 18:08:45 +00:00
|
|
|
|
const auto expected = toml::table{{
|
2020-07-05 15:08:28 +00:00
|
|
|
|
{
|
2020-07-18 12:10:19 +00:00
|
|
|
|
R"(title)"sv, toml::array{
|
|
|
|
|
R"(Client: XXXX, Job: XXXX)"sv,
|
|
|
|
|
R"(Code: XXXX)"sv,
|
2020-07-05 15:08:28 +00:00
|
|
|
|
}
|
|
|
|
|
},
|
|
|
|
|
}};
|
|
|
|
|
REQUIRE(tbl == expected);
|
|
|
|
|
});
|
|
|
|
|
|
2021-09-04 09:24:47 +00:00
|
|
|
|
parsing_should_succeed(FILE_LINE_ARGS, array_strings, [](toml::table&& tbl) // array-strings
|
2020-07-05 15:08:28 +00:00
|
|
|
|
{
|
2021-06-24 18:08:45 +00:00
|
|
|
|
const auto expected = toml::table{{
|
2020-07-05 15:08:28 +00:00
|
|
|
|
{
|
2021-06-24 18:08:45 +00:00
|
|
|
|
R"(string_array)"sv, toml::array{
|
|
|
|
|
R"(all)"sv,
|
|
|
|
|
R"(strings)"sv,
|
|
|
|
|
R"(are the same)"sv,
|
|
|
|
|
R"(type)"sv,
|
2020-07-05 15:08:28 +00:00
|
|
|
|
}
|
|
|
|
|
},
|
|
|
|
|
}};
|
|
|
|
|
REQUIRE(tbl == expected);
|
|
|
|
|
});
|
|
|
|
|
|
2021-09-04 09:24:47 +00:00
|
|
|
|
parsing_should_succeed(FILE_LINE_ARGS, array_table_array_string_backslash, [](toml::table&& tbl) // array-table-array-string-backslash
|
2020-07-05 15:08:28 +00:00
|
|
|
|
{
|
2021-06-24 18:08:45 +00:00
|
|
|
|
const auto expected = toml::table{{
|
2020-07-05 15:08:28 +00:00
|
|
|
|
{
|
2021-06-24 18:08:45 +00:00
|
|
|
|
R"(foo)"sv, toml::array{
|
|
|
|
|
toml::table{{
|
|
|
|
|
{ R"(bar)"sv, R"("{{baz}}")"sv },
|
|
|
|
|
}},
|
2020-07-05 15:08:28 +00:00
|
|
|
|
}
|
|
|
|
|
},
|
|
|
|
|
}};
|
|
|
|
|
REQUIRE(tbl == expected);
|
|
|
|
|
});
|
|
|
|
|
|
2021-09-04 09:24:47 +00:00
|
|
|
|
parsing_should_succeed(FILE_LINE_ARGS, bool_bool, [](toml::table&& tbl) // bool-bool
|
2020-07-05 15:08:28 +00:00
|
|
|
|
{
|
2021-06-24 18:08:45 +00:00
|
|
|
|
const auto expected = toml::table{{
|
2020-07-18 12:10:19 +00:00
|
|
|
|
{ R"(f)"sv, false },
|
|
|
|
|
{ R"(t)"sv, true },
|
2020-07-05 15:08:28 +00:00
|
|
|
|
}};
|
|
|
|
|
REQUIRE(tbl == expected);
|
|
|
|
|
});
|
|
|
|
|
|
2021-09-04 09:24:47 +00:00
|
|
|
|
parsing_should_succeed(FILE_LINE_ARGS, comment_at_eof, [](toml::table&& tbl) // comment-at-eof
|
2020-07-05 15:08:28 +00:00
|
|
|
|
{
|
2021-06-24 18:08:45 +00:00
|
|
|
|
const auto expected = toml::table{{
|
2020-07-18 12:10:19 +00:00
|
|
|
|
{ R"(key)"sv, R"(value)"sv },
|
2020-07-05 15:08:28 +00:00
|
|
|
|
}};
|
|
|
|
|
REQUIRE(tbl == expected);
|
|
|
|
|
});
|
|
|
|
|
|
2021-09-04 09:24:47 +00:00
|
|
|
|
parsing_should_succeed(FILE_LINE_ARGS, comment_at_eof2, [](toml::table&& tbl) // comment-at-eof2
|
2020-07-05 15:08:28 +00:00
|
|
|
|
{
|
2021-06-24 18:08:45 +00:00
|
|
|
|
const auto expected = toml::table{{
|
2020-07-18 12:10:19 +00:00
|
|
|
|
{ R"(key)"sv, R"(value)"sv },
|
2020-07-05 15:08:28 +00:00
|
|
|
|
}};
|
|
|
|
|
REQUIRE(tbl == expected);
|
|
|
|
|
});
|
|
|
|
|
|
2021-09-04 09:24:47 +00:00
|
|
|
|
parsing_should_succeed(FILE_LINE_ARGS, comment_everywhere, [](toml::table&& tbl) // comment-everywhere
|
2020-07-05 15:08:28 +00:00
|
|
|
|
{
|
2021-06-24 18:08:45 +00:00
|
|
|
|
const auto expected = toml::table{{
|
2020-07-05 15:08:28 +00:00
|
|
|
|
{
|
2020-07-18 12:10:19 +00:00
|
|
|
|
R"(group)"sv, toml::table{{
|
|
|
|
|
{ R"(answer)"sv, 42 },
|
2021-09-04 09:24:47 +00:00
|
|
|
|
{ R"(d)"sv, toml::date_time{ { 1979, 5, 27 }, { 7, 32, 12, 0u }, { -7, 0 } } },
|
2020-07-05 15:08:28 +00:00
|
|
|
|
{
|
2020-07-18 12:10:19 +00:00
|
|
|
|
R"(more)"sv, toml::array{
|
2020-07-05 15:08:28 +00:00
|
|
|
|
42,
|
|
|
|
|
42,
|
|
|
|
|
}
|
|
|
|
|
},
|
|
|
|
|
}}
|
|
|
|
|
},
|
|
|
|
|
}};
|
|
|
|
|
REQUIRE(tbl == expected);
|
|
|
|
|
});
|
|
|
|
|
|
2021-09-04 09:24:47 +00:00
|
|
|
|
parsing_should_succeed(FILE_LINE_ARGS, comment_tricky, [](toml::table&& tbl) // comment-tricky
|
2020-07-05 15:08:28 +00:00
|
|
|
|
{
|
2021-06-24 18:08:45 +00:00
|
|
|
|
const auto expected = toml::table{{
|
|
|
|
|
{
|
|
|
|
|
R"(hash#tag)"sv, toml::table{{
|
|
|
|
|
{ R"(#!)"sv, R"(hash bang)"sv },
|
|
|
|
|
{
|
|
|
|
|
R"(arr3)"sv, toml::array{
|
|
|
|
|
R"(#)"sv,
|
|
|
|
|
R"(#)"sv,
|
|
|
|
|
R"(###)"sv,
|
|
|
|
|
}
|
|
|
|
|
},
|
|
|
|
|
{
|
|
|
|
|
R"(arr4)"sv, toml::array{
|
|
|
|
|
1,
|
|
|
|
|
2,
|
|
|
|
|
3,
|
|
|
|
|
4,
|
|
|
|
|
}
|
|
|
|
|
},
|
|
|
|
|
{
|
|
|
|
|
R"(arr5)"sv, toml::array{
|
|
|
|
|
toml::inserter{toml::array{
|
|
|
|
|
toml::inserter{toml::array{
|
|
|
|
|
toml::inserter{toml::array{
|
|
|
|
|
toml::inserter{toml::array{
|
|
|
|
|
R"(#)"sv,
|
|
|
|
|
}},
|
|
|
|
|
}},
|
|
|
|
|
}},
|
|
|
|
|
}},
|
|
|
|
|
}
|
|
|
|
|
},
|
|
|
|
|
{
|
|
|
|
|
R"(tbl1)"sv, toml::table{{
|
|
|
|
|
{ R"(#)"sv, R"(}#)"sv },
|
|
|
|
|
}}
|
|
|
|
|
},
|
|
|
|
|
}}
|
|
|
|
|
},
|
|
|
|
|
{
|
|
|
|
|
R"(section)"sv, toml::table{{
|
|
|
|
|
{ R"(8)"sv, R"(eight)"sv },
|
|
|
|
|
{ R"(eleven)"sv, 11.1 },
|
|
|
|
|
{ R"(five)"sv, 5.5 },
|
|
|
|
|
{ R"(four)"sv, R"(# no comment
|
|
|
|
|
# nor this
|
|
|
|
|
#also not comment)"sv },
|
|
|
|
|
{ R"(one)"sv, R"(11)"sv },
|
|
|
|
|
{ R"(six)"sv, 6 },
|
|
|
|
|
{ R"(ten)"sv, 1000.0 },
|
|
|
|
|
{ R"(three)"sv, R"(#)"sv },
|
|
|
|
|
{ R"(two)"sv, R"(22#)"sv },
|
|
|
|
|
}}
|
|
|
|
|
},
|
2020-07-05 15:08:28 +00:00
|
|
|
|
}};
|
|
|
|
|
REQUIRE(tbl == expected);
|
|
|
|
|
});
|
|
|
|
|
|
2021-09-04 09:24:47 +00:00
|
|
|
|
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
|
2020-07-05 15:08:28 +00:00
|
|
|
|
{
|
2021-06-24 18:08:45 +00:00
|
|
|
|
const auto expected = toml::table{{
|
|
|
|
|
{ R"(bestdayever)"sv, toml::date{ 1987, 7, 5 } },
|
2020-07-05 15:08:28 +00:00
|
|
|
|
}};
|
|
|
|
|
REQUIRE(tbl == expected);
|
|
|
|
|
});
|
|
|
|
|
|
2021-09-04 09:24:47 +00:00
|
|
|
|
parsing_should_succeed(FILE_LINE_ARGS, datetime_local_time, [](toml::table&& tbl) // datetime-local-time
|
2020-07-05 15:08:28 +00:00
|
|
|
|
{
|
2021-06-24 18:08:45 +00:00
|
|
|
|
const auto expected = toml::table{{
|
|
|
|
|
{ R"(besttimeever)"sv, toml::time{ 17, 45, 0, 0 } },
|
|
|
|
|
{ R"(milliseconds)"sv, toml::time{ 10, 32, 0, 555000000 } },
|
|
|
|
|
}};
|
2020-07-05 15:08:28 +00:00
|
|
|
|
REQUIRE(tbl == expected);
|
|
|
|
|
});
|
|
|
|
|
|
2021-09-04 09:24:47 +00:00
|
|
|
|
parsing_should_succeed(FILE_LINE_ARGS, datetime_local, [](toml::table&& tbl) // datetime-local
|
2020-07-05 15:08:28 +00:00
|
|
|
|
{
|
2021-06-24 18:08:45 +00:00
|
|
|
|
const auto expected = toml::table{{
|
2021-09-04 09:24:47 +00:00
|
|
|
|
{ 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 } } },
|
2021-06-24 18:08:45 +00:00
|
|
|
|
}};
|
|
|
|
|
REQUIRE(tbl == expected);
|
|
|
|
|
});
|
|
|
|
|
|
2021-09-04 09:24:47 +00:00
|
|
|
|
parsing_should_succeed(FILE_LINE_ARGS, datetime_milliseconds, [](toml::table&& tbl) // datetime-milliseconds
|
2021-06-24 18:08:45 +00:00
|
|
|
|
{
|
|
|
|
|
const auto expected = toml::table{{
|
2021-09-04 09:24:47 +00:00
|
|
|
|
{ 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 } } },
|
2021-06-24 18:08:45 +00:00
|
|
|
|
}};
|
|
|
|
|
REQUIRE(tbl == expected);
|
|
|
|
|
});
|
|
|
|
|
|
2021-09-04 09:24:47 +00:00
|
|
|
|
parsing_should_succeed(FILE_LINE_ARGS, datetime_timezone, [](toml::table&& tbl) // datetime-timezone
|
2021-06-24 18:08:45 +00:00
|
|
|
|
{
|
|
|
|
|
const auto expected = toml::table{{
|
2021-09-04 09:24:47 +00:00
|
|
|
|
{ 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 } } },
|
2020-07-05 15:08:28 +00:00
|
|
|
|
}};
|
|
|
|
|
REQUIRE(tbl == expected);
|
|
|
|
|
});
|
|
|
|
|
|
2021-09-04 09:24:47 +00:00
|
|
|
|
parsing_should_succeed(FILE_LINE_ARGS, empty_file, [](toml::table&& tbl) // empty-file
|
2021-06-24 18:08:45 +00:00
|
|
|
|
{
|
|
|
|
|
const auto expected = toml::table{};
|
|
|
|
|
REQUIRE(tbl == expected);
|
|
|
|
|
});
|
|
|
|
|
|
2021-09-04 09:24:47 +00:00
|
|
|
|
parsing_should_succeed(FILE_LINE_ARGS, example, [](toml::table&& tbl) // example
|
2020-07-05 15:08:28 +00:00
|
|
|
|
{
|
2021-06-24 18:08:45 +00:00
|
|
|
|
const auto expected = toml::table{{
|
2020-07-18 12:10:19 +00:00
|
|
|
|
{ R"(best-day-ever)"sv, toml::date_time{ { 1987, 7, 5 }, { 17, 45, 0, 0u }, { 0, 0 } } },
|
2020-07-05 15:08:28 +00:00
|
|
|
|
{
|
2020-07-18 12:10:19 +00:00
|
|
|
|
R"(numtheory)"sv, toml::table{{
|
|
|
|
|
{ R"(boring)"sv, false },
|
2020-07-05 15:08:28 +00:00
|
|
|
|
{
|
2020-07-18 12:10:19 +00:00
|
|
|
|
R"(perfection)"sv, toml::array{
|
2020-07-05 15:08:28 +00:00
|
|
|
|
6,
|
|
|
|
|
28,
|
|
|
|
|
496,
|
|
|
|
|
}
|
|
|
|
|
},
|
|
|
|
|
}}
|
|
|
|
|
},
|
|
|
|
|
}};
|
|
|
|
|
REQUIRE(tbl == expected);
|
|
|
|
|
});
|
|
|
|
|
|
2021-09-04 09:24:47 +00:00
|
|
|
|
parsing_should_succeed(FILE_LINE_ARGS, float_exponent, [](toml::table&& tbl) // float-exponent
|
2020-07-05 15:08:28 +00:00
|
|
|
|
{
|
2021-06-24 18:08:45 +00:00
|
|
|
|
const auto expected = toml::table{{
|
|
|
|
|
{ R"(lower)"sv, 300.0 },
|
2020-07-18 12:10:19 +00:00
|
|
|
|
{ R"(minustenth)"sv, -0.1 },
|
2021-06-24 18:08:45 +00:00
|
|
|
|
{ R"(neg)"sv, 0.03 },
|
|
|
|
|
{ R"(pointlower)"sv, 310.0 },
|
|
|
|
|
{ R"(pointupper)"sv, 310.0 },
|
|
|
|
|
{ R"(pos)"sv, 300.0 },
|
|
|
|
|
{ R"(upper)"sv, 300.0 },
|
|
|
|
|
{ R"(zero)"sv, 3.0 },
|
2020-07-05 15:08:28 +00:00
|
|
|
|
}};
|
|
|
|
|
REQUIRE(tbl == expected);
|
|
|
|
|
});
|
|
|
|
|
|
2021-09-04 09:24:47 +00:00
|
|
|
|
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
|
2020-07-05 15:08:28 +00:00
|
|
|
|
{
|
2021-06-24 18:08:45 +00:00
|
|
|
|
const auto expected = toml::table{{
|
|
|
|
|
{ R"(infinity)"sv, std::numeric_limits<double>::infinity() },
|
|
|
|
|
{ R"(infinity_neg)"sv, -std::numeric_limits<double>::infinity() },
|
|
|
|
|
{ R"(infinity_plus)"sv, std::numeric_limits<double>::infinity() },
|
|
|
|
|
{ R"(nan)"sv, std::numeric_limits<double>::quiet_NaN() },
|
|
|
|
|
{ R"(nan_neg)"sv, std::numeric_limits<double>::quiet_NaN() },
|
|
|
|
|
{ R"(nan_plus)"sv, std::numeric_limits<double>::quiet_NaN() },
|
|
|
|
|
}};
|
|
|
|
|
REQUIRE(tbl == expected);
|
|
|
|
|
});
|
|
|
|
|
|
2021-09-04 09:24:47 +00:00
|
|
|
|
parsing_should_succeed(FILE_LINE_ARGS, float_long, [](toml::table&& tbl) // float-long
|
2021-06-24 18:08:45 +00:00
|
|
|
|
{
|
|
|
|
|
const auto expected = toml::table{{
|
|
|
|
|
{ R"(longpi)"sv, 3.141592653589793 },
|
|
|
|
|
{ R"(neglongpi)"sv, -3.141592653589793 },
|
2020-07-05 15:08:28 +00:00
|
|
|
|
}};
|
|
|
|
|
REQUIRE(tbl == expected);
|
|
|
|
|
});
|
|
|
|
|
|
2021-09-04 09:24:47 +00:00
|
|
|
|
parsing_should_succeed(FILE_LINE_ARGS, float_underscore, [](toml::table&& tbl) // float-underscore
|
2020-07-05 15:08:28 +00:00
|
|
|
|
{
|
2021-06-24 18:08:45 +00:00
|
|
|
|
const auto expected = toml::table{{
|
2020-07-18 12:10:19 +00:00
|
|
|
|
{ R"(after)"sv, 3141.5927 },
|
2021-06-24 18:08:45 +00:00
|
|
|
|
{ R"(before)"sv, 3141.5927 },
|
2020-07-18 12:10:19 +00:00
|
|
|
|
{ R"(exponent)"sv, 300000000000000.0 },
|
2020-07-05 15:08:28 +00:00
|
|
|
|
}};
|
|
|
|
|
REQUIRE(tbl == expected);
|
|
|
|
|
});
|
|
|
|
|
|
2021-09-04 09:24:47 +00:00
|
|
|
|
parsing_should_succeed(FILE_LINE_ARGS, float_zero, [](toml::table&& tbl) // float-zero
|
2021-06-24 18:08:45 +00:00
|
|
|
|
{
|
|
|
|
|
const auto expected = toml::table{{
|
|
|
|
|
{ R"(f1)"sv, 0.0 },
|
|
|
|
|
{ R"(f2)"sv, 0.0 },
|
|
|
|
|
{ R"(f3)"sv, 0.0 },
|
|
|
|
|
{ R"(f4)"sv, 0.0 },
|
|
|
|
|
{ R"(f5)"sv, 0.0 },
|
|
|
|
|
{ R"(f6)"sv, 0.0 },
|
|
|
|
|
{ R"(f7)"sv, 0.0 },
|
|
|
|
|
}};
|
|
|
|
|
REQUIRE(tbl == expected);
|
|
|
|
|
});
|
|
|
|
|
|
2021-09-04 09:24:47 +00:00
|
|
|
|
parsing_should_succeed(FILE_LINE_ARGS, implicit_and_explicit_after, [](toml::table&& tbl) // implicit-and-explicit-after
|
2020-07-05 15:08:28 +00:00
|
|
|
|
{
|
2021-06-24 18:08:45 +00:00
|
|
|
|
const auto expected = toml::table{{
|
2020-07-05 15:08:28 +00:00
|
|
|
|
{
|
2020-07-18 12:10:19 +00:00
|
|
|
|
R"(a)"sv, toml::table{{
|
2020-07-05 15:08:28 +00:00
|
|
|
|
{
|
2020-07-18 12:10:19 +00:00
|
|
|
|
R"(b)"sv, toml::table{{
|
2020-07-05 15:08:28 +00:00
|
|
|
|
{
|
2020-07-18 12:10:19 +00:00
|
|
|
|
R"(c)"sv, toml::table{{
|
|
|
|
|
{ R"(answer)"sv, 42 },
|
2020-07-05 15:08:28 +00:00
|
|
|
|
}}
|
|
|
|
|
},
|
|
|
|
|
}}
|
|
|
|
|
},
|
2021-06-24 18:08:45 +00:00
|
|
|
|
{ R"(better)"sv, 43 },
|
2020-07-05 15:08:28 +00:00
|
|
|
|
}}
|
|
|
|
|
},
|
|
|
|
|
}};
|
|
|
|
|
REQUIRE(tbl == expected);
|
|
|
|
|
});
|
|
|
|
|
|
2021-09-04 09:24:47 +00:00
|
|
|
|
parsing_should_succeed(FILE_LINE_ARGS, implicit_and_explicit_before, [](toml::table&& tbl) // implicit-and-explicit-before
|
2020-07-05 15:08:28 +00:00
|
|
|
|
{
|
2021-06-24 18:08:45 +00:00
|
|
|
|
const auto expected = toml::table{{
|
2020-07-05 15:08:28 +00:00
|
|
|
|
{
|
2020-07-18 12:10:19 +00:00
|
|
|
|
R"(a)"sv, toml::table{{
|
2020-07-05 15:08:28 +00:00
|
|
|
|
{
|
2020-07-18 12:10:19 +00:00
|
|
|
|
R"(b)"sv, toml::table{{
|
2020-07-05 15:08:28 +00:00
|
|
|
|
{
|
2020-07-18 12:10:19 +00:00
|
|
|
|
R"(c)"sv, toml::table{{
|
|
|
|
|
{ R"(answer)"sv, 42 },
|
2020-07-05 15:08:28 +00:00
|
|
|
|
}}
|
|
|
|
|
},
|
|
|
|
|
}}
|
|
|
|
|
},
|
2021-06-24 18:08:45 +00:00
|
|
|
|
{ R"(better)"sv, 43 },
|
2020-07-05 15:08:28 +00:00
|
|
|
|
}}
|
|
|
|
|
},
|
|
|
|
|
}};
|
|
|
|
|
REQUIRE(tbl == expected);
|
|
|
|
|
});
|
|
|
|
|
|
2021-09-04 09:24:47 +00:00
|
|
|
|
parsing_should_succeed(FILE_LINE_ARGS, implicit_groups, [](toml::table&& tbl) // implicit-groups
|
2020-07-05 15:08:28 +00:00
|
|
|
|
{
|
2021-06-24 18:08:45 +00:00
|
|
|
|
const auto expected = toml::table{{
|
2020-07-05 15:08:28 +00:00
|
|
|
|
{
|
2020-07-18 12:10:19 +00:00
|
|
|
|
R"(a)"sv, toml::table{{
|
2020-07-05 15:08:28 +00:00
|
|
|
|
{
|
2020-07-18 12:10:19 +00:00
|
|
|
|
R"(b)"sv, toml::table{{
|
2020-07-05 15:08:28 +00:00
|
|
|
|
{
|
2020-07-18 12:10:19 +00:00
|
|
|
|
R"(c)"sv, toml::table{{
|
|
|
|
|
{ R"(answer)"sv, 42 },
|
2020-07-05 15:08:28 +00:00
|
|
|
|
}}
|
|
|
|
|
},
|
|
|
|
|
}}
|
|
|
|
|
},
|
|
|
|
|
}}
|
|
|
|
|
},
|
|
|
|
|
}};
|
|
|
|
|
REQUIRE(tbl == expected);
|
|
|
|
|
});
|
|
|
|
|
|
2021-09-04 09:24:47 +00:00
|
|
|
|
parsing_should_succeed(FILE_LINE_ARGS, inline_table_array, [](toml::table&& tbl) // inline-table-array
|
2020-07-05 15:08:28 +00:00
|
|
|
|
{
|
2021-06-24 18:08:45 +00:00
|
|
|
|
const auto expected = toml::table{{
|
2020-07-05 15:08:28 +00:00
|
|
|
|
{
|
2020-07-18 12:10:19 +00:00
|
|
|
|
R"(people)"sv, toml::array{
|
2020-07-05 15:08:28 +00:00
|
|
|
|
toml::table{{
|
2020-07-18 12:10:19 +00:00
|
|
|
|
{ R"(first_name)"sv, R"(Bruce)"sv },
|
|
|
|
|
{ R"(last_name)"sv, R"(Springsteen)"sv },
|
2020-07-05 15:08:28 +00:00
|
|
|
|
}},
|
|
|
|
|
toml::table{{
|
2020-07-18 12:10:19 +00:00
|
|
|
|
{ R"(first_name)"sv, R"(Eric)"sv },
|
|
|
|
|
{ R"(last_name)"sv, R"(Clapton)"sv },
|
2020-07-05 15:08:28 +00:00
|
|
|
|
}},
|
|
|
|
|
toml::table{{
|
2020-07-18 12:10:19 +00:00
|
|
|
|
{ R"(first_name)"sv, R"(Bob)"sv },
|
|
|
|
|
{ R"(last_name)"sv, R"(Seger)"sv },
|
2020-07-05 15:08:28 +00:00
|
|
|
|
}},
|
|
|
|
|
}
|
|
|
|
|
},
|
|
|
|
|
}};
|
|
|
|
|
REQUIRE(tbl == expected);
|
|
|
|
|
});
|
|
|
|
|
|
2021-09-04 09:24:47 +00:00
|
|
|
|
parsing_should_succeed(FILE_LINE_ARGS, inline_table_bool, [](toml::table&& tbl) // inline-table-bool
|
2021-06-24 18:08:45 +00:00
|
|
|
|
{
|
|
|
|
|
const auto expected = toml::table{{
|
|
|
|
|
{
|
|
|
|
|
R"(a)"sv, toml::table{{
|
|
|
|
|
{ R"(a)"sv, true },
|
|
|
|
|
{ R"(b)"sv, false },
|
|
|
|
|
}}
|
|
|
|
|
},
|
|
|
|
|
}};
|
|
|
|
|
REQUIRE(tbl == expected);
|
|
|
|
|
});
|
|
|
|
|
|
2021-09-04 09:24:47 +00:00
|
|
|
|
parsing_should_succeed(FILE_LINE_ARGS, inline_table_empty, [](toml::table&& tbl) // inline-table-empty
|
2021-06-24 18:08:45 +00:00
|
|
|
|
{
|
|
|
|
|
const auto expected = toml::table{{
|
|
|
|
|
{ R"(empty1)"sv, toml::table{} },
|
|
|
|
|
{ R"(empty2)"sv, toml::table{} },
|
|
|
|
|
{
|
|
|
|
|
R"(empty_in_array)"sv, toml::array{
|
|
|
|
|
toml::table{{
|
|
|
|
|
{ R"(not_empty)"sv, 1 },
|
|
|
|
|
}},
|
|
|
|
|
toml::table{},
|
|
|
|
|
}
|
|
|
|
|
},
|
|
|
|
|
{
|
|
|
|
|
R"(empty_in_array2)"sv, toml::array{
|
|
|
|
|
toml::table{},
|
|
|
|
|
toml::table{{
|
|
|
|
|
{ R"(not_empty)"sv, 1 },
|
|
|
|
|
}},
|
|
|
|
|
}
|
|
|
|
|
},
|
|
|
|
|
{
|
|
|
|
|
R"(many_empty)"sv, toml::array{
|
|
|
|
|
toml::table{},
|
|
|
|
|
toml::table{},
|
|
|
|
|
toml::table{},
|
|
|
|
|
}
|
|
|
|
|
},
|
|
|
|
|
{
|
|
|
|
|
R"(nested_empty)"sv, toml::table{{
|
|
|
|
|
{ R"(empty)"sv, toml::table{} },
|
|
|
|
|
}}
|
|
|
|
|
},
|
|
|
|
|
}};
|
|
|
|
|
REQUIRE(tbl == expected);
|
|
|
|
|
});
|
|
|
|
|
|
2021-09-04 09:24:47 +00:00
|
|
|
|
parsing_should_succeed(FILE_LINE_ARGS, inline_table_end_in_bool, [](toml::table&& tbl) // inline-table-end-in-bool
|
2021-06-24 18:08:45 +00:00
|
|
|
|
{
|
|
|
|
|
const auto expected = toml::table{{
|
|
|
|
|
{
|
|
|
|
|
R"(black)"sv, toml::table{{
|
|
|
|
|
{ R"(allow_prereleases)"sv, true },
|
|
|
|
|
{ R"(python)"sv, R"(>3.6)"sv },
|
|
|
|
|
{ R"(version)"sv, R"(>=18.9b0)"sv },
|
|
|
|
|
}}
|
|
|
|
|
},
|
|
|
|
|
}};
|
|
|
|
|
REQUIRE(tbl == expected);
|
|
|
|
|
});
|
|
|
|
|
|
2021-09-04 09:24:47 +00:00
|
|
|
|
parsing_should_succeed(FILE_LINE_ARGS, inline_table_inline_table, [](toml::table&& tbl) // inline-table-inline-table
|
2021-06-24 18:08:45 +00:00
|
|
|
|
{
|
|
|
|
|
const auto expected = toml::table{{
|
|
|
|
|
{
|
2021-09-04 09:24:47 +00:00
|
|
|
|
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{{
|
2021-06-24 18:08:45 +00:00
|
|
|
|
{ R"(a)"sv, 1 },
|
|
|
|
|
}}
|
|
|
|
|
},
|
|
|
|
|
{
|
2021-09-04 09:24:47 +00:00
|
|
|
|
R"(str-key)"sv, toml::table{{
|
|
|
|
|
{ R"(a)"sv, 1 },
|
|
|
|
|
}}
|
|
|
|
|
},
|
|
|
|
|
{
|
|
|
|
|
R"(table-array)"sv, toml::array{
|
|
|
|
|
toml::table{{
|
|
|
|
|
{ R"(a)"sv, 1 },
|
|
|
|
|
}},
|
|
|
|
|
toml::table{{
|
|
|
|
|
{ R"(b)"sv, 2 },
|
|
|
|
|
}},
|
|
|
|
|
}
|
|
|
|
|
},
|
|
|
|
|
}};
|
|
|
|
|
REQUIRE(tbl == expected);
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
parsing_should_succeed(FILE_LINE_ARGS, inline_table_multiline, [](toml::table&& tbl) // inline-table-multiline
|
|
|
|
|
{
|
|
|
|
|
const auto expected = toml::table{{
|
|
|
|
|
{
|
|
|
|
|
R"(tbl_multiline)"sv, toml::table{{
|
|
|
|
|
{ R"(a)"sv, 1 },
|
|
|
|
|
{ R"(b)"sv, R"(multiline
|
|
|
|
|
)"sv },
|
|
|
|
|
{ R"(c)"sv, R"(and yet
|
|
|
|
|
another line)"sv },
|
|
|
|
|
{ R"(d)"sv, 4 },
|
|
|
|
|
}}
|
|
|
|
|
},
|
|
|
|
|
}};
|
|
|
|
|
REQUIRE(tbl == expected);
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
parsing_should_succeed(FILE_LINE_ARGS, inline_table_nest, [](toml::table&& tbl) // inline-table-nest
|
|
|
|
|
{
|
|
|
|
|
const auto expected = toml::table{{
|
|
|
|
|
{
|
|
|
|
|
R"(arr_arr_tbl_empty)"sv, toml::array{
|
|
|
|
|
toml::inserter{toml::array{
|
|
|
|
|
toml::table{},
|
|
|
|
|
}},
|
|
|
|
|
}
|
2021-06-24 18:08:45 +00:00
|
|
|
|
},
|
|
|
|
|
{
|
|
|
|
|
R"(arr_arr_tbl_val)"sv, toml::array{
|
|
|
|
|
toml::inserter{toml::array{
|
|
|
|
|
toml::table{{
|
|
|
|
|
{ R"(one)"sv, 1 },
|
|
|
|
|
}},
|
|
|
|
|
}},
|
|
|
|
|
}
|
|
|
|
|
},
|
|
|
|
|
{
|
|
|
|
|
R"(arr_arr_tbls)"sv, toml::array{
|
|
|
|
|
toml::inserter{toml::array{
|
|
|
|
|
toml::table{{
|
|
|
|
|
{ R"(one)"sv, 1 },
|
|
|
|
|
}},
|
|
|
|
|
toml::table{{
|
|
|
|
|
{ R"(two)"sv, 2 },
|
|
|
|
|
}},
|
|
|
|
|
}},
|
|
|
|
|
}
|
|
|
|
|
},
|
|
|
|
|
{
|
|
|
|
|
R"(arr_tbl_tbl)"sv, toml::array{
|
|
|
|
|
toml::table{{
|
|
|
|
|
{
|
|
|
|
|
R"(tbl)"sv, toml::table{{
|
|
|
|
|
{ R"(one)"sv, 1 },
|
|
|
|
|
}}
|
|
|
|
|
},
|
|
|
|
|
}},
|
|
|
|
|
}
|
|
|
|
|
},
|
|
|
|
|
{
|
|
|
|
|
R"(tbl_arr_tbl)"sv, toml::table{{
|
|
|
|
|
{
|
|
|
|
|
R"(arr_tbl)"sv, toml::array{
|
|
|
|
|
toml::table{{
|
|
|
|
|
{ R"(one)"sv, 1 },
|
|
|
|
|
}},
|
|
|
|
|
}
|
|
|
|
|
},
|
|
|
|
|
}}
|
|
|
|
|
},
|
|
|
|
|
{
|
|
|
|
|
R"(tbl_tbl_empty)"sv, toml::table{{
|
|
|
|
|
{ R"(tbl_0)"sv, toml::table{} },
|
|
|
|
|
}}
|
|
|
|
|
},
|
|
|
|
|
{
|
|
|
|
|
R"(tbl_tbl_val)"sv, toml::table{{
|
|
|
|
|
{
|
|
|
|
|
R"(tbl_1)"sv, toml::table{{
|
|
|
|
|
{ R"(one)"sv, 1 },
|
|
|
|
|
}}
|
|
|
|
|
},
|
|
|
|
|
}}
|
|
|
|
|
},
|
|
|
|
|
}};
|
|
|
|
|
REQUIRE(tbl == expected);
|
|
|
|
|
});
|
|
|
|
|
|
2021-09-04 09:24:47 +00:00
|
|
|
|
#if !TOML_MSVC
|
|
|
|
|
|
|
|
|
|
parsing_should_succeed(FILE_LINE_ARGS, inline_table_key_dotted, [](toml::table&& tbl) // inline-table-key-dotted
|
2020-07-05 15:08:28 +00:00
|
|
|
|
{
|
2021-06-24 18:08:45 +00:00
|
|
|
|
const auto expected = toml::table{{
|
2020-07-05 15:08:28 +00:00
|
|
|
|
{
|
2021-09-04 09:24:47 +00:00
|
|
|
|
R"(a)"sv, toml::table{{
|
|
|
|
|
{
|
|
|
|
|
R"(a)"sv, toml::table{{
|
|
|
|
|
{ R"(b)"sv, 1 },
|
|
|
|
|
}}
|
|
|
|
|
},
|
2020-07-05 15:08:28 +00:00
|
|
|
|
}}
|
|
|
|
|
},
|
|
|
|
|
{
|
2021-09-04 09:24:47 +00:00
|
|
|
|
R"(arr)"sv, toml::array{
|
|
|
|
|
toml::table{{
|
|
|
|
|
{
|
|
|
|
|
R"(T)"sv, toml::table{{
|
|
|
|
|
{
|
|
|
|
|
R"(a)"sv, toml::table{{
|
|
|
|
|
{ R"(b)"sv, 1 },
|
|
|
|
|
}}
|
|
|
|
|
},
|
|
|
|
|
}}
|
|
|
|
|
},
|
|
|
|
|
{
|
|
|
|
|
R"(t)"sv, toml::table{{
|
|
|
|
|
{
|
|
|
|
|
R"(a)"sv, toml::table{{
|
|
|
|
|
{ R"(b)"sv, 1 },
|
|
|
|
|
}}
|
|
|
|
|
},
|
|
|
|
|
}}
|
|
|
|
|
},
|
|
|
|
|
}},
|
|
|
|
|
toml::table{{
|
|
|
|
|
{
|
|
|
|
|
R"(T)"sv, toml::table{{
|
|
|
|
|
{
|
|
|
|
|
R"(a)"sv, toml::table{{
|
|
|
|
|
{ R"(b)"sv, 2 },
|
|
|
|
|
}}
|
|
|
|
|
},
|
|
|
|
|
}}
|
|
|
|
|
},
|
|
|
|
|
{
|
|
|
|
|
R"(t)"sv, toml::table{{
|
|
|
|
|
{
|
|
|
|
|
R"(a)"sv, toml::table{{
|
|
|
|
|
{ R"(b)"sv, 2 },
|
|
|
|
|
}}
|
|
|
|
|
},
|
|
|
|
|
}}
|
|
|
|
|
},
|
|
|
|
|
}},
|
|
|
|
|
}
|
|
|
|
|
},
|
|
|
|
|
{
|
|
|
|
|
R"(b)"sv, toml::table{{
|
|
|
|
|
{
|
|
|
|
|
R"(a)"sv, toml::table{{
|
|
|
|
|
{ R"(b)"sv, 1 },
|
|
|
|
|
}}
|
|
|
|
|
},
|
2020-07-05 15:08:28 +00:00
|
|
|
|
}}
|
|
|
|
|
},
|
|
|
|
|
{
|
2021-09-04 09:24:47 +00:00
|
|
|
|
R"(c)"sv, toml::table{{
|
|
|
|
|
{
|
|
|
|
|
R"(a)"sv, toml::table{{
|
|
|
|
|
{ R"(b)"sv, 1 },
|
|
|
|
|
}}
|
|
|
|
|
},
|
2020-07-05 15:08:28 +00:00
|
|
|
|
}}
|
|
|
|
|
},
|
|
|
|
|
{
|
2021-09-04 09:24:47 +00:00
|
|
|
|
R"(d)"sv, toml::table{{
|
|
|
|
|
{
|
|
|
|
|
R"(a)"sv, toml::table{{
|
|
|
|
|
{ R"(b)"sv, 1 },
|
|
|
|
|
}}
|
|
|
|
|
},
|
2020-07-05 15:08:28 +00:00
|
|
|
|
}}
|
|
|
|
|
},
|
|
|
|
|
{
|
2021-09-04 09:24:47 +00:00
|
|
|
|
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 },
|
|
|
|
|
}}
|
|
|
|
|
},
|
|
|
|
|
}}
|
|
|
|
|
},
|
|
|
|
|
}}
|
|
|
|
|
},
|
|
|
|
|
}}
|
|
|
|
|
},
|
|
|
|
|
}}
|
|
|
|
|
},
|
|
|
|
|
}}
|
2020-07-05 15:08:28 +00:00
|
|
|
|
},
|
|
|
|
|
}};
|
|
|
|
|
REQUIRE(tbl == expected);
|
|
|
|
|
});
|
|
|
|
|
|
2021-09-04 09:24:47 +00:00
|
|
|
|
#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
|
2021-06-24 18:08:45 +00:00
|
|
|
|
{
|
|
|
|
|
const auto expected = toml::table{{
|
|
|
|
|
{ R"(bin1)"sv, 214 },
|
|
|
|
|
{ R"(bin2)"sv, 5 },
|
|
|
|
|
{ R"(hex1)"sv, 3735928559 },
|
|
|
|
|
{ R"(hex2)"sv, 3735928559 },
|
|
|
|
|
{ R"(hex3)"sv, 3735928559 },
|
|
|
|
|
{ R"(hex4)"sv, 2439 },
|
|
|
|
|
{ R"(oct1)"sv, 342391 },
|
|
|
|
|
{ R"(oct2)"sv, 493 },
|
|
|
|
|
{ R"(oct3)"sv, 501 },
|
|
|
|
|
}};
|
|
|
|
|
REQUIRE(tbl == expected);
|
|
|
|
|
});
|
|
|
|
|
|
2021-09-04 09:24:47 +00:00
|
|
|
|
parsing_should_succeed(FILE_LINE_ARGS, integer_long, [](toml::table&& tbl) // integer-long
|
2021-06-24 18:08:45 +00:00
|
|
|
|
{
|
|
|
|
|
const auto expected = toml::table{{
|
2021-09-07 17:02:00 +00:00
|
|
|
|
{ R"(int64-max)"sv, std::numeric_limits<int64_t>::max() },
|
|
|
|
|
{ R"(int64-max-neg)"sv, std::numeric_limits<int64_t>::min() },
|
2021-06-24 18:08:45 +00:00
|
|
|
|
}};
|
|
|
|
|
REQUIRE(tbl == expected);
|
|
|
|
|
});
|
|
|
|
|
|
2021-09-04 09:24:47 +00:00
|
|
|
|
parsing_should_succeed(FILE_LINE_ARGS, integer_underscore, [](toml::table&& tbl) // integer-underscore
|
2020-07-05 15:08:28 +00:00
|
|
|
|
{
|
2021-06-24 18:08:45 +00:00
|
|
|
|
const auto expected = toml::table{{
|
2020-07-18 12:10:19 +00:00
|
|
|
|
{ R"(kilo)"sv, 1000 },
|
2021-06-24 18:08:45 +00:00
|
|
|
|
{ R"(x)"sv, 1111 },
|
|
|
|
|
}};
|
|
|
|
|
REQUIRE(tbl == expected);
|
|
|
|
|
});
|
|
|
|
|
|
2021-09-04 09:24:47 +00:00
|
|
|
|
parsing_should_succeed(FILE_LINE_ARGS, integer_zero, [](toml::table&& tbl) // integer-zero
|
2021-06-24 18:08:45 +00:00
|
|
|
|
{
|
|
|
|
|
const auto expected = toml::table{{
|
|
|
|
|
{ R"(a2)"sv, 0 },
|
|
|
|
|
{ R"(a3)"sv, 0 },
|
|
|
|
|
{ R"(b1)"sv, 0 },
|
|
|
|
|
{ R"(b2)"sv, 0 },
|
|
|
|
|
{ R"(b3)"sv, 0 },
|
|
|
|
|
{ R"(d1)"sv, 0 },
|
|
|
|
|
{ R"(d2)"sv, 0 },
|
|
|
|
|
{ R"(d3)"sv, 0 },
|
|
|
|
|
{ R"(h1)"sv, 0 },
|
|
|
|
|
{ R"(h2)"sv, 0 },
|
|
|
|
|
{ R"(h3)"sv, 0 },
|
|
|
|
|
{ R"(o1)"sv, 0 },
|
2020-07-05 15:08:28 +00:00
|
|
|
|
}};
|
|
|
|
|
REQUIRE(tbl == expected);
|
|
|
|
|
});
|
|
|
|
|
|
2021-06-24 18:08:45 +00:00
|
|
|
|
#if UNICODE_LITERALS_OK
|
|
|
|
|
|
2021-09-04 09:24:47 +00:00
|
|
|
|
parsing_should_succeed(FILE_LINE_ARGS, key_case_sensitive, [](toml::table&& tbl) // key-case-sensitive
|
2020-07-05 15:08:28 +00:00
|
|
|
|
{
|
2021-06-24 18:08:45 +00:00
|
|
|
|
const auto expected = toml::table{{
|
|
|
|
|
{
|
|
|
|
|
R"(Section)"sv, toml::table{{
|
|
|
|
|
{ R"(M)"sv, R"(latin letter M)"sv },
|
|
|
|
|
{ R"(name)"sv, R"(different section!!)"sv },
|
|
|
|
|
{ R"(Μ)"sv, R"(greek capital letter MU)"sv },
|
|
|
|
|
{ R"(μ)"sv, R"(greek small letter mu)"sv },
|
|
|
|
|
}}
|
|
|
|
|
},
|
|
|
|
|
{ R"(sectioN)"sv, R"(NN)"sv },
|
|
|
|
|
{
|
|
|
|
|
R"(section)"sv, toml::table{{
|
|
|
|
|
{ R"(NAME)"sv, R"(upper)"sv },
|
|
|
|
|
{ R"(Name)"sv, R"(capitalized)"sv },
|
|
|
|
|
{ R"(name)"sv, R"(lower)"sv },
|
|
|
|
|
}}
|
|
|
|
|
},
|
2020-07-05 15:08:28 +00:00
|
|
|
|
}};
|
|
|
|
|
REQUIRE(tbl == expected);
|
|
|
|
|
});
|
|
|
|
|
|
2021-09-04 09:24:47 +00:00
|
|
|
|
parsing_should_succeed(FILE_LINE_ARGS, key_escapes, [](toml::table&& tbl) // key-escapes
|
2020-07-05 15:08:28 +00:00
|
|
|
|
{
|
2021-06-24 18:08:45 +00:00
|
|
|
|
const auto expected = toml::table{{
|
|
|
|
|
{ R"(
|
|
|
|
|
)"sv, R"(newline)"sv },
|
|
|
|
|
{ R"(")"sv, R"(just a quote)"sv },
|
|
|
|
|
{
|
|
|
|
|
R"("quoted")"sv, toml::table{{
|
|
|
|
|
{ R"(quote)"sv, true },
|
|
|
|
|
}}
|
|
|
|
|
},
|
|
|
|
|
{
|
|
|
|
|
R"(a.b)"sv, toml::table{{
|
|
|
|
|
{ R"(À)"sv, toml::table{} },
|
|
|
|
|
}}
|
|
|
|
|
},
|
|
|
|
|
{ R"(backsp)"sv, toml::table{} },
|
|
|
|
|
{ R"(À)"sv, R"(latin capital letter A with grave)"sv },
|
2020-07-05 15:08:28 +00:00
|
|
|
|
}};
|
|
|
|
|
REQUIRE(tbl == expected);
|
|
|
|
|
});
|
|
|
|
|
|
2021-06-24 18:08:45 +00:00
|
|
|
|
#endif // UNICODE_LITERALS_OK
|
|
|
|
|
|
2021-09-04 09:24:47 +00:00
|
|
|
|
parsing_should_succeed(FILE_LINE_ARGS, key_dotted, [](toml::table&& tbl) // key-dotted
|
2020-07-05 15:08:28 +00:00
|
|
|
|
{
|
2021-06-24 18:08:45 +00:00
|
|
|
|
const auto expected = toml::table{{
|
|
|
|
|
{
|
|
|
|
|
R"(a)"sv, toml::table{{
|
|
|
|
|
{
|
|
|
|
|
R"(few)"sv, toml::table{{
|
|
|
|
|
{
|
|
|
|
|
R"(dots)"sv, toml::table{{
|
|
|
|
|
{
|
|
|
|
|
R"(polka)"sv, toml::table{{
|
|
|
|
|
{ R"(dance-with)"sv, R"(Dot)"sv },
|
|
|
|
|
{ R"(dot)"sv, R"(again?)"sv },
|
|
|
|
|
}}
|
|
|
|
|
},
|
|
|
|
|
}}
|
|
|
|
|
},
|
|
|
|
|
}}
|
|
|
|
|
},
|
|
|
|
|
}}
|
|
|
|
|
},
|
|
|
|
|
{
|
|
|
|
|
R"(arr)"sv, toml::array{
|
|
|
|
|
toml::table{{
|
|
|
|
|
{
|
|
|
|
|
R"(a)"sv, toml::table{{
|
|
|
|
|
{
|
|
|
|
|
R"(b)"sv, toml::table{{
|
|
|
|
|
{ R"(c)"sv, 1 },
|
|
|
|
|
{ R"(d)"sv, 2 },
|
|
|
|
|
}}
|
|
|
|
|
},
|
|
|
|
|
}}
|
|
|
|
|
},
|
|
|
|
|
}},
|
|
|
|
|
toml::table{{
|
|
|
|
|
{
|
|
|
|
|
R"(a)"sv, toml::table{{
|
|
|
|
|
{
|
|
|
|
|
R"(b)"sv, toml::table{{
|
|
|
|
|
{ R"(c)"sv, 3 },
|
|
|
|
|
{ R"(d)"sv, 4 },
|
|
|
|
|
}}
|
|
|
|
|
},
|
|
|
|
|
}}
|
|
|
|
|
},
|
|
|
|
|
}},
|
|
|
|
|
}
|
|
|
|
|
},
|
|
|
|
|
{
|
|
|
|
|
R"(count)"sv, toml::table{{
|
|
|
|
|
{ R"(a)"sv, 1 },
|
|
|
|
|
{ R"(b)"sv, 2 },
|
|
|
|
|
{ R"(c)"sv, 3 },
|
|
|
|
|
{ R"(d)"sv, 4 },
|
|
|
|
|
{ R"(e)"sv, 5 },
|
|
|
|
|
{ R"(f)"sv, 6 },
|
|
|
|
|
{ R"(g)"sv, 7 },
|
|
|
|
|
{ R"(h)"sv, 8 },
|
|
|
|
|
{ R"(i)"sv, 9 },
|
|
|
|
|
{ R"(j)"sv, 10 },
|
|
|
|
|
{ R"(k)"sv, 11 },
|
|
|
|
|
{ R"(l)"sv, 12 },
|
|
|
|
|
}}
|
|
|
|
|
},
|
|
|
|
|
{
|
|
|
|
|
R"(many)"sv, toml::table{{
|
|
|
|
|
{
|
|
|
|
|
R"(dots)"sv, toml::table{{
|
|
|
|
|
{
|
|
|
|
|
R"(here)"sv, toml::table{{
|
|
|
|
|
{
|
|
|
|
|
R"(dot)"sv, toml::table{{
|
|
|
|
|
{
|
|
|
|
|
R"(dot)"sv, toml::table{{
|
|
|
|
|
{ R"(dot)"sv, 42 },
|
|
|
|
|
}}
|
|
|
|
|
},
|
|
|
|
|
}}
|
|
|
|
|
},
|
|
|
|
|
}}
|
|
|
|
|
},
|
|
|
|
|
}}
|
|
|
|
|
},
|
|
|
|
|
}}
|
|
|
|
|
},
|
|
|
|
|
{
|
|
|
|
|
R"(name)"sv, toml::table{{
|
|
|
|
|
{ R"(first)"sv, R"(Arthur)"sv },
|
|
|
|
|
{ R"(last)"sv, R"(Dent)"sv },
|
|
|
|
|
}}
|
|
|
|
|
},
|
|
|
|
|
{
|
|
|
|
|
R"(tbl)"sv, toml::table{{
|
|
|
|
|
{
|
|
|
|
|
R"(a)"sv, toml::table{{
|
|
|
|
|
{
|
|
|
|
|
R"(b)"sv, toml::table{{
|
|
|
|
|
{ R"(c)"sv, 42.666 },
|
|
|
|
|
}}
|
|
|
|
|
},
|
|
|
|
|
}}
|
|
|
|
|
},
|
|
|
|
|
}}
|
|
|
|
|
},
|
2020-07-05 15:08:28 +00:00
|
|
|
|
}};
|
|
|
|
|
REQUIRE(tbl == expected);
|
|
|
|
|
});
|
|
|
|
|
|
2021-09-04 09:24:47 +00:00
|
|
|
|
parsing_should_succeed(FILE_LINE_ARGS, key_empty, [](toml::table&& tbl) // key-empty
|
2020-07-05 15:08:28 +00:00
|
|
|
|
{
|
2021-06-24 18:08:45 +00:00
|
|
|
|
const auto expected = toml::table{{
|
2021-09-07 17:02:00 +00:00
|
|
|
|
{ ""sv, R"(blank)"sv },
|
2021-06-24 18:08:45 +00:00
|
|
|
|
}};
|
|
|
|
|
REQUIRE(tbl == expected);
|
|
|
|
|
});
|
|
|
|
|
|
2021-09-04 09:24:47 +00:00
|
|
|
|
parsing_should_succeed(FILE_LINE_ARGS, key_equals_nospace, [](toml::table&& tbl) // key-equals-nospace
|
2021-06-24 18:08:45 +00:00
|
|
|
|
{
|
|
|
|
|
const auto expected = toml::table{{
|
|
|
|
|
{ R"(answer)"sv, 42 },
|
2020-07-05 15:08:28 +00:00
|
|
|
|
}};
|
|
|
|
|
REQUIRE(tbl == expected);
|
|
|
|
|
});
|
|
|
|
|
|
2021-09-04 09:24:47 +00:00
|
|
|
|
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
|
2020-07-05 15:08:28 +00:00
|
|
|
|
{
|
2021-06-24 18:08:45 +00:00
|
|
|
|
const auto expected = toml::table{{
|
|
|
|
|
{ R"(1)"sv, 1 },
|
|
|
|
|
}};
|
|
|
|
|
REQUIRE(tbl == expected);
|
|
|
|
|
});
|
|
|
|
|
|
2021-09-04 09:24:47 +00:00
|
|
|
|
parsing_should_succeed(FILE_LINE_ARGS, key_quoted_dots, [](toml::table&& tbl) // key-quoted-dots
|
2021-06-24 18:08:45 +00:00
|
|
|
|
{
|
|
|
|
|
const auto expected = toml::table{{
|
2020-07-18 12:10:19 +00:00
|
|
|
|
{ R"(plain)"sv, 1 },
|
2020-07-05 15:08:28 +00:00
|
|
|
|
{
|
2020-07-18 12:10:19 +00:00
|
|
|
|
R"(plain_table)"sv, toml::table{{
|
|
|
|
|
{ R"(plain)"sv, 3 },
|
|
|
|
|
{ R"(with.dot)"sv, 4 },
|
2020-07-05 15:08:28 +00:00
|
|
|
|
}}
|
|
|
|
|
},
|
|
|
|
|
{
|
2020-07-18 12:10:19 +00:00
|
|
|
|
R"(table)"sv, toml::table{{
|
2020-07-05 15:08:28 +00:00
|
|
|
|
{
|
2020-07-18 12:10:19 +00:00
|
|
|
|
R"(withdot)"sv, toml::table{{
|
|
|
|
|
{ R"(key.with.dots)"sv, 6 },
|
2021-06-24 18:08:45 +00:00
|
|
|
|
{ R"(plain)"sv, 5 },
|
2020-07-05 15:08:28 +00:00
|
|
|
|
}}
|
|
|
|
|
},
|
|
|
|
|
}}
|
|
|
|
|
},
|
2021-06-24 18:08:45 +00:00
|
|
|
|
{ R"(with.dot)"sv, 2 },
|
2020-07-05 15:08:28 +00:00
|
|
|
|
}};
|
|
|
|
|
REQUIRE(tbl == expected);
|
|
|
|
|
});
|
|
|
|
|
|
2021-09-04 09:24:47 +00:00
|
|
|
|
parsing_should_succeed(FILE_LINE_ARGS, key_space, [](toml::table&& tbl) // key-space
|
2020-07-05 15:08:28 +00:00
|
|
|
|
{
|
2021-06-24 18:08:45 +00:00
|
|
|
|
const auto expected = toml::table{{
|
|
|
|
|
{ R"(a b)"sv, 1 },
|
2020-07-05 15:08:28 +00:00
|
|
|
|
}};
|
|
|
|
|
REQUIRE(tbl == expected);
|
|
|
|
|
});
|
|
|
|
|
|
2021-09-04 09:24:47 +00:00
|
|
|
|
parsing_should_succeed(FILE_LINE_ARGS, key_special_chars, [](toml::table&& tbl) // key-special-chars
|
2020-07-05 15:08:28 +00:00
|
|
|
|
{
|
2021-06-24 18:08:45 +00:00
|
|
|
|
const auto expected = toml::table{{
|
|
|
|
|
{ R"(~!@$^&*()_+-`1234567890[]|/?><.,;:')"sv, 1 },
|
2020-07-05 15:08:28 +00:00
|
|
|
|
}};
|
|
|
|
|
REQUIRE(tbl == expected);
|
|
|
|
|
});
|
|
|
|
|
|
2021-09-04 09:24:47 +00:00
|
|
|
|
parsing_should_succeed(FILE_LINE_ARGS, key_special_word, [](toml::table&& tbl) // key-special-word
|
2020-07-05 15:08:28 +00:00
|
|
|
|
{
|
2021-06-24 18:08:45 +00:00
|
|
|
|
const auto expected = toml::table{{
|
|
|
|
|
{ R"(false)"sv, false },
|
|
|
|
|
{ R"(inf)"sv, 100000000 },
|
|
|
|
|
{ R"(nan)"sv, R"(ceci n'est pas un nombre)"sv },
|
|
|
|
|
{ R"(true)"sv, 1 },
|
2020-07-05 15:08:28 +00:00
|
|
|
|
}};
|
|
|
|
|
REQUIRE(tbl == expected);
|
|
|
|
|
});
|
|
|
|
|
|
2021-09-04 09:24:47 +00:00
|
|
|
|
parsing_should_succeed(FILE_LINE_ARGS, newline_crlf, [](toml::table&& tbl) // newline-crlf
|
2020-07-05 15:08:28 +00:00
|
|
|
|
{
|
2021-06-24 18:08:45 +00:00
|
|
|
|
const auto expected = toml::table{{
|
2020-07-18 12:10:19 +00:00
|
|
|
|
{ R"(newline)"sv, R"(crlf)"sv },
|
2021-06-24 18:08:45 +00:00
|
|
|
|
{ R"(os)"sv, R"(DOS)"sv },
|
2020-07-05 15:08:28 +00:00
|
|
|
|
}};
|
|
|
|
|
REQUIRE(tbl == expected);
|
|
|
|
|
});
|
|
|
|
|
|
2021-09-04 09:24:47 +00:00
|
|
|
|
parsing_should_succeed(FILE_LINE_ARGS, newline_lf, [](toml::table&& tbl) // newline-lf
|
2020-07-05 15:08:28 +00:00
|
|
|
|
{
|
2021-06-24 18:08:45 +00:00
|
|
|
|
const auto expected = toml::table{{
|
2020-07-18 12:10:19 +00:00
|
|
|
|
{ R"(newline)"sv, R"(lf)"sv },
|
2021-06-24 18:08:45 +00:00
|
|
|
|
{ R"(os)"sv, R"(unix)"sv },
|
2020-07-05 15:08:28 +00:00
|
|
|
|
}};
|
|
|
|
|
REQUIRE(tbl == expected);
|
|
|
|
|
});
|
|
|
|
|
|
2021-09-04 09:24:47 +00:00
|
|
|
|
parsing_should_succeed(FILE_LINE_ARGS, spec_example_1_compact, [](toml::table&& tbl) // spec-example-1-compact
|
2020-07-05 15:08:28 +00:00
|
|
|
|
{
|
2021-06-24 18:08:45 +00:00
|
|
|
|
const auto expected = toml::table{{
|
2020-07-05 15:08:28 +00:00
|
|
|
|
{
|
2021-06-24 18:08:45 +00:00
|
|
|
|
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);
|
|
|
|
|
});
|
|
|
|
|
|
2021-09-04 09:24:47 +00:00
|
|
|
|
parsing_should_succeed(FILE_LINE_ARGS, spec_example_1, [](toml::table&& tbl) // spec-example-1
|
2021-06-24 18:08:45 +00:00
|
|
|
|
{
|
|
|
|
|
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,
|
|
|
|
|
}
|
|
|
|
|
},
|
2020-07-05 15:08:28 +00:00
|
|
|
|
}}
|
|
|
|
|
},
|
2021-06-24 18:08:45 +00:00
|
|
|
|
{
|
|
|
|
|
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);
|
|
|
|
|
});
|
|
|
|
|
|
2021-09-04 09:24:47 +00:00
|
|
|
|
parsing_should_succeed(FILE_LINE_ARGS, string_double_quote_escape, [](toml::table&& tbl) // string-double-quote-escape
|
2021-06-24 18:08:45 +00:00
|
|
|
|
{
|
|
|
|
|
const auto expected = toml::table{{
|
|
|
|
|
{ R"(test)"sv, R"("one")"sv },
|
2020-07-05 15:08:28 +00:00
|
|
|
|
}};
|
|
|
|
|
REQUIRE(tbl == expected);
|
|
|
|
|
});
|
|
|
|
|
|
2021-09-04 09:24:47 +00:00
|
|
|
|
parsing_should_succeed(FILE_LINE_ARGS, string_empty, [](toml::table&& tbl) // string-empty
|
2020-07-05 15:08:28 +00:00
|
|
|
|
{
|
2021-06-24 18:08:45 +00:00
|
|
|
|
const auto expected = toml::table{{
|
2021-09-07 17:02:00 +00:00
|
|
|
|
{ R"(answer)"sv, ""sv },
|
2020-07-05 15:08:28 +00:00
|
|
|
|
}};
|
|
|
|
|
REQUIRE(tbl == expected);
|
|
|
|
|
});
|
|
|
|
|
|
2021-09-04 09:24:47 +00:00
|
|
|
|
parsing_should_succeed(FILE_LINE_ARGS, string_escaped_escape, [](toml::table&& tbl) // string-escaped-escape
|
2021-06-24 18:08:45 +00:00
|
|
|
|
{
|
|
|
|
|
const auto expected = toml::table{{
|
|
|
|
|
{ R"(answer)"sv, R"(\x64)"sv },
|
|
|
|
|
}};
|
|
|
|
|
REQUIRE(tbl == expected);
|
|
|
|
|
});
|
|
|
|
|
|
2021-09-04 09:24:47 +00:00
|
|
|
|
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 },
|
|
|
|
|
{ R"(lit_one_space)"sv, R"( 'one quote' )"sv },
|
|
|
|
|
{ R"(lit_two)"sv, R"(''two quotes'')"sv },
|
|
|
|
|
{ R"(lit_two_space)"sv, R"( ''two quotes'' )"sv },
|
|
|
|
|
{ R"(mismatch1)"sv, R"(aaa'''bbb)"sv },
|
|
|
|
|
{ R"(mismatch2)"sv, R"(aaa"""bbb)"sv },
|
|
|
|
|
{ R"(one)"sv, R"("one quote")"sv },
|
|
|
|
|
{ R"(one_space)"sv, R"( "one quote" )"sv },
|
|
|
|
|
{ R"(two)"sv, R"(""two quotes"")"sv },
|
|
|
|
|
{ R"(two_space)"sv, R"( ""two quotes"" )"sv },
|
|
|
|
|
}};
|
|
|
|
|
REQUIRE(tbl == expected);
|
|
|
|
|
});
|
|
|
|
|
|
2021-09-07 17:02:00 +00:00
|
|
|
|
parsing_should_succeed(FILE_LINE_ARGS, string_multiline, [](toml::table&& tbl) // string-multiline
|
|
|
|
|
{
|
|
|
|
|
const auto expected = toml::table{{
|
|
|
|
|
{ R"(equivalent_one)"sv, R"(The quick brown fox jumps over the lazy dog.)"sv },
|
|
|
|
|
{ R"(equivalent_three)"sv, R"(The quick brown fox jumps over the lazy dog.)"sv },
|
|
|
|
|
{ R"(equivalent_two)"sv, R"(The quick brown fox jumps over the lazy dog.)"sv },
|
|
|
|
|
{ R"(escape-bs-1)"sv, R"(a \
|
|
|
|
|
b)"sv },
|
|
|
|
|
{ R"(escape-bs-2)"sv, R"(a \b)"sv },
|
|
|
|
|
{ R"(escape-bs-3)"sv, R"(a \\
|
|
|
|
|
b)"sv },
|
|
|
|
|
{ R"(keep-ws-before)"sv, R"(a b)"sv },
|
|
|
|
|
{ R"(multiline_empty_four)"sv, ""sv },
|
|
|
|
|
{ R"(multiline_empty_one)"sv, ""sv },
|
|
|
|
|
{ R"(multiline_empty_three)"sv, ""sv },
|
|
|
|
|
{ R"(multiline_empty_two)"sv, ""sv },
|
|
|
|
|
{ R"(no-space)"sv, R"(ab)"sv },
|
|
|
|
|
{ R"(whitespace-after-bs)"sv, R"(The quick brown fox jumps over the lazy dog.)"sv },
|
|
|
|
|
}};
|
|
|
|
|
REQUIRE(tbl == expected);
|
|
|
|
|
});
|
|
|
|
|
|
2021-09-04 09:24:47 +00:00
|
|
|
|
parsing_should_succeed(FILE_LINE_ARGS, string_nl, [](toml::table&& tbl) // string-nl
|
2020-07-05 15:08:28 +00:00
|
|
|
|
{
|
2021-06-24 18:08:45 +00:00
|
|
|
|
const auto expected = toml::table{{
|
2020-07-18 12:10:19 +00:00
|
|
|
|
{ R"(lit_nl_end)"sv, R"(value\n)"sv },
|
|
|
|
|
{ R"(lit_nl_mid)"sv, R"(val\nue)"sv },
|
|
|
|
|
{ R"(lit_nl_uni)"sv, R"(val\ue)"sv },
|
2021-06-24 18:08:45 +00:00
|
|
|
|
{ R"(nl_end)"sv, R"(value
|
|
|
|
|
)"sv },
|
|
|
|
|
{ R"(nl_mid)"sv, R"(val
|
|
|
|
|
ue)"sv },
|
2020-07-05 15:08:28 +00:00
|
|
|
|
}};
|
|
|
|
|
REQUIRE(tbl == expected);
|
|
|
|
|
});
|
|
|
|
|
|
2021-09-04 09:24:47 +00:00
|
|
|
|
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
|
2020-07-05 15:08:28 +00:00
|
|
|
|
{
|
2021-06-24 18:08:45 +00:00
|
|
|
|
const auto expected = toml::table{{
|
2020-07-18 12:10:19 +00:00
|
|
|
|
{ R"(answer)"sv, R"(You are not drinking enough whisky.)"sv },
|
2020-07-05 15:08:28 +00:00
|
|
|
|
}};
|
|
|
|
|
REQUIRE(tbl == expected);
|
|
|
|
|
});
|
|
|
|
|
|
2021-09-04 09:24:47 +00:00
|
|
|
|
parsing_should_succeed(FILE_LINE_ARGS, string_with_pound, [](toml::table&& tbl) // string-with-pound
|
2020-07-05 15:08:28 +00:00
|
|
|
|
{
|
2021-06-24 18:08:45 +00:00
|
|
|
|
const auto expected = toml::table{{
|
2020-07-18 12:10:19 +00:00
|
|
|
|
{ R"(pound)"sv, R"(We see no # comments here.)"sv },
|
|
|
|
|
{ R"(poundcomment)"sv, R"(But there are # some comments here.)"sv },
|
2020-07-05 15:08:28 +00:00
|
|
|
|
}};
|
|
|
|
|
REQUIRE(tbl == expected);
|
|
|
|
|
});
|
|
|
|
|
|
2021-06-24 18:08:45 +00:00
|
|
|
|
#if UNICODE_LITERALS_OK
|
|
|
|
|
|
2021-09-04 09:24:47 +00:00
|
|
|
|
parsing_should_succeed(FILE_LINE_ARGS, string_escape_tricky, [](toml::table&& tbl) // string-escape-tricky
|
2021-06-24 18:08:45 +00:00
|
|
|
|
{
|
|
|
|
|
const auto expected = toml::table{{
|
|
|
|
|
{ R"(end_esc)"sv, R"(String does not end here" but ends here\)"sv },
|
|
|
|
|
{ R"(lit_end_esc)"sv, R"(String ends here\)"sv },
|
|
|
|
|
{ R"(lit_multiline_end)"sv, R"(There is no escape\)"sv },
|
|
|
|
|
{ R"(lit_multiline_not_unicode)"sv, R"(\u007f)"sv },
|
|
|
|
|
{ R"(multiline_end_esc)"sv, R"(When will it end? """...""" should be here")"sv },
|
|
|
|
|
{ R"(multiline_not_unicode)"sv, R"(\u0041)"sv },
|
|
|
|
|
{ R"(multiline_unicode)"sv, R"( )"sv },
|
|
|
|
|
}};
|
|
|
|
|
REQUIRE(tbl == expected);
|
|
|
|
|
});
|
|
|
|
|
|
2021-09-04 09:24:47 +00:00
|
|
|
|
parsing_should_succeed(FILE_LINE_ARGS, string_unicode_escape, [](toml::table&& tbl) // string-unicode-escape
|
2021-06-24 18:08:45 +00:00
|
|
|
|
{
|
|
|
|
|
const auto expected = toml::table{{
|
|
|
|
|
{ R"(answer4)"sv, R"(δ)"sv },
|
|
|
|
|
{ R"(answer8)"sv, R"(δ)"sv },
|
|
|
|
|
}};
|
|
|
|
|
REQUIRE(tbl == expected);
|
|
|
|
|
});
|
|
|
|
|
|
2021-09-04 09:24:47 +00:00
|
|
|
|
parsing_should_succeed(FILE_LINE_ARGS, string_unicode_literal, [](toml::table&& tbl) // string-unicode-literal
|
2021-06-24 18:08:45 +00:00
|
|
|
|
{
|
|
|
|
|
const auto expected = toml::table{{
|
|
|
|
|
{ R"(answer)"sv, R"(δ)"sv },
|
|
|
|
|
}};
|
|
|
|
|
REQUIRE(tbl == expected);
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
#endif // UNICODE_LITERALS_OK
|
|
|
|
|
|
2021-09-04 09:24:47 +00:00
|
|
|
|
parsing_should_succeed(FILE_LINE_ARGS, table_array_implicit, [](toml::table&& tbl) // table-array-implicit
|
2020-07-05 15:08:28 +00:00
|
|
|
|
{
|
2021-06-24 18:08:45 +00:00
|
|
|
|
const auto expected = toml::table{{
|
2020-07-05 15:08:28 +00:00
|
|
|
|
{
|
2020-07-18 12:10:19 +00:00
|
|
|
|
R"(albums)"sv, toml::table{{
|
2020-07-05 15:08:28 +00:00
|
|
|
|
{
|
2020-07-18 12:10:19 +00:00
|
|
|
|
R"(songs)"sv, toml::array{
|
2020-07-05 15:08:28 +00:00
|
|
|
|
toml::table{{
|
2020-07-18 12:10:19 +00:00
|
|
|
|
{ R"(name)"sv, R"(Glory Days)"sv },
|
2020-07-05 15:08:28 +00:00
|
|
|
|
}},
|
|
|
|
|
}
|
|
|
|
|
},
|
|
|
|
|
}}
|
|
|
|
|
},
|
|
|
|
|
}};
|
|
|
|
|
REQUIRE(tbl == expected);
|
|
|
|
|
});
|
|
|
|
|
|
2021-09-04 09:24:47 +00:00
|
|
|
|
parsing_should_succeed(FILE_LINE_ARGS, table_array_many, [](toml::table&& tbl) // table-array-many
|
2020-07-05 15:08:28 +00:00
|
|
|
|
{
|
2021-06-24 18:08:45 +00:00
|
|
|
|
const auto expected = toml::table{{
|
2020-07-05 15:08:28 +00:00
|
|
|
|
{
|
2020-07-18 12:10:19 +00:00
|
|
|
|
R"(people)"sv, toml::array{
|
2020-07-05 15:08:28 +00:00
|
|
|
|
toml::table{{
|
2020-07-18 12:10:19 +00:00
|
|
|
|
{ R"(first_name)"sv, R"(Bruce)"sv },
|
|
|
|
|
{ R"(last_name)"sv, R"(Springsteen)"sv },
|
2020-07-05 15:08:28 +00:00
|
|
|
|
}},
|
|
|
|
|
toml::table{{
|
2020-07-18 12:10:19 +00:00
|
|
|
|
{ R"(first_name)"sv, R"(Eric)"sv },
|
|
|
|
|
{ R"(last_name)"sv, R"(Clapton)"sv },
|
2020-07-05 15:08:28 +00:00
|
|
|
|
}},
|
|
|
|
|
toml::table{{
|
2020-07-18 12:10:19 +00:00
|
|
|
|
{ R"(first_name)"sv, R"(Bob)"sv },
|
|
|
|
|
{ R"(last_name)"sv, R"(Seger)"sv },
|
2020-07-05 15:08:28 +00:00
|
|
|
|
}},
|
|
|
|
|
}
|
|
|
|
|
},
|
|
|
|
|
}};
|
|
|
|
|
REQUIRE(tbl == expected);
|
|
|
|
|
});
|
|
|
|
|
|
2021-09-04 09:24:47 +00:00
|
|
|
|
parsing_should_succeed(FILE_LINE_ARGS, table_array_nest, [](toml::table&& tbl) // table-array-nest
|
2020-07-05 15:08:28 +00:00
|
|
|
|
{
|
2021-06-24 18:08:45 +00:00
|
|
|
|
const auto expected = toml::table{{
|
2020-07-05 15:08:28 +00:00
|
|
|
|
{
|
2020-07-18 12:10:19 +00:00
|
|
|
|
R"(albums)"sv, toml::array{
|
2020-07-05 15:08:28 +00:00
|
|
|
|
toml::table{{
|
2020-07-18 12:10:19 +00:00
|
|
|
|
{ R"(name)"sv, R"(Born to Run)"sv },
|
2020-07-05 15:08:28 +00:00
|
|
|
|
{
|
2020-07-18 12:10:19 +00:00
|
|
|
|
R"(songs)"sv, toml::array{
|
2020-07-05 15:08:28 +00:00
|
|
|
|
toml::table{{
|
2020-07-18 12:10:19 +00:00
|
|
|
|
{ R"(name)"sv, R"(Jungleland)"sv },
|
2020-07-05 15:08:28 +00:00
|
|
|
|
}},
|
|
|
|
|
toml::table{{
|
2020-07-18 12:10:19 +00:00
|
|
|
|
{ R"(name)"sv, R"(Meeting Across the River)"sv },
|
2020-07-05 15:08:28 +00:00
|
|
|
|
}},
|
|
|
|
|
}
|
|
|
|
|
},
|
|
|
|
|
}},
|
|
|
|
|
toml::table{{
|
2020-07-18 12:10:19 +00:00
|
|
|
|
{ R"(name)"sv, R"(Born in the USA)"sv },
|
2020-07-05 15:08:28 +00:00
|
|
|
|
{
|
2020-07-18 12:10:19 +00:00
|
|
|
|
R"(songs)"sv, toml::array{
|
2020-07-05 15:08:28 +00:00
|
|
|
|
toml::table{{
|
2020-07-18 12:10:19 +00:00
|
|
|
|
{ R"(name)"sv, R"(Glory Days)"sv },
|
2020-07-05 15:08:28 +00:00
|
|
|
|
}},
|
|
|
|
|
toml::table{{
|
2020-07-18 12:10:19 +00:00
|
|
|
|
{ R"(name)"sv, R"(Dancing in the Dark)"sv },
|
2020-07-05 15:08:28 +00:00
|
|
|
|
}},
|
|
|
|
|
}
|
|
|
|
|
},
|
|
|
|
|
}},
|
|
|
|
|
}
|
|
|
|
|
},
|
|
|
|
|
}};
|
|
|
|
|
REQUIRE(tbl == expected);
|
|
|
|
|
});
|
|
|
|
|
|
2021-09-04 09:24:47 +00:00
|
|
|
|
parsing_should_succeed(FILE_LINE_ARGS, table_array_one, [](toml::table&& tbl) // table-array-one
|
2020-07-05 15:08:28 +00:00
|
|
|
|
{
|
2021-06-24 18:08:45 +00:00
|
|
|
|
const auto expected = toml::table{{
|
2020-07-05 15:08:28 +00:00
|
|
|
|
{
|
2020-07-18 12:10:19 +00:00
|
|
|
|
R"(people)"sv, toml::array{
|
2020-07-05 15:08:28 +00:00
|
|
|
|
toml::table{{
|
2020-07-18 12:10:19 +00:00
|
|
|
|
{ R"(first_name)"sv, R"(Bruce)"sv },
|
|
|
|
|
{ R"(last_name)"sv, R"(Springsteen)"sv },
|
2020-07-05 15:08:28 +00:00
|
|
|
|
}},
|
|
|
|
|
}
|
|
|
|
|
},
|
|
|
|
|
}};
|
|
|
|
|
REQUIRE(tbl == expected);
|
|
|
|
|
});
|
|
|
|
|
|
2021-09-04 09:24:47 +00:00
|
|
|
|
parsing_should_succeed(FILE_LINE_ARGS, table_array_table_array, [](toml::table&& tbl) // table-array-table-array
|
2020-07-05 15:08:28 +00:00
|
|
|
|
{
|
2021-06-24 18:08:45 +00:00
|
|
|
|
const auto expected = toml::table{{
|
2020-07-05 15:08:28 +00:00
|
|
|
|
{
|
2020-07-18 12:10:19 +00:00
|
|
|
|
R"(a)"sv, toml::array{
|
2020-07-05 15:08:28 +00:00
|
|
|
|
toml::table{{
|
|
|
|
|
{
|
2020-07-18 12:10:19 +00:00
|
|
|
|
R"(b)"sv, toml::array{
|
2020-07-05 15:08:28 +00:00
|
|
|
|
toml::table{{
|
|
|
|
|
{
|
2020-07-18 12:10:19 +00:00
|
|
|
|
R"(c)"sv, toml::table{{
|
|
|
|
|
{ R"(d)"sv, R"(val0)"sv },
|
2020-07-05 15:08:28 +00:00
|
|
|
|
}}
|
|
|
|
|
},
|
|
|
|
|
}},
|
|
|
|
|
toml::table{{
|
|
|
|
|
{
|
2020-07-18 12:10:19 +00:00
|
|
|
|
R"(c)"sv, toml::table{{
|
|
|
|
|
{ R"(d)"sv, R"(val1)"sv },
|
2020-07-05 15:08:28 +00:00
|
|
|
|
}}
|
|
|
|
|
},
|
|
|
|
|
}},
|
|
|
|
|
}
|
|
|
|
|
},
|
|
|
|
|
}},
|
|
|
|
|
}
|
|
|
|
|
},
|
|
|
|
|
}};
|
|
|
|
|
REQUIRE(tbl == expected);
|
|
|
|
|
});
|
|
|
|
|
|
2021-09-04 09:24:47 +00:00
|
|
|
|
parsing_should_succeed(FILE_LINE_ARGS, table_empty, [](toml::table&& tbl) // table-empty
|
2020-07-05 15:08:28 +00:00
|
|
|
|
{
|
2021-06-24 18:08:45 +00:00
|
|
|
|
const auto expected = toml::table{{
|
2020-07-18 12:10:19 +00:00
|
|
|
|
{ R"(a)"sv, toml::table{} },
|
2020-07-05 15:08:28 +00:00
|
|
|
|
}};
|
|
|
|
|
REQUIRE(tbl == expected);
|
|
|
|
|
});
|
|
|
|
|
|
2021-09-04 09:24:47 +00:00
|
|
|
|
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
|
2020-07-05 15:08:28 +00:00
|
|
|
|
{
|
2021-06-24 18:08:45 +00:00
|
|
|
|
const auto expected = toml::table{{
|
2020-07-18 12:10:19 +00:00
|
|
|
|
{ R"(table)"sv, toml::table{} },
|
2020-07-05 15:08:28 +00:00
|
|
|
|
}};
|
|
|
|
|
REQUIRE(tbl == expected);
|
|
|
|
|
});
|
|
|
|
|
|
2021-09-04 09:24:47 +00:00
|
|
|
|
parsing_should_succeed(FILE_LINE_ARGS, table_sub_empty, [](toml::table&& tbl) // table-sub-empty
|
2020-07-05 15:08:28 +00:00
|
|
|
|
{
|
2021-06-24 18:08:45 +00:00
|
|
|
|
const auto expected = toml::table{{
|
2020-07-05 15:08:28 +00:00
|
|
|
|
{
|
2020-07-18 12:10:19 +00:00
|
|
|
|
R"(a)"sv, toml::table{{
|
|
|
|
|
{ R"(b)"sv, toml::table{} },
|
2020-07-05 15:08:28 +00:00
|
|
|
|
}}
|
|
|
|
|
},
|
|
|
|
|
}};
|
|
|
|
|
REQUIRE(tbl == expected);
|
|
|
|
|
});
|
|
|
|
|
|
2021-09-04 09:24:47 +00:00
|
|
|
|
parsing_should_succeed(FILE_LINE_ARGS, table_whitespace, [](toml::table&& tbl) // table-whitespace
|
2020-07-05 15:08:28 +00:00
|
|
|
|
{
|
2021-06-24 18:08:45 +00:00
|
|
|
|
const auto expected = toml::table{{
|
2020-07-18 12:10:19 +00:00
|
|
|
|
{ R"(valid key)"sv, toml::table{} },
|
2020-07-05 15:08:28 +00:00
|
|
|
|
}};
|
|
|
|
|
REQUIRE(tbl == expected);
|
|
|
|
|
});
|
|
|
|
|
|
2021-09-04 09:24:47 +00:00
|
|
|
|
parsing_should_succeed(FILE_LINE_ARGS, table_with_literal_string, [](toml::table&& tbl) // table-with-literal-string
|
2020-07-05 15:08:28 +00:00
|
|
|
|
{
|
2021-06-24 18:08:45 +00:00
|
|
|
|
const auto expected = toml::table{{
|
2020-07-05 15:08:28 +00:00
|
|
|
|
{
|
2020-07-18 12:10:19 +00:00
|
|
|
|
R"(a)"sv, toml::table{{
|
2020-07-05 15:08:28 +00:00
|
|
|
|
{
|
2020-07-18 12:10:19 +00:00
|
|
|
|
R"("b")"sv, toml::table{{
|
2020-07-05 15:08:28 +00:00
|
|
|
|
{
|
2020-07-18 12:10:19 +00:00
|
|
|
|
R"(c)"sv, toml::table{{
|
|
|
|
|
{ R"(answer)"sv, 42 },
|
2020-07-05 15:08:28 +00:00
|
|
|
|
}}
|
|
|
|
|
},
|
|
|
|
|
}}
|
|
|
|
|
},
|
|
|
|
|
}}
|
|
|
|
|
},
|
|
|
|
|
}};
|
|
|
|
|
REQUIRE(tbl == expected);
|
|
|
|
|
});
|
|
|
|
|
|
2021-09-04 09:24:47 +00:00
|
|
|
|
parsing_should_succeed(FILE_LINE_ARGS, table_with_pound, [](toml::table&& tbl) // table-with-pound
|
2020-07-05 15:08:28 +00:00
|
|
|
|
{
|
2021-06-24 18:08:45 +00:00
|
|
|
|
const auto expected = toml::table{{
|
2020-07-05 15:08:28 +00:00
|
|
|
|
{
|
2020-07-18 12:10:19 +00:00
|
|
|
|
R"(key#group)"sv, toml::table{{
|
|
|
|
|
{ R"(answer)"sv, 42 },
|
2020-07-05 15:08:28 +00:00
|
|
|
|
}}
|
|
|
|
|
},
|
|
|
|
|
}};
|
|
|
|
|
REQUIRE(tbl == expected);
|
|
|
|
|
});
|
|
|
|
|
|
2021-09-04 09:24:47 +00:00
|
|
|
|
parsing_should_succeed(FILE_LINE_ARGS, table_with_single_quotes, [](toml::table&& tbl) // table-with-single-quotes
|
2020-07-05 15:08:28 +00:00
|
|
|
|
{
|
2021-06-24 18:08:45 +00:00
|
|
|
|
const auto expected = toml::table{{
|
2020-07-05 15:08:28 +00:00
|
|
|
|
{
|
2020-07-18 12:10:19 +00:00
|
|
|
|
R"(a)"sv, toml::table{{
|
2020-07-05 15:08:28 +00:00
|
|
|
|
{
|
2020-07-18 12:10:19 +00:00
|
|
|
|
R"(b)"sv, toml::table{{
|
2020-07-05 15:08:28 +00:00
|
|
|
|
{
|
2020-07-18 12:10:19 +00:00
|
|
|
|
R"(c)"sv, toml::table{{
|
|
|
|
|
{ R"(answer)"sv, 42 },
|
2020-07-05 15:08:28 +00:00
|
|
|
|
}}
|
|
|
|
|
},
|
|
|
|
|
}}
|
|
|
|
|
},
|
|
|
|
|
}}
|
|
|
|
|
},
|
|
|
|
|
}};
|
|
|
|
|
REQUIRE(tbl == expected);
|
|
|
|
|
});
|
|
|
|
|
|
2021-09-04 09:24:47 +00:00
|
|
|
|
parsing_should_succeed(FILE_LINE_ARGS, table_without_super, [](toml::table&& tbl) // table-without-super
|
2020-10-09 05:50:15 +00:00
|
|
|
|
{
|
2021-06-24 18:08:45 +00:00
|
|
|
|
const auto expected = toml::table{{
|
2020-10-09 05:50:15 +00:00
|
|
|
|
{
|
|
|
|
|
R"(x)"sv, toml::table{{
|
|
|
|
|
{
|
|
|
|
|
R"(y)"sv, toml::table{{
|
|
|
|
|
{
|
|
|
|
|
R"(z)"sv, toml::table{{
|
|
|
|
|
{ R"(w)"sv, toml::table{} },
|
|
|
|
|
}}
|
|
|
|
|
},
|
|
|
|
|
}}
|
|
|
|
|
},
|
|
|
|
|
}}
|
|
|
|
|
},
|
|
|
|
|
}};
|
|
|
|
|
REQUIRE(tbl == expected);
|
|
|
|
|
});
|
|
|
|
|
|
2021-06-24 18:08:45 +00:00
|
|
|
|
#if UNICODE_LITERALS_OK
|
2020-07-05 15:08:28 +00:00
|
|
|
|
|
2021-09-04 09:24:47 +00:00
|
|
|
|
parsing_should_succeed(FILE_LINE_ARGS, table_names, [](toml::table&& tbl) // table-names
|
2020-07-05 15:08:28 +00:00
|
|
|
|
{
|
2021-06-24 18:08:45 +00:00
|
|
|
|
const auto expected = toml::table{{
|
|
|
|
|
{
|
|
|
|
|
R"(a)"sv, toml::table{{
|
|
|
|
|
{ R"( x )"sv, toml::table{} },
|
|
|
|
|
{
|
|
|
|
|
R"(b)"sv, toml::table{{
|
|
|
|
|
{ R"(c)"sv, toml::table{} },
|
|
|
|
|
}}
|
|
|
|
|
},
|
|
|
|
|
{ R"(b.c)"sv, toml::table{} },
|
|
|
|
|
{ R"(d.e)"sv, toml::table{} },
|
|
|
|
|
}}
|
|
|
|
|
},
|
|
|
|
|
{
|
|
|
|
|
R"(d)"sv, toml::table{{
|
|
|
|
|
{
|
|
|
|
|
R"(e)"sv, toml::table{{
|
|
|
|
|
{ R"(f)"sv, toml::table{} },
|
|
|
|
|
}}
|
|
|
|
|
},
|
|
|
|
|
}}
|
|
|
|
|
},
|
|
|
|
|
{
|
|
|
|
|
R"(g)"sv, toml::table{{
|
|
|
|
|
{
|
|
|
|
|
R"(h)"sv, toml::table{{
|
|
|
|
|
{ R"(i)"sv, toml::table{} },
|
|
|
|
|
}}
|
|
|
|
|
},
|
|
|
|
|
}}
|
|
|
|
|
},
|
|
|
|
|
{
|
|
|
|
|
R"(j)"sv, toml::table{{
|
|
|
|
|
{
|
|
|
|
|
R"(ʞ)"sv, toml::table{{
|
|
|
|
|
{ R"(l)"sv, toml::table{} },
|
|
|
|
|
}}
|
|
|
|
|
},
|
|
|
|
|
}}
|
|
|
|
|
},
|
2021-09-04 09:24:47 +00:00
|
|
|
|
{
|
|
|
|
|
R"(x)"sv, toml::table{{
|
|
|
|
|
{
|
|
|
|
|
R"(1)"sv, toml::table{{
|
|
|
|
|
{ R"(2)"sv, toml::table{} },
|
|
|
|
|
}}
|
|
|
|
|
},
|
|
|
|
|
}}
|
|
|
|
|
},
|
2020-07-05 15:08:28 +00:00
|
|
|
|
}};
|
|
|
|
|
REQUIRE(tbl == expected);
|
|
|
|
|
});
|
|
|
|
|
|
2021-06-24 18:08:45 +00:00
|
|
|
|
#endif // UNICODE_LITERALS_OK
|
2020-07-05 15:08:28 +00:00
|
|
|
|
}
|
|
|
|
|
|