mirror of
https://github.com/marzer/tomlplusplus.git
synced 2024-09-04 14:09:11 +00:00
updated conformance tests (see #113)
also removed the 'modern C++' meme text from various places
This commit is contained in:
parent
f3896b7474
commit
9aa7cd8218
@ -127,7 +127,7 @@ FetchContent_MakeAvailable(tomlplusplus)
|
||||
|
||||
### Other environments and package managers
|
||||
`toml++` is a fairly new project and I'm not up-to-speed with all of the available packaging and integration options
|
||||
in the modern C++ ecosystem. I'm also a cmake novice, for better or worse. If there's an integration option missing be
|
||||
in the C++ ecosystem. I'm also a cmake novice, for better or worse. If there's an integration option missing be
|
||||
assured that I fully support it being added, and welcome [pull requests](./CONTRIBUTING.md)!
|
||||
|
||||
<br>
|
||||
|
Binary file not shown.
Binary file not shown.
Before Width: | Height: | Size: 12 KiB After Width: | Height: | Size: 13 KiB |
Binary file not shown.
Before Width: | Height: | Size: 10 KiB After Width: | Height: | Size: 11 KiB |
@ -473,7 +473,7 @@
|
||||
|
||||
\subsection mainpage-adding-lib-other Other environments and package managers
|
||||
toml++ is a fairly new project and I'm not up-to-speed with all of the available packaging and integration options
|
||||
in the modern C++ ecosystem. I'm also a cmake novice, for better or worse. If there's an integration option missing
|
||||
in the C++ ecosystem. I'm also a cmake novice, for better or worse. If there's an integration option missing
|
||||
be assured that I fully support it being added, and welcome pull requests!
|
||||
|
||||
|
||||
|
@ -3,7 +3,7 @@
|
||||
|
||||
name = 'toml++'
|
||||
author = 'Mark Gillard'
|
||||
description = 'TOML for modern C++'
|
||||
description = 'TOML for C++'
|
||||
cpp = 17
|
||||
github = 'marzer/tomlplusplus'
|
||||
license = [ 'MIT', 'https://github.com/marzer/tomlplusplus/blob/master/LICENSE' ]
|
||||
|
2
external/toml-test
vendored
2
external/toml-test
vendored
@ -1 +1 @@
|
||||
Subproject commit 51f2e538628727ca749e10701aaf8d53a4d81bac
|
||||
Subproject commit f2f2280c83f74212860fe0f12ee84581836c066c
|
@ -514,7 +514,7 @@ pkgc = import('pkgconfig')
|
||||
pkgc.generate(
|
||||
name: meson.project_name(),
|
||||
version: meson.project_version(),
|
||||
description: 'Header-only TOML config file parser and serializer for modern C++',
|
||||
description: 'Header-only TOML config file parser and serializer for C++',
|
||||
install_dir: join_paths(get_option('datadir'), 'pkgconfig'),
|
||||
)
|
||||
|
||||
|
@ -259,6 +259,18 @@ 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_injection_1 = R"([a.b.c]
|
||||
z = 9
|
||||
[a]
|
||||
b.c.t = "Using dotted keys to add to [a.b.c] after explicitly defining it above is not allowed"
|
||||
|
||||
# see https://github.com/toml-lang/toml/issues/846)"sv;
|
||||
static constexpr auto table_injection_2 = R"([a.b.c.d]
|
||||
z = 9
|
||||
[a]
|
||||
b.c.d.k.t = "Using dotted keys to add to [a.b.c.d] after explicitly defining it above is not allowed"
|
||||
|
||||
# see https://github.com/toml-lang/toml/issues/846)"sv;
|
||||
static constexpr auto table_llbrace = R"([ [table]])"sv;
|
||||
static constexpr auto table_nested_brackets_close = R"([a]b]
|
||||
zyx = 42)"sv;
|
||||
@ -595,6 +607,10 @@ TEST_CASE("conformance - burntsushi/invalid")
|
||||
|
||||
parsing_should_fail(FILE_LINE_ARGS, table_equals_sign); // table-equals-sign
|
||||
|
||||
parsing_should_fail(FILE_LINE_ARGS, table_injection_1); // table-injection-1
|
||||
|
||||
parsing_should_fail(FILE_LINE_ARGS, table_injection_2); // table-injection-2
|
||||
|
||||
parsing_should_fail(FILE_LINE_ARGS, table_llbrace); // table-llbrace
|
||||
|
||||
parsing_should_fail(FILE_LINE_ARGS, table_nested_brackets_close); // table-nested-brackets-close
|
||||
|
@ -447,6 +447,52 @@ two_space = """ ""two quotes"" """
|
||||
|
||||
mismatch1 = """aaa'''bbb"""
|
||||
mismatch2 = '''aaa"""bbb''')"sv;
|
||||
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;
|
||||
static constexpr auto string_nl = R"(nl_mid = "val\nue"
|
||||
nl_end = """value\n"""
|
||||
|
||||
@ -1622,8 +1668,8 @@ another line)"sv },
|
||||
parsing_should_succeed(FILE_LINE_ARGS, integer_long, [](toml::table&& tbl) // integer-long
|
||||
{
|
||||
const auto expected = toml::table{{
|
||||
{ R"(int64-max)"sv, INT64_MAX },
|
||||
{ R"(int64-max-neg)"sv, INT64_MIN },
|
||||
{ R"(int64-max)"sv, std::numeric_limits<int64_t>::max() },
|
||||
{ R"(int64-max-neg)"sv, std::numeric_limits<int64_t>::min() },
|
||||
}};
|
||||
REQUIRE(tbl == expected);
|
||||
});
|
||||
@ -1817,7 +1863,7 @@ another line)"sv },
|
||||
parsing_should_succeed(FILE_LINE_ARGS, key_empty, [](toml::table&& tbl) // key-empty
|
||||
{
|
||||
const auto expected = toml::table{{
|
||||
{ R"()"sv, R"(blank)"sv },
|
||||
{ ""sv, R"(blank)"sv },
|
||||
}};
|
||||
REQUIRE(tbl == expected);
|
||||
});
|
||||
@ -2063,7 +2109,7 @@ another line)"sv },
|
||||
parsing_should_succeed(FILE_LINE_ARGS, string_empty, [](toml::table&& tbl) // string-empty
|
||||
{
|
||||
const auto expected = toml::table{{
|
||||
{ R"(answer)"sv, R"()"sv },
|
||||
{ R"(answer)"sv, ""sv },
|
||||
}};
|
||||
REQUIRE(tbl == expected);
|
||||
});
|
||||
@ -2093,6 +2139,28 @@ another line)"sv },
|
||||
REQUIRE(tbl == expected);
|
||||
});
|
||||
|
||||
parsing_should_succeed(FILE_LINE_ARGS, string_multiline, [](toml::table&& tbl) // string-multiline
|
||||
{
|
||||
const auto expected = toml::table{{
|
||||
{ R"(equivalent_one)"sv, R"(The quick brown fox jumps over the lazy dog.)"sv },
|
||||
{ R"(equivalent_three)"sv, R"(The quick brown fox jumps over the lazy dog.)"sv },
|
||||
{ R"(equivalent_two)"sv, R"(The quick brown fox jumps over the lazy dog.)"sv },
|
||||
{ R"(escape-bs-1)"sv, R"(a \
|
||||
b)"sv },
|
||||
{ R"(escape-bs-2)"sv, R"(a \b)"sv },
|
||||
{ R"(escape-bs-3)"sv, R"(a \\
|
||||
b)"sv },
|
||||
{ R"(keep-ws-before)"sv, R"(a b)"sv },
|
||||
{ R"(multiline_empty_four)"sv, ""sv },
|
||||
{ R"(multiline_empty_one)"sv, ""sv },
|
||||
{ R"(multiline_empty_three)"sv, ""sv },
|
||||
{ R"(multiline_empty_two)"sv, ""sv },
|
||||
{ R"(no-space)"sv, R"(ab)"sv },
|
||||
{ R"(whitespace-after-bs)"sv, R"(The quick brown fox jumps over the lazy dog.)"sv },
|
||||
}};
|
||||
REQUIRE(tbl == expected);
|
||||
});
|
||||
|
||||
parsing_should_succeed(FILE_LINE_ARGS, string_nl, [](toml::table&& tbl) // string-nl
|
||||
{
|
||||
const auto expected = toml::table{{
|
||||
|
@ -204,6 +204,8 @@ The quick brown \
|
||||
fox jumps over \
|
||||
the lazy dog.\
|
||||
""")"sv;
|
||||
static constexpr auto spec_string_basic_multiline_4 = R"(a = """abc\
|
||||
def""")"sv;
|
||||
static constexpr auto spec_string_basic_multiline_5 = R"(ml-escaped-nl = """
|
||||
foo \
|
||||
bar \\
|
||||
@ -665,7 +667,7 @@ TEST_CASE("conformance - iarna/valid")
|
||||
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 },
|
||||
{ ""sv, R"(blank)"sv },
|
||||
}};
|
||||
REQUIRE(tbl == expected);
|
||||
});
|
||||
@ -673,7 +675,7 @@ TEST_CASE("conformance - iarna/valid")
|
||||
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 },
|
||||
{ ""sv, R"(blank)"sv },
|
||||
}};
|
||||
REQUIRE(tbl == expected);
|
||||
});
|
||||
@ -964,7 +966,7 @@ TEST_CASE("conformance - iarna/valid")
|
||||
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 },
|
||||
{ R"(max)"sv, std::numeric_limits<int64_t>::max() },
|
||||
}};
|
||||
REQUIRE(tbl == expected);
|
||||
});
|
||||
@ -972,7 +974,7 @@ TEST_CASE("conformance - iarna/valid")
|
||||
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 },
|
||||
{ R"(min)"sv, std::numeric_limits<int64_t>::min() },
|
||||
}};
|
||||
REQUIRE(tbl == expected);
|
||||
});
|
||||
@ -1168,6 +1170,14 @@ Violets are blue)"sv },
|
||||
REQUIRE(tbl == expected);
|
||||
});
|
||||
|
||||
parsing_should_succeed(FILE_LINE_ARGS, spec_string_basic_multiline_4, [](toml::table&& tbl) // spec-string-basic-multiline-4
|
||||
{
|
||||
const auto expected = toml::table{{
|
||||
{ R"(a)"sv, R"(abcdef)"sv },
|
||||
}};
|
||||
REQUIRE(tbl == expected);
|
||||
});
|
||||
|
||||
parsing_should_succeed(FILE_LINE_ARGS, spec_string_basic_multiline_5, [](toml::table&& tbl) // spec-string-basic-multiline-5
|
||||
{
|
||||
const auto expected = toml::table{{
|
||||
|
@ -29,8 +29,10 @@ def python_value_to_tomlpp(val):
|
||||
if isinstance(val, str):
|
||||
if re.fullmatch(r'^[+-]?[0-9]+[eE][+-]?[0-9]+$', val, re.M):
|
||||
return str(float(val))
|
||||
elif not val:
|
||||
return r'""sv'
|
||||
else:
|
||||
return 'R"({})"sv'.format(val)
|
||||
return rf'R"({val})"sv'
|
||||
elif isinstance(val, bool):
|
||||
return 'true' if val else 'false'
|
||||
elif isinstance(val, float):
|
||||
@ -42,9 +44,9 @@ def python_value_to_tomlpp(val):
|
||||
return str(val)
|
||||
elif isinstance(val, int):
|
||||
if val == 9223372036854775807:
|
||||
return 'INT64_MAX'
|
||||
return 'std::numeric_limits<int64_t>::max()'
|
||||
elif val == -9223372036854775808:
|
||||
return 'INT64_MIN'
|
||||
return 'std::numeric_limits<int64_t>::min()'
|
||||
else:
|
||||
return str(val)
|
||||
elif isinstance(val, (TomlPPArray, TomlPPTable)):
|
||||
@ -216,6 +218,7 @@ class TomlTest:
|
||||
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()
|
||||
self.__data = re.sub(r'\\[ \t]+?\n', '\\\n', self.__data, re.S) # C++ compilers don't like whitespace after trailing slashes
|
||||
self.__conditions = []
|
||||
if is_valid_case:
|
||||
self.__expected = True
|
||||
@ -323,8 +326,6 @@ def load_valid_inputs(tests, extern_root):
|
||||
'string-escapes',
|
||||
# broken by the json reader
|
||||
'key-alphanum',
|
||||
# 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
|
||||
@ -349,8 +350,6 @@ def load_valid_inputs(tests, extern_root):
|
||||
'spec-date-time-6',
|
||||
'spec-date-time-local-2',
|
||||
'spec-time-2',
|
||||
# whitespace after trailing slash in raw strings breaks GCC
|
||||
'spec-string-basic-multiline-4',
|
||||
))
|
||||
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user