fixed linkage error with windows compat mode

also:
- updated conformance tests
This commit is contained in:
Mark Gillard 2021-06-24 21:08:45 +03:00
parent bc6891e1fb
commit ba754462b8
13 changed files with 2324 additions and 766 deletions

2
external/Catch2 vendored

@ -1 +1 @@
Subproject commit 5c88067bd339465513af4aec606bd2292f1b594a
Subproject commit 7727c15290ce2d289c1809d0eab3cceb88384ad6

2
external/tloptional vendored

@ -1 +1 @@
Subproject commit e28828efa021bf51f1c8cc3248642ec5a636c8d7
Subproject commit c28fcf74d207fc667c4ed3dbae4c251ea551c8c1

2
external/toml-test vendored

@ -1 +1 @@
Subproject commit 9767d201b51ac9c50630f181828bcd922bf3e9e5
Subproject commit 1f6389604dc6053f23cc4679c557a0b0e69eaf5d

View File

@ -100,6 +100,7 @@ TOML_POP_WARNINGS; // TOML_DISABLE_SPAM_WARNINGS
#undef TOML_IMPLEMENTATION
#undef TOML_IMPL_NAMESPACE_END
#undef TOML_IMPL_NAMESPACE_START
#undef TOML_INCLUDE_WINDOWS_H
#undef TOML_INT128
#undef TOML_INTELLISENSE
#undef TOML_INTERNAL_LINKAGE
@ -111,7 +112,8 @@ TOML_POP_WARNINGS; // TOML_DISABLE_SPAM_WARNINGS
#undef TOML_LAUNDER
#undef TOML_LIFETIME_HOOKS
#undef TOML_LIKELY
#undef TOML_MAKE_BITOPS
#undef TOML_MAKE_FLAGS_
#undef TOML_MAKE_FLAGS
#undef TOML_MAKE_VERSION
#undef TOML_MAY_THROW
#undef TOML_MSVC

View File

@ -995,7 +995,7 @@ TOML_NAMESPACE_START
/// \brief Format integer values as hexadecimal.
format_as_hexadecimal = 3,
};
TOML_MAKE_BITOPS(value_flags);
TOML_MAKE_FLAGS(value_flags);
/// \brief Format flags for modifying how TOML data is printed to streams.
enum class format_flags : uint8_t
@ -1015,7 +1015,7 @@ TOML_NAMESPACE_START
/// \brief Values with special format flags will be formatted accordingly.
allow_value_format_flags = 8,
};
TOML_MAKE_BITOPS(format_flags);
TOML_MAKE_FLAGS(format_flags);
/// \brief Pretty-prints the value of a node_type to a stream.
///

View File

@ -202,27 +202,34 @@ TOML_NAMESPACE_END;
#if TOML_WINDOWS_COMPAT
#ifndef _WINDOWS_
extern "C"
{
int __stdcall WideCharToMultiByte(
unsigned int CodePage,
unsigned long dwFlags,
const wchar_t* lpWideCharStr,
int cchWideChar,
char* lpMultiByteStr,
int cbMultiByte,
const char* lpDefaultChar,
int* lpUsedDefaultChar
);
int __stdcall MultiByteToWideChar(
unsigned int CodePage,
unsigned long dwFlags,
const char* lpMultiByteStr,
int cbMultiByte,
wchar_t* lpWideCharStr,
int cchWideChar
);
}
#if TOML_INCLUDE_WINDOWS_H
#include <Windows.h>
#else
extern "C"
{
__declspec(dllimport)
int __stdcall WideCharToMultiByte(
unsigned int CodePage,
unsigned long dwFlags,
const wchar_t* lpWideCharStr,
int cchWideChar,
char* lpMultiByteStr,
int cbMultiByte,
const char* lpDefaultChar,
int* lpUsedDefaultChar
);
__declspec(dllimport)
int __stdcall MultiByteToWideChar(
unsigned int CodePage,
unsigned long dwFlags,
const char* lpMultiByteStr,
int cbMultiByte,
wchar_t* lpWideCharStr,
int cchWideChar
);
}
#endif
#endif // _WINDOWS_
TOML_IMPL_NAMESPACE_START
@ -234,13 +241,13 @@ TOML_IMPL_NAMESPACE_START
return {};
std::string s;
const auto len = WideCharToMultiByte(
const auto len = ::WideCharToMultiByte(
65001, 0, str.data(), static_cast<int>(str.length()), nullptr, 0, nullptr, nullptr
);
if (len)
{
s.resize(static_cast<size_t>(len));
WideCharToMultiByte(65001, 0, str.data(), static_cast<int>(str.length()), s.data(), len, nullptr, nullptr);
::WideCharToMultiByte(65001, 0, str.data(), static_cast<int>(str.length()), s.data(), len, nullptr, nullptr);
}
return s;
}
@ -252,11 +259,11 @@ TOML_IMPL_NAMESPACE_START
return {};
std::wstring s;
const auto len = MultiByteToWideChar(65001, 0, str.data(), static_cast<int>(str.length()), nullptr, 0);
const auto len = ::MultiByteToWideChar(65001, 0, str.data(), static_cast<int>(str.length()), nullptr, 0);
if (len)
{
s.resize(static_cast<size_t>(len));
MultiByteToWideChar(65001, 0, str.data(), static_cast<int>(str.length()), s.data(), len);
::MultiByteToWideChar(65001, 0, str.data(), static_cast<int>(str.length()), s.data(), len);
}
return s;
}

View File

@ -393,12 +393,21 @@
#endif
#ifndef DOXYGEN
#if defined(_WIN32) && !defined(TOML_WINDOWS_COMPAT)
#define TOML_WINDOWS_COMPAT 1
#ifdef _WIN32
#ifndef TOML_WINDOWS_COMPAT
#define TOML_WINDOWS_COMPAT 1
#endif
#if TOML_WINDOWS_COMPAT && !defined(TOML_INCLUDE_WINDOWS_H)
#define TOML_INCLUDE_WINDOWS_H 0
#endif
#endif
#if !defined(_WIN32) || !defined(TOML_WINDOWS_COMPAT)
#undef TOML_WINDOWS_COMPAT
#define TOML_WINDOWS_COMPAT 0
#define TOML_WINDOWS_COMPAT 0
#endif
#if !TOML_WINDOWS_COMPAT
#undef TOML_INCLUDE_WINDOWS_H
#define TOML_INCLUDE_WINDOWS_H 0
#endif
#endif
@ -609,24 +618,43 @@ is no longer necessary.
#define TOML_ARM 0
#endif
#define TOML_MAKE_BITOPS(type) \
#define TOML_MAKE_FLAGS_(name, op) \
[[nodiscard]] \
TOML_ALWAYS_INLINE \
TOML_ATTR(const) \
TOML_ATTR(flatten) \
constexpr type operator & (type lhs, type rhs) noexcept \
constexpr name operator op(name lhs, name rhs) noexcept \
{ \
return static_cast<type>(::toml::impl::unwrap_enum(lhs) & ::toml::impl::unwrap_enum(rhs)); \
using under = std::underlying_type_t<name>; \
return static_cast<name>(static_cast<under>(lhs) op static_cast<under>(rhs)); \
} \
constexpr name& operator TOML_CONCAT(op, =)(name & lhs, name rhs) noexcept \
{ \
return lhs = (lhs op rhs); \
} \
static_assert(true, "")
#define TOML_MAKE_FLAGS(name) \
TOML_MAKE_FLAGS_(name, &); \
TOML_MAKE_FLAGS_(name, |); \
TOML_MAKE_FLAGS_(name, ^); \
[[nodiscard]] \
TOML_ALWAYS_INLINE \
TOML_ATTR(const) \
constexpr name operator~(name val) noexcept \
{ \
using under = std::underlying_type_t<name>; \
return static_cast<name>(~static_cast<under>(val)); \
} \
[[nodiscard]] \
TOML_ALWAYS_INLINE \
TOML_ATTR(const) \
TOML_ATTR(flatten) \
constexpr type operator | (type lhs, type rhs) noexcept \
constexpr bool operator!(name val) noexcept \
{ \
return static_cast<type>(::toml::impl::unwrap_enum(lhs) | ::toml::impl::unwrap_enum(rhs)); \
using under = std::underlying_type_t<name>; \
return !static_cast<under>(val); \
} \
static_assert(true)
static_assert(true, "")
#ifndef TOML_LIFETIME_HOOKS
#define TOML_LIFETIME_HOOKS 0

View File

@ -12,12 +12,42 @@ TOML_DISABLE_WARNINGS; // unused variable spam
namespace
{
static constexpr auto array_missing_separator = R"(wrong = [ 1 2 3 ])"sv;
static constexpr auto array_no_close_2 = R"(x = [42 #)"sv;
static constexpr auto array_no_close_table_2 = R"(x = [{ key = 42 #)"sv;
static constexpr auto array_no_close_table = R"(x = [{ key = 42)"sv;
static constexpr auto array_no_close = R"(long_array = [ 1, 2, 3)"sv;
static constexpr auto array_of_tables_1 = R"(# INVALID TOML DOC
fruit = []
[[fruit]] # Not allowed)"sv;
static constexpr auto array_of_tables_2 = R"(# INVALID TOML DOC
[[fruit]]
name = "apple"
[[fruit.variety]]
name = "red delicious"
# This table conflicts with the previous table
[fruit.variety]
name = "granny smith")"sv;
static constexpr auto bool_mixed_case = R"(valid = False)"sv;
static constexpr auto bool_wrong_case_false = R"(b = FALSE)"sv;
static constexpr auto bool_wrong_case_true = R"(a = TRUE)"sv;
static constexpr auto datetime_malformed_no_leads = R"(no-leads = 1987-7-05T17:45:00Z)"sv;
static constexpr auto datetime_malformed_no_secs = R"(no-secs = 1987-07-05T17:45Z)"sv;
static constexpr auto datetime_malformed_no_t = R"(no-t = 1987-07-0517:45:00Z)"sv;
static constexpr auto datetime_malformed_with_milli = R"(with-milli = 1987-07-5T17:45:00.12Z)"sv;
static constexpr auto datetime_impossible_date = R"(d = 2006-01-50T00:00:00Z)"sv;
static constexpr auto datetime_no_leads_with_milli = R"(with-milli = 1987-07-5T17:45:00.12Z)"sv;
static constexpr auto datetime_no_leads = R"(no-leads = 1987-7-05T17:45:00Z)"sv;
static constexpr auto datetime_no_t = R"(no-t = 1987-07-0517:45:00Z)"sv;
static constexpr auto datetime_trailing_t = R"(d = 2006-01-30T)"sv;
#if !TOML_LANG_UNRELEASED
static constexpr auto datetime_no_secs = R"(no-secs = 1987-07-05T17:45Z)"sv;
#endif // !TOML_LANG_UNRELEASED
static constexpr auto duplicate_key_table = R"([fruit]
type = "apple"
@ -25,58 +55,187 @@ type = "apple"
apple = "yes")"sv;
static constexpr auto duplicate_keys = R"(dupe = false
dupe = true)"sv;
static constexpr auto duplicate_table_array = R"([tbl]
[[tbl]])"sv;
static constexpr auto duplicate_table_array2 = R"([[tbl]]
[tbl])"sv;
static constexpr auto duplicate_tables = R"([a]
[a])"sv;
static constexpr auto empty_implicit_table = R"([naughty..naughty])"sv;
static constexpr auto empty_table = R"([])"sv;
static constexpr auto float_leading_zero_neg = R"(leading-zero = -03.14)"sv;
static constexpr auto float_leading_zero_pos = R"(leading-zero = +03.14)"sv;
static constexpr auto float_double_point_1 = R"(double-point-1 = 0..1)"sv;
static constexpr auto float_double_point_2 = R"(double-point-2 = 0.1.2)"sv;
static constexpr auto float_exp_double_e_1 = R"(exp-double-e-1 = 1ee2)"sv;
static constexpr auto float_exp_double_e_2 = R"(exp-double-e-2 = 1e2e3)"sv;
static constexpr auto float_exp_double_us = R"(exp-double-us = 1e__23)"sv;
static constexpr auto float_exp_leading_us = R"(exp-leading-us = 1e_23)"sv;
static constexpr auto float_exp_point_1 = R"(exp-point-1 = 1e2.3)"sv;
static constexpr auto float_exp_point_2 = R"(exp-point-2 = 1.e2)"sv;
static constexpr auto float_exp_trailing_us = R"(exp-trailing-us = 1e_23_)"sv;
static constexpr auto float_inf_incomplete_1 = R"(inf-incomplete-1 = in)"sv;
static constexpr auto float_inf_incomplete_2 = R"(inf-incomplete-2 = +in)"sv;
static constexpr auto float_inf_incomplete_3 = R"(inf-incomplete-3 = -in)"sv;
static constexpr auto float_inf_underscore = R"(inf_underscore = in_f)"sv;
static constexpr auto float_leading_point_neg = R"(leading-point-neg = -.12345)"sv;
static constexpr auto float_leading_point_plus = R"(leading-point-plus = +.12345)"sv;
static constexpr auto float_leading_point = R"(leading-point = .12345)"sv;
static constexpr auto float_leading_us = R"(leading-us = _1.2)"sv;
static constexpr auto float_leading_zero_neg = R"(leading-zero-neg = -03.14)"sv;
static constexpr auto float_leading_zero_plus = R"(leading-zero-plus = +03.14)"sv;
static constexpr auto float_leading_zero = R"(leading-zero = 03.14)"sv;
static constexpr auto float_no_leading_zero = R"(answer = .12345
neganswer = -.12345)"sv;
static constexpr auto float_no_trailing_digits = R"(answer = 1.
neganswer = -1.)"sv;
static constexpr auto float_underscore_after_point = R"(bad = 1._2)"sv;
static constexpr auto float_underscore_after = R"(bad = 1.2_)"sv;
static constexpr auto float_underscore_before_point = R"(bad = 1_.2)"sv;
static constexpr auto float_underscore_before = R"(bad = _1.2)"sv;
static constexpr auto inline_table_linebreak = R"(simple = { a = 1
static constexpr auto float_nan_incomplete_1 = R"(nan-incomplete-1 = na)"sv;
static constexpr auto float_nan_incomplete_2 = R"(nan-incomplete-2 = +na)"sv;
static constexpr auto float_nan_incomplete_3 = R"(nan-incomplete-3 = -na)"sv;
static constexpr auto float_nan_underscore = R"(nan_underscore = na_n)"sv;
static constexpr auto float_trailing_point_min = R"(trailing-point-min = -1.)"sv;
static constexpr auto float_trailing_point_plus = R"(trailing-point-plus = +1.)"sv;
static constexpr auto float_trailing_point = R"(trailing-point = 1.)"sv;
static constexpr auto float_trailing_us = R"(trailing-us = 1.2_)"sv;
static constexpr auto float_us_after_point = R"(us-after-point = 1._2)"sv;
static constexpr auto float_us_before_point = R"(us-before-point = 1_.2)"sv;
static constexpr auto inline_table_double_comma = R"(t = {x=3,,y=4})"sv;
static constexpr auto inline_table_empty = R"(t = {,})"sv;
static constexpr auto inline_table_no_comma = R"(t = {x = 3 y = 4})"sv;
#if !TOML_LANG_UNRELEASED
static constexpr auto inline_table_linebreak_1 = R"(# No newlines are allowed between the curly braces unless they are valid within
# a value.
simple = { a = 1
})"sv;
static constexpr auto integer_leading_zero_neg = R"(leading-zero = -012)"sv;
static constexpr auto integer_leading_zero_pos = R"(leading-zero = +012)"sv;
static constexpr auto integer_leading_zero = R"(leading-zero = 012)"sv;
static constexpr auto integer_underscore_after = R"(bad = 123_)"sv;
static constexpr auto integer_underscore_before = R"(bad = _123)"sv;
static constexpr auto integer_underscore_double = R"(bad = 1__23)"sv;
static constexpr auto inline_table_linebreak_2 = R"(t = {a=1,
b=2})"sv;
static constexpr auto inline_table_linebreak_3 = R"(t = {a=1
,b=2})"sv;
static constexpr auto inline_table_trailing_comma = R"(# A terminating comma (also called trailing comma) is not permitted after the
# last key/value pair in an inline table
abc = { abc = 123, })"sv;
#endif // !TOML_LANG_UNRELEASED
static constexpr auto integer_capital_bin = R"(capital-bin = 0B0)"sv;
static constexpr auto integer_capital_hex = R"(capital-hex = 0X1)"sv;
static constexpr auto integer_capital_oct = R"(capital-oct = 0O0)"sv;
static constexpr auto integer_double_sign_nex = R"(double-sign-nex = --99)"sv;
static constexpr auto integer_double_sign_plus = R"(double-sign-plus = ++99)"sv;
static constexpr auto integer_double_us = R"(double-us = 1__23)"sv;
static constexpr auto integer_invalid_bin = R"(invalid-bin = 0b0012)"sv;
static constexpr auto integer_invalid_hex = R"(invalid-hex = 0xaafz)"sv;
static constexpr auto integer_invalid_oct = R"(invalid-oct = 0o778)"sv;
static constexpr auto integer_leading_us_bin = R"(leading-us-bin = _0o1)"sv;
static constexpr auto integer_leading_us_hex = R"(leading-us-hex = _0o1)"sv;
static constexpr auto integer_leading_us_oct = R"(leading-us-oct = _0o1)"sv;
static constexpr auto integer_leading_us = R"(leading-us = _123)"sv;
static constexpr auto integer_leading_zero_1 = R"(leading-zero-1 = 01)"sv;
static constexpr auto integer_leading_zero_2 = R"(leading-zero-2 = 00)"sv;
static constexpr auto integer_leading_zero_sign_1 = R"(leading-zero-sign-1 = -01)"sv;
static constexpr auto integer_leading_zero_sign_2 = R"(leading-zero-sign-2 = +01)"sv;
static constexpr auto integer_negative_bin = R"(negative-bin = -0b11010110)"sv;
static constexpr auto integer_negative_hex = R"(negative-hex = -0xff)"sv;
static constexpr auto integer_negative_oct = R"(negative-oct = -0o99)"sv;
static constexpr auto integer_positive_bin = R"(positive-bin = +0b11010110)"sv;
static constexpr auto integer_positive_hex = R"(positive-hex = +0xff)"sv;
static constexpr auto integer_positive_oct = R"(positive-oct = +0o99)"sv;
static constexpr auto integer_trailing_us_bin = R"(trailing-us-bin = 0b1_)"sv;
static constexpr auto integer_trailing_us_hex = R"(trailing-us-hex = 0x1_)"sv;
static constexpr auto integer_trailing_us_oct = R"(trailing-us-oct = 0o1_)"sv;
static constexpr auto integer_trailing_us = R"(trailing-us = 123_)"sv;
static constexpr auto integer_us_after_bin = R"(us-after-bin = 0b_1)"sv;
static constexpr auto integer_us_after_hex = R"(us-after-hex = 0x_1)"sv;
static constexpr auto integer_us_after_oct = R"(us-after-oct = 0o_1)"sv;
static constexpr auto key_after_array = R"([[agencies]] owner = "S Cjelli")"sv;
static constexpr auto key_after_table = R"([error] this = "should not be here")"sv;
static constexpr auto key_after_value = R"(first = "Tom" last = "Preston-Werner" # INVALID)"sv;
static constexpr auto key_bare_invalid_character = R"(bare!key = 123)"sv;
static constexpr auto key_dotted_redefine_table = R"(# Defined a.b as int
a.b = 1
# Tries to access it as table: error
a.b.c = 2)"sv;
static constexpr auto key_duplicate = R"(# DO NOT DO THIS
name = "Tom"
name = "Pradyun")"sv;
static constexpr auto key_empty = R"(= 1)"sv;
static constexpr auto key_escape = R"(\u00c0 = "latin capital letter A with grave")"sv;
static constexpr auto key_hash = R"(a# = 1)"sv;
static constexpr auto key_newline = R"(a
= 1)"sv;
static constexpr auto key_multiline = R"("""long
key""" = 1)"sv;
static constexpr auto key_newline = R"(barekey
= 123)"sv;
static constexpr auto key_no_eol = R"(a = 1 b = 2)"sv;
static constexpr auto key_open_bracket = R"([abc = 1)"sv;
static constexpr auto key_partial_quoted = R"(partial"quoted" = 5)"sv;
static constexpr auto key_single_open_bracket = R"([)"sv;
static constexpr auto key_space = R"(a b = 1)"sv;
static constexpr auto key_start_bracket = R"([a]
[xyz = 5
[b])"sv;
static constexpr auto key_two_equals = R"(key= = 1)"sv;
static constexpr auto key_two_equals2 = R"(a==1)"sv;
static constexpr auto key_two_equals3 = R"(a=b=1)"sv;
static constexpr auto key_without_value_1 = R"(key)"sv;
static constexpr auto key_without_value_2 = R"(key =)"sv;
#if !TOML_LANG_UNRELEASED && UNICODE_LITERALS_OK
static constexpr auto key_special_character = R"(μ = "greek small letter mu")"sv;
#endif // !TOML_LANG_UNRELEASED && UNICODE_LITERALS_OK
static constexpr auto llbrace = R"([ [table]])"sv;
#if !TOML_LANG_UNRELEASED
static constexpr auto multi_line_inline_table = R"(json_like = {
first = "Tom",
last = "Preston-Werner"
})"sv;
#endif // !TOML_LANG_UNRELEASED
static constexpr auto multi_line_string_no_close_2 = R"(x=""")"sv;
static constexpr auto multi_line_string_no_close = R"(invalid = """
this will fail)"sv;
static constexpr auto rrbrace = R"([[table] ])"sv;
static constexpr auto string_bad_byte_escape = R"(naughty = "\xAg")"sv;
static constexpr auto string_bad_codepoint = R"(invalid-codepoint = "This string contains a non scalar unicode codepoint \uD801")"sv;
static constexpr auto string_bad_concat = R"(no_concat = "first" "second")"sv;
static constexpr auto string_bad_escape = R"(invalid-escape = "This string has a bad \a escape character.")"sv;
static constexpr auto string_bad_multiline = R"(multi = "first line
second line")"sv;
static constexpr auto string_bad_slash_escape = R"(invalid-escape = "This string has a bad \/ escape character.")"sv;
static constexpr auto string_bad_uni_esc = R"(str = "val\ue")"sv;
static constexpr auto string_byte_escapes = R"(answer = "\x33")"sv;
static constexpr auto string_basic_multiline_out_of_range_unicode_escape_1 = R"(a = """\UFFFFFFFF""")"sv;
static constexpr auto string_basic_multiline_out_of_range_unicode_escape_2 = R"(a = """\U00D80000""")"sv;
static constexpr auto string_basic_multiline_quotes = R"(str5 = """Here are three quotation marks: """.""")"sv;
static constexpr auto string_basic_multiline_unknown_escape = R"(a = """\@""")"sv;
static constexpr auto string_basic_out_of_range_unicode_escape_1 = R"(a = "\UFFFFFFFF")"sv;
static constexpr auto string_basic_out_of_range_unicode_escape_2 = R"(a = "\U00D80000")"sv;
static constexpr auto string_basic_unknown_escape = R"(a = "\@")"sv;
static constexpr auto string_literal_multiline_quotes_1 = R"(a = '''6 apostrophes: '''''')"sv;
static constexpr auto string_literal_multiline_quotes_2 = R"(a = '''15 apostrophes: '''''''''''''''''')"sv;
static constexpr auto string_missing_quotes = R"(name = value)"sv;
static constexpr auto string_multiline_escape_space = R"(a = """
foo \ \n
bar""")"sv;
static constexpr auto string_multiline_quotes_1 = R"(a = """6 quotes: """""")"sv;
static constexpr auto string_multiline_quotes_2 = R"(a = """6 quotes: """""")"sv;
static constexpr auto string_no_close = R"(no-ending-quote = "One time, at band camp)"sv;
static constexpr auto string_wrong_close = R"(bad-ending-quote = "double and single')"sv;
#if !TOML_LANG_UNRELEASED
static constexpr auto string_basic_byte_escapes = R"(answer = "\x33")"sv;
#endif // !TOML_LANG_UNRELEASED
static constexpr auto table_array_empty = R"([[]]
name = "Born to Run")"sv;
static constexpr auto table_array_implicit = R"(# This test is a bit tricky. It should fail because the first use of
# `[[albums.songs]]` without first declaring `albums` implies that `albums`
# must be a table. The alternative would be quite weird. Namely, it wouldn't
@ -91,18 +250,31 @@ name = "Glory Days"
[[albums]]
name = "Born in the USA")"sv;
static constexpr auto table_array_malformed_bracket = R"([[albums]
name = "Born to Run")"sv;
static constexpr auto table_array_malformed_empty = R"([[]]
static constexpr auto table_array_missing_bracket = R"([[albums]
name = "Born to Run")"sv;
static constexpr auto table_duplicate = R"([a]
b = 1
[a]
c = 2)"sv;
static constexpr auto table_empty = R"([])"sv;
static constexpr auto table_equals_sign = R"([name=bad])"sv;
static constexpr auto table_nested_brackets_close = R"([a]b]
zyx = 42)"sv;
static constexpr auto table_nested_brackets_open = R"([a[b]
zyx = 42)"sv;
static constexpr auto table_quoted_no_close = R"(["where will it end]
name = value)"sv;
static constexpr auto table_redefine = R"(# Define b as int, and try to use it as a table: error
[a]
b = 1
[a.b]
c = 2)"sv;
static constexpr auto table_whitespace = R"([invalid key])"sv;
static constexpr auto table_with_pound = R"([key#group]
answer = 42)"sv;
static constexpr auto text_after_array_entries = R"(array = [
"Is there life after an array separator?", No
"Entry"
@ -125,71 +297,342 @@ TOML_ENABLE_WARNINGS;
TEST_CASE("conformance - burntsushi/invalid")
{
parsing_should_fail(FILE_LINE_ARGS, bool_wrong_case_false);
parsing_should_fail(FILE_LINE_ARGS, bool_wrong_case_true);
parsing_should_fail(FILE_LINE_ARGS, datetime_malformed_no_leads);
parsing_should_fail(FILE_LINE_ARGS, datetime_malformed_no_t);
parsing_should_fail(FILE_LINE_ARGS, datetime_malformed_with_milli);
parsing_should_fail(FILE_LINE_ARGS, duplicate_key_table);
parsing_should_fail(FILE_LINE_ARGS, duplicate_keys);
parsing_should_fail(FILE_LINE_ARGS, duplicate_tables);
parsing_should_fail(FILE_LINE_ARGS, empty_implicit_table);
parsing_should_fail(FILE_LINE_ARGS, empty_table);
parsing_should_fail(FILE_LINE_ARGS, float_leading_zero_neg);
parsing_should_fail(FILE_LINE_ARGS, float_leading_zero_pos);
parsing_should_fail(FILE_LINE_ARGS, float_leading_zero);
parsing_should_fail(FILE_LINE_ARGS, float_no_leading_zero);
parsing_should_fail(FILE_LINE_ARGS, float_no_trailing_digits);
parsing_should_fail(FILE_LINE_ARGS, float_underscore_after_point);
parsing_should_fail(FILE_LINE_ARGS, float_underscore_after);
parsing_should_fail(FILE_LINE_ARGS, float_underscore_before_point);
parsing_should_fail(FILE_LINE_ARGS, float_underscore_before);
parsing_should_fail(FILE_LINE_ARGS, integer_leading_zero_neg);
parsing_should_fail(FILE_LINE_ARGS, integer_leading_zero_pos);
parsing_should_fail(FILE_LINE_ARGS, integer_leading_zero);
parsing_should_fail(FILE_LINE_ARGS, integer_underscore_after);
parsing_should_fail(FILE_LINE_ARGS, integer_underscore_before);
parsing_should_fail(FILE_LINE_ARGS, integer_underscore_double);
parsing_should_fail(FILE_LINE_ARGS, key_after_array);
parsing_should_fail(FILE_LINE_ARGS, key_after_table);
parsing_should_fail(FILE_LINE_ARGS, key_empty);
parsing_should_fail(FILE_LINE_ARGS, key_hash);
parsing_should_fail(FILE_LINE_ARGS, key_newline);
parsing_should_fail(FILE_LINE_ARGS, key_no_eol);
parsing_should_fail(FILE_LINE_ARGS, key_open_bracket);
parsing_should_fail(FILE_LINE_ARGS, key_single_open_bracket);
parsing_should_fail(FILE_LINE_ARGS, key_space);
parsing_should_fail(FILE_LINE_ARGS, key_start_bracket);
parsing_should_fail(FILE_LINE_ARGS, key_two_equals);
parsing_should_fail(FILE_LINE_ARGS, llbrace);
parsing_should_fail(FILE_LINE_ARGS, multi_line_string_no_close);
parsing_should_fail(FILE_LINE_ARGS, rrbrace);
parsing_should_fail(FILE_LINE_ARGS, string_bad_byte_escape);
parsing_should_fail(FILE_LINE_ARGS, string_bad_codepoint);
parsing_should_fail(FILE_LINE_ARGS, string_bad_escape);
parsing_should_fail(FILE_LINE_ARGS, string_bad_slash_escape);
parsing_should_fail(FILE_LINE_ARGS, string_bad_uni_esc);
parsing_should_fail(FILE_LINE_ARGS, string_no_close);
parsing_should_fail(FILE_LINE_ARGS, table_array_implicit);
parsing_should_fail(FILE_LINE_ARGS, table_array_malformed_bracket);
parsing_should_fail(FILE_LINE_ARGS, table_array_malformed_empty);
parsing_should_fail(FILE_LINE_ARGS, table_empty);
parsing_should_fail(FILE_LINE_ARGS, table_nested_brackets_close);
parsing_should_fail(FILE_LINE_ARGS, table_nested_brackets_open);
parsing_should_fail(FILE_LINE_ARGS, table_whitespace);
parsing_should_fail(FILE_LINE_ARGS, table_with_pound);
parsing_should_fail(FILE_LINE_ARGS, text_after_array_entries);
parsing_should_fail(FILE_LINE_ARGS, text_after_integer);
parsing_should_fail(FILE_LINE_ARGS, text_after_string);
parsing_should_fail(FILE_LINE_ARGS, text_after_table);
parsing_should_fail(FILE_LINE_ARGS, text_before_array_separator);
parsing_should_fail(FILE_LINE_ARGS, text_in_array);
parsing_should_fail(FILE_LINE_ARGS, array_missing_separator);
parsing_should_fail(FILE_LINE_ARGS, array_no_close_2);
parsing_should_fail(FILE_LINE_ARGS, array_no_close_table_2);
parsing_should_fail(FILE_LINE_ARGS, array_no_close_table);
parsing_should_fail(FILE_LINE_ARGS, array_no_close);
parsing_should_fail(FILE_LINE_ARGS, array_of_tables_1);
parsing_should_fail(FILE_LINE_ARGS, array_of_tables_2);
parsing_should_fail(FILE_LINE_ARGS, bool_mixed_case);
parsing_should_fail(FILE_LINE_ARGS, bool_wrong_case_false);
parsing_should_fail(FILE_LINE_ARGS, bool_wrong_case_true);
parsing_should_fail(FILE_LINE_ARGS, datetime_impossible_date);
parsing_should_fail(FILE_LINE_ARGS, datetime_no_leads_with_milli);
parsing_should_fail(FILE_LINE_ARGS, datetime_no_leads);
parsing_should_fail(FILE_LINE_ARGS, datetime_no_t);
parsing_should_fail(FILE_LINE_ARGS, datetime_trailing_t);
#if !TOML_LANG_UNRELEASED
parsing_should_fail(FILE_LINE_ARGS, datetime_no_secs);
#endif // !TOML_LANG_UNRELEASED
parsing_should_fail(FILE_LINE_ARGS, duplicate_key_table);
parsing_should_fail(FILE_LINE_ARGS, duplicate_keys);
parsing_should_fail(FILE_LINE_ARGS, duplicate_table_array);
parsing_should_fail(FILE_LINE_ARGS, duplicate_table_array2);
parsing_should_fail(FILE_LINE_ARGS, duplicate_tables);
parsing_should_fail(FILE_LINE_ARGS, empty_implicit_table);
parsing_should_fail(FILE_LINE_ARGS, empty_table);
parsing_should_fail(FILE_LINE_ARGS, float_double_point_1);
parsing_should_fail(FILE_LINE_ARGS, float_double_point_2);
parsing_should_fail(FILE_LINE_ARGS, float_exp_double_e_1);
parsing_should_fail(FILE_LINE_ARGS, float_exp_double_e_2);
parsing_should_fail(FILE_LINE_ARGS, float_exp_double_us);
parsing_should_fail(FILE_LINE_ARGS, float_exp_leading_us);
parsing_should_fail(FILE_LINE_ARGS, float_exp_point_1);
parsing_should_fail(FILE_LINE_ARGS, float_exp_point_2);
parsing_should_fail(FILE_LINE_ARGS, float_exp_trailing_us);
parsing_should_fail(FILE_LINE_ARGS, float_inf_incomplete_1);
parsing_should_fail(FILE_LINE_ARGS, float_inf_incomplete_2);
parsing_should_fail(FILE_LINE_ARGS, float_inf_incomplete_3);
parsing_should_fail(FILE_LINE_ARGS, float_inf_underscore);
parsing_should_fail(FILE_LINE_ARGS, float_leading_point_neg);
parsing_should_fail(FILE_LINE_ARGS, float_leading_point_plus);
parsing_should_fail(FILE_LINE_ARGS, float_leading_point);
parsing_should_fail(FILE_LINE_ARGS, float_leading_us);
parsing_should_fail(FILE_LINE_ARGS, float_leading_zero_neg);
parsing_should_fail(FILE_LINE_ARGS, float_leading_zero_plus);
parsing_should_fail(FILE_LINE_ARGS, float_leading_zero);
parsing_should_fail(FILE_LINE_ARGS, float_nan_incomplete_1);
parsing_should_fail(FILE_LINE_ARGS, float_nan_incomplete_2);
parsing_should_fail(FILE_LINE_ARGS, float_nan_incomplete_3);
parsing_should_fail(FILE_LINE_ARGS, float_nan_underscore);
parsing_should_fail(FILE_LINE_ARGS, float_trailing_point_min);
parsing_should_fail(FILE_LINE_ARGS, float_trailing_point_plus);
parsing_should_fail(FILE_LINE_ARGS, float_trailing_point);
parsing_should_fail(FILE_LINE_ARGS, float_trailing_us);
parsing_should_fail(FILE_LINE_ARGS, float_us_after_point);
parsing_should_fail(FILE_LINE_ARGS, float_us_before_point);
parsing_should_fail(FILE_LINE_ARGS, inline_table_double_comma);
parsing_should_fail(FILE_LINE_ARGS, inline_table_empty);
parsing_should_fail(FILE_LINE_ARGS, inline_table_no_comma);
#if !TOML_LANG_UNRELEASED
parsing_should_fail(FILE_LINE_ARGS, inline_table_linebreak_1);
parsing_should_fail(FILE_LINE_ARGS, inline_table_linebreak_2);
parsing_should_fail(FILE_LINE_ARGS, inline_table_linebreak_3);
parsing_should_fail(FILE_LINE_ARGS, inline_table_trailing_comma);
#endif // !TOML_LANG_UNRELEASED
parsing_should_fail(FILE_LINE_ARGS, integer_capital_bin);
parsing_should_fail(FILE_LINE_ARGS, integer_capital_hex);
parsing_should_fail(FILE_LINE_ARGS, integer_capital_oct);
parsing_should_fail(FILE_LINE_ARGS, integer_double_sign_nex);
parsing_should_fail(FILE_LINE_ARGS, integer_double_sign_plus);
parsing_should_fail(FILE_LINE_ARGS, integer_double_us);
parsing_should_fail(FILE_LINE_ARGS, integer_invalid_bin);
parsing_should_fail(FILE_LINE_ARGS, integer_invalid_hex);
parsing_should_fail(FILE_LINE_ARGS, integer_invalid_oct);
parsing_should_fail(FILE_LINE_ARGS, integer_leading_us_bin);
parsing_should_fail(FILE_LINE_ARGS, integer_leading_us_hex);
parsing_should_fail(FILE_LINE_ARGS, integer_leading_us_oct);
parsing_should_fail(FILE_LINE_ARGS, integer_leading_us);
parsing_should_fail(FILE_LINE_ARGS, integer_leading_zero_1);
parsing_should_fail(FILE_LINE_ARGS, integer_leading_zero_2);
parsing_should_fail(FILE_LINE_ARGS, integer_leading_zero_sign_1);
parsing_should_fail(FILE_LINE_ARGS, integer_leading_zero_sign_2);
parsing_should_fail(FILE_LINE_ARGS, integer_negative_bin);
parsing_should_fail(FILE_LINE_ARGS, integer_negative_hex);
parsing_should_fail(FILE_LINE_ARGS, integer_negative_oct);
parsing_should_fail(FILE_LINE_ARGS, integer_positive_bin);
parsing_should_fail(FILE_LINE_ARGS, integer_positive_hex);
parsing_should_fail(FILE_LINE_ARGS, integer_positive_oct);
parsing_should_fail(FILE_LINE_ARGS, integer_trailing_us_bin);
parsing_should_fail(FILE_LINE_ARGS, integer_trailing_us_hex);
parsing_should_fail(FILE_LINE_ARGS, integer_trailing_us_oct);
parsing_should_fail(FILE_LINE_ARGS, integer_trailing_us);
parsing_should_fail(FILE_LINE_ARGS, integer_us_after_bin);
parsing_should_fail(FILE_LINE_ARGS, integer_us_after_hex);
parsing_should_fail(FILE_LINE_ARGS, integer_us_after_oct);
parsing_should_fail(FILE_LINE_ARGS, key_after_array);
parsing_should_fail(FILE_LINE_ARGS, key_after_table);
parsing_should_fail(FILE_LINE_ARGS, key_after_value);
parsing_should_fail(FILE_LINE_ARGS, key_bare_invalid_character);
parsing_should_fail(FILE_LINE_ARGS, key_dotted_redefine_table);
parsing_should_fail(FILE_LINE_ARGS, key_duplicate);
parsing_should_fail(FILE_LINE_ARGS, key_empty);
parsing_should_fail(FILE_LINE_ARGS, key_escape);
parsing_should_fail(FILE_LINE_ARGS, key_hash);
parsing_should_fail(FILE_LINE_ARGS, key_multiline);
parsing_should_fail(FILE_LINE_ARGS, key_newline);
parsing_should_fail(FILE_LINE_ARGS, key_no_eol);
parsing_should_fail(FILE_LINE_ARGS, key_open_bracket);
parsing_should_fail(FILE_LINE_ARGS, key_partial_quoted);
parsing_should_fail(FILE_LINE_ARGS, key_single_open_bracket);
parsing_should_fail(FILE_LINE_ARGS, key_space);
parsing_should_fail(FILE_LINE_ARGS, key_start_bracket);
parsing_should_fail(FILE_LINE_ARGS, key_two_equals);
parsing_should_fail(FILE_LINE_ARGS, key_two_equals2);
parsing_should_fail(FILE_LINE_ARGS, key_two_equals3);
parsing_should_fail(FILE_LINE_ARGS, key_without_value_1);
parsing_should_fail(FILE_LINE_ARGS, key_without_value_2);
#if !TOML_LANG_UNRELEASED && UNICODE_LITERALS_OK
parsing_should_fail(FILE_LINE_ARGS, key_special_character);
#endif // !TOML_LANG_UNRELEASED && UNICODE_LITERALS_OK
parsing_should_fail(FILE_LINE_ARGS, llbrace);
#if !TOML_LANG_UNRELEASED
#if !TOML_LANG_UNRELEASED
parsing_should_fail(FILE_LINE_ARGS, datetime_malformed_no_secs);
parsing_should_fail(FILE_LINE_ARGS, inline_table_linebreak);
parsing_should_fail(FILE_LINE_ARGS, multi_line_inline_table);
parsing_should_fail(FILE_LINE_ARGS, string_byte_escapes);
#endif // !TOML_LANG_UNRELEASED
#endif // !TOML_LANG_UNRELEASED
parsing_should_fail(FILE_LINE_ARGS, multi_line_string_no_close_2);
parsing_should_fail(FILE_LINE_ARGS, multi_line_string_no_close);
parsing_should_fail(FILE_LINE_ARGS, rrbrace);
parsing_should_fail(FILE_LINE_ARGS, string_bad_byte_escape);
parsing_should_fail(FILE_LINE_ARGS, string_bad_codepoint);
parsing_should_fail(FILE_LINE_ARGS, string_bad_concat);
parsing_should_fail(FILE_LINE_ARGS, string_bad_escape);
parsing_should_fail(FILE_LINE_ARGS, string_bad_multiline);
parsing_should_fail(FILE_LINE_ARGS, string_bad_slash_escape);
parsing_should_fail(FILE_LINE_ARGS, string_bad_uni_esc);
parsing_should_fail(FILE_LINE_ARGS, string_basic_multiline_out_of_range_unicode_escape_1);
parsing_should_fail(FILE_LINE_ARGS, string_basic_multiline_out_of_range_unicode_escape_2);
parsing_should_fail(FILE_LINE_ARGS, string_basic_multiline_quotes);
parsing_should_fail(FILE_LINE_ARGS, string_basic_multiline_unknown_escape);
parsing_should_fail(FILE_LINE_ARGS, string_basic_out_of_range_unicode_escape_1);
parsing_should_fail(FILE_LINE_ARGS, string_basic_out_of_range_unicode_escape_2);
parsing_should_fail(FILE_LINE_ARGS, string_basic_unknown_escape);
parsing_should_fail(FILE_LINE_ARGS, string_literal_multiline_quotes_1);
parsing_should_fail(FILE_LINE_ARGS, string_literal_multiline_quotes_2);
parsing_should_fail(FILE_LINE_ARGS, string_missing_quotes);
parsing_should_fail(FILE_LINE_ARGS, string_multiline_escape_space);
parsing_should_fail(FILE_LINE_ARGS, string_multiline_quotes_1);
parsing_should_fail(FILE_LINE_ARGS, string_multiline_quotes_2);
parsing_should_fail(FILE_LINE_ARGS, string_no_close);
parsing_should_fail(FILE_LINE_ARGS, string_wrong_close);
#if !TOML_LANG_UNRELEASED
parsing_should_fail(FILE_LINE_ARGS, string_basic_byte_escapes);
#endif // !TOML_LANG_UNRELEASED
parsing_should_fail(FILE_LINE_ARGS, table_array_empty);
parsing_should_fail(FILE_LINE_ARGS, table_array_implicit);
parsing_should_fail(FILE_LINE_ARGS, table_array_missing_bracket);
parsing_should_fail(FILE_LINE_ARGS, table_duplicate);
parsing_should_fail(FILE_LINE_ARGS, table_empty);
parsing_should_fail(FILE_LINE_ARGS, table_equals_sign);
parsing_should_fail(FILE_LINE_ARGS, table_nested_brackets_close);
parsing_should_fail(FILE_LINE_ARGS, table_nested_brackets_open);
parsing_should_fail(FILE_LINE_ARGS, table_quoted_no_close);
parsing_should_fail(FILE_LINE_ARGS, table_redefine);
parsing_should_fail(FILE_LINE_ARGS, table_whitespace);
parsing_should_fail(FILE_LINE_ARGS, table_with_pound);
parsing_should_fail(FILE_LINE_ARGS, text_after_array_entries);
parsing_should_fail(FILE_LINE_ARGS, text_after_integer);
parsing_should_fail(FILE_LINE_ARGS, text_after_string);
parsing_should_fail(FILE_LINE_ARGS, text_after_table);
parsing_should_fail(FILE_LINE_ARGS, text_before_array_separator);
parsing_should_fail(FILE_LINE_ARGS, text_in_array);
}

File diff suppressed because it is too large Load Diff

View File

@ -26,23 +26,33 @@ fruit = []
# This table conflicts with the previous table
[fruit.variety]
name = "granny smith")"sv;
static constexpr auto bare_key_1 = R"(bare!key = 123)"sv;
static constexpr auto bare_key_2 = R"(barekey
= 123)"sv;
static constexpr auto bare_key_3 = R"(barekey =)"sv;
static constexpr auto inline_table_imutable_1 = R"([product]
type = { name = "Nail" }
type.edible = false # INVALID)"sv;
static constexpr auto inline_table_imutable_2 = R"([product]
type.name = "Nail"
type = { edible = false } # INVALID)"sv;
#if !TOML_LANG_UNRELEASED
static constexpr auto inline_table_trailing_comma = R"(abc = { abc = 123, })"sv;
#endif // !TOML_LANG_UNRELEASED
static constexpr auto int_0_padded = R"(int = 0123)"sv;
static constexpr auto int_signed_bin = R"(bin = +0b10)"sv;
static constexpr auto int_signed_hex = R"(hex = +0xab)"sv;
static constexpr auto int_signed_oct = R"(oct = +0o23)"sv;
static constexpr auto key_value_pair_1 = R"(key = # INVALID)"sv;
static constexpr auto key_value_pair_2 = R"(first = "Tom" last = "Preston-Werner" # INVALID)"sv;
static constexpr auto multiple_dot_key = R"(# THE FOLLOWING IS INVALID
# This defines the value of fruit.apple to be an integer.
@ -54,7 +64,9 @@ fruit.apple.smooth = true)"sv;
static constexpr auto multiple_key = R"(# DO NOT DO THIS
name = "Tom"
name = "Pradyun")"sv;
static constexpr auto no_key_name = R"(= "no key name" # INVALID)"sv;
static constexpr auto string_basic_multiline_invalid_backslash = R"(a = """
foo \ \n
bar""")"sv;
@ -66,6 +78,7 @@ name = "Pradyun")"sv;
static constexpr auto string_basic_out_of_range_unicode_escape_2 = R"(a = "\U00D80000")"sv;
static constexpr auto string_basic_unknown_escape = R"(a = "\@")"sv;
static constexpr auto string_literal_multiline_quotes = R"(apos15 = '''Here are fifteen apostrophes: '''''''''''''''''' # INVALID)"sv;
static constexpr auto table_1 = R"(# DO NOT DO THIS
[fruit]
@ -136,41 +149,75 @@ TOML_ENABLE_WARNINGS;
TEST_CASE("conformance - iarna/invalid")
{
parsing_should_fail(FILE_LINE_ARGS, array_of_tables_1);
parsing_should_fail(FILE_LINE_ARGS, array_of_tables_2);
parsing_should_fail(FILE_LINE_ARGS, bare_key_1);
parsing_should_fail(FILE_LINE_ARGS, bare_key_2);
parsing_should_fail(FILE_LINE_ARGS, bare_key_3);
parsing_should_fail(FILE_LINE_ARGS, inline_table_imutable_1);
parsing_should_fail(FILE_LINE_ARGS, inline_table_imutable_2);
parsing_should_fail(FILE_LINE_ARGS, int_0_padded);
parsing_should_fail(FILE_LINE_ARGS, int_signed_bin);
parsing_should_fail(FILE_LINE_ARGS, int_signed_hex);
parsing_should_fail(FILE_LINE_ARGS, int_signed_oct);
parsing_should_fail(FILE_LINE_ARGS, key_value_pair_1);
parsing_should_fail(FILE_LINE_ARGS, key_value_pair_2);
parsing_should_fail(FILE_LINE_ARGS, multiple_dot_key);
parsing_should_fail(FILE_LINE_ARGS, multiple_key);
parsing_should_fail(FILE_LINE_ARGS, no_key_name);
parsing_should_fail(FILE_LINE_ARGS, string_basic_multiline_invalid_backslash);
parsing_should_fail(FILE_LINE_ARGS, string_basic_multiline_out_of_range_unicode_escape_1);
parsing_should_fail(FILE_LINE_ARGS, string_basic_multiline_out_of_range_unicode_escape_2);
parsing_should_fail(FILE_LINE_ARGS, string_basic_multiline_quotes);
parsing_should_fail(FILE_LINE_ARGS, string_basic_multiline_unknown_escape);
parsing_should_fail(FILE_LINE_ARGS, string_basic_out_of_range_unicode_escape_1);
parsing_should_fail(FILE_LINE_ARGS, string_basic_out_of_range_unicode_escape_2);
parsing_should_fail(FILE_LINE_ARGS, string_basic_unknown_escape);
parsing_should_fail(FILE_LINE_ARGS, string_literal_multiline_quotes);
parsing_should_fail(FILE_LINE_ARGS, table_1);
parsing_should_fail(FILE_LINE_ARGS, table_2);
parsing_should_fail(FILE_LINE_ARGS, table_3);
parsing_should_fail(FILE_LINE_ARGS, table_4);
parsing_should_fail(FILE_LINE_ARGS, table_invalid_1);
parsing_should_fail(FILE_LINE_ARGS, table_invalid_2);
parsing_should_fail(FILE_LINE_ARGS, table_invalid_3);
parsing_should_fail(FILE_LINE_ARGS, table_invalid_4);
#if !TOML_LANG_UNRELEASED
parsing_should_fail(FILE_LINE_ARGS, array_of_tables_2);
parsing_should_fail(FILE_LINE_ARGS, bare_key_1);
parsing_should_fail(FILE_LINE_ARGS, bare_key_2);
parsing_should_fail(FILE_LINE_ARGS, bare_key_3);
parsing_should_fail(FILE_LINE_ARGS, inline_table_imutable_1);
parsing_should_fail(FILE_LINE_ARGS, inline_table_imutable_2);
#if !TOML_LANG_UNRELEASED
parsing_should_fail(FILE_LINE_ARGS, inline_table_trailing_comma);
#endif // !TOML_LANG_UNRELEASED
#endif // !TOML_LANG_UNRELEASED
parsing_should_fail(FILE_LINE_ARGS, int_0_padded);
parsing_should_fail(FILE_LINE_ARGS, int_signed_bin);
parsing_should_fail(FILE_LINE_ARGS, int_signed_hex);
parsing_should_fail(FILE_LINE_ARGS, int_signed_oct);
parsing_should_fail(FILE_LINE_ARGS, key_value_pair_1);
parsing_should_fail(FILE_LINE_ARGS, key_value_pair_2);
parsing_should_fail(FILE_LINE_ARGS, multiple_dot_key);
parsing_should_fail(FILE_LINE_ARGS, multiple_key);
parsing_should_fail(FILE_LINE_ARGS, no_key_name);
parsing_should_fail(FILE_LINE_ARGS, string_basic_multiline_invalid_backslash);
parsing_should_fail(FILE_LINE_ARGS, string_basic_multiline_out_of_range_unicode_escape_1);
parsing_should_fail(FILE_LINE_ARGS, string_basic_multiline_out_of_range_unicode_escape_2);
parsing_should_fail(FILE_LINE_ARGS, string_basic_multiline_quotes);
parsing_should_fail(FILE_LINE_ARGS, string_basic_multiline_unknown_escape);
parsing_should_fail(FILE_LINE_ARGS, string_basic_out_of_range_unicode_escape_1);
parsing_should_fail(FILE_LINE_ARGS, string_basic_out_of_range_unicode_escape_2);
parsing_should_fail(FILE_LINE_ARGS, string_basic_unknown_escape);
parsing_should_fail(FILE_LINE_ARGS, string_literal_multiline_quotes);
parsing_should_fail(FILE_LINE_ARGS, table_1);
parsing_should_fail(FILE_LINE_ARGS, table_2);
parsing_should_fail(FILE_LINE_ARGS, table_3);
parsing_should_fail(FILE_LINE_ARGS, table_4);
parsing_should_fail(FILE_LINE_ARGS, table_invalid_1);
parsing_should_fail(FILE_LINE_ARGS, table_invalid_2);
parsing_should_fail(FILE_LINE_ARGS, table_invalid_3);
parsing_should_fail(FILE_LINE_ARGS, table_invalid_4);
}

View File

@ -156,9 +156,6 @@ orange.color = "orange")"sv;
static constexpr auto spec_key_value_pair_7 = R"(_=1)"sv;
static constexpr auto spec_key_value_pair_8 = R"(-_-_-_-_-=1)"sv;
static constexpr auto spec_key_value_pair_9 = R"(3.14159 = "pi")"sv;
#if UNICODE_LITERALS_OK
static constexpr auto spec_quoted_basic_keys_1 = R"("ʎǝʞ" = "value")"sv;
#endif // UNICODE_LITERALS_OK
static constexpr auto spec_quoted_literal_keys_1 = R"('quoted "value"' = "value")"sv;
static constexpr auto spec_readme_example = R"(# This is a TOML document.
@ -218,7 +215,6 @@ The quick brown \
static constexpr auto spec_string_basic_multiline_9 = R"(str7 = """"This," she said, "is just a pointless statement."""")"sv;
static constexpr auto spec_string_basic_tab_multiline = R"(str = """This is a tab""")"sv;
static constexpr auto spec_string_basic_tab = R"(str = "This is a tab")"sv;
static constexpr auto spec_string_basic = R"(str = "I'm a string. \"You can quote me\". Name\tJos\u00E9\nLocation\tSF.")"sv;
static constexpr auto spec_string_literal_1 = R"(winpath = 'C:\Users\nodejs\templates')"sv;
static constexpr auto spec_string_literal_2 = R"(winpath2 = '\\ServerX\admin$\system32\')"sv;
static constexpr auto spec_string_literal_3 = R"(quoted = 'Tom "Dubs" Preston-Werner')"sv;
@ -244,9 +240,6 @@ type.name = "pug")"sv;
static constexpr auto spec_table_3 = R"([a.b.c])"sv;
static constexpr auto spec_table_4 = R"([ d.e.f ] # same as [d.e.f])"sv;
static constexpr auto spec_table_5 = R"([ g . h . i ] # same as [g.h.i])"sv;
#if UNICODE_LITERALS_OK
static constexpr auto spec_table_6 = R"([ j . "ʞ" . 'l' ] # same as [j."ʞ".'l'])"sv;
#endif // UNICODE_LITERALS_OK
static constexpr auto spec_table_7 = R"(# [x] you
# [x.y] don't
# [x.y.z] need these
@ -263,6 +256,14 @@ smooth = true)"sv;
static constexpr auto spec_table_inline_3 = R"(animal = { type.name = "pug" })"sv;
static constexpr auto spec_table = R"([table])"sv;
static constexpr auto spec_time_1 = R"(lt1 = 07:32:00)"sv;
#if UNICODE_LITERALS_OK
static constexpr auto spec_quoted_basic_keys_1 = R"("ʎǝʞ" = "value")"sv;
static constexpr auto spec_string_basic = R"(str = "I'm a string. \"You can quote me\". Name\tJos\u00E9\nLocation\tSF.")"sv;
static constexpr auto spec_table_6 = R"([ j . "ʞ" . 'l' ] # same as [j."ʞ".'l'])"sv;
#endif // UNICODE_LITERALS_OK
}
TOML_ENABLE_WARNINGS;
@ -271,7 +272,7 @@ TEST_CASE("conformance - iarna/valid")
{
parsing_should_succeed(FILE_LINE_ARGS, spec_array_1, [](toml::table&& tbl)
{
auto expected = toml::table{{
const auto expected = toml::table{{
{
R"(integers)"sv, toml::array{
1,
@ -285,7 +286,7 @@ TEST_CASE("conformance - iarna/valid")
parsing_should_succeed(FILE_LINE_ARGS, spec_array_2, [](toml::table&& tbl)
{
auto expected = toml::table{{
const auto expected = toml::table{{
{
R"(colors)"sv, toml::array{
R"(red)"sv,
@ -299,7 +300,7 @@ TEST_CASE("conformance - iarna/valid")
parsing_should_succeed(FILE_LINE_ARGS, spec_array_3, [](toml::table&& tbl)
{
auto expected = toml::table{{
const auto expected = toml::table{{
{
R"(nested_array_of_int)"sv, toml::array{
toml::array{
@ -319,7 +320,7 @@ TEST_CASE("conformance - iarna/valid")
parsing_should_succeed(FILE_LINE_ARGS, spec_array_4, [](toml::table&& tbl)
{
auto expected = toml::table{{
const auto expected = toml::table{{
{
R"(string_array)"sv, toml::array{
R"(all)"sv,
@ -334,7 +335,7 @@ TEST_CASE("conformance - iarna/valid")
parsing_should_succeed(FILE_LINE_ARGS, spec_array_5, [](toml::table&& tbl)
{
auto expected = toml::table{{
const auto expected = toml::table{{
{
R"(nested_mixed_array)"sv, toml::array{
toml::array{
@ -354,7 +355,7 @@ TEST_CASE("conformance - iarna/valid")
parsing_should_succeed(FILE_LINE_ARGS, spec_array_7, [](toml::table&& tbl)
{
auto expected = toml::table{{
const auto expected = toml::table{{
{
R"(integers2)"sv, toml::array{
1,
@ -368,7 +369,7 @@ TEST_CASE("conformance - iarna/valid")
parsing_should_succeed(FILE_LINE_ARGS, spec_array_8, [](toml::table&& tbl)
{
auto expected = toml::table{{
const auto expected = toml::table{{
{
R"(integers3)"sv, toml::array{
1,
@ -381,7 +382,7 @@ TEST_CASE("conformance - iarna/valid")
parsing_should_succeed(FILE_LINE_ARGS, spec_array_mixed_number_types, [](toml::table&& tbl)
{
auto expected = toml::table{{
const auto expected = toml::table{{
{
R"(numbers)"sv, toml::array{
0.1,
@ -398,7 +399,7 @@ TEST_CASE("conformance - iarna/valid")
parsing_should_succeed(FILE_LINE_ARGS, spec_array_more_mixed_types, [](toml::table&& tbl)
{
auto expected = toml::table{{
const auto expected = toml::table{{
{
R"(contributors)"sv, toml::array{
R"(Foo Bar <foo@example.com>)"sv,
@ -415,7 +416,7 @@ TEST_CASE("conformance - iarna/valid")
parsing_should_succeed(FILE_LINE_ARGS, spec_array_of_tables_1, [](toml::table&& tbl)
{
auto expected = toml::table{{
const auto expected = toml::table{{
{
R"(products)"sv, toml::array{
toml::table{{
@ -436,7 +437,7 @@ TEST_CASE("conformance - iarna/valid")
parsing_should_succeed(FILE_LINE_ARGS, spec_array_of_tables_2, [](toml::table&& tbl)
{
auto expected = toml::table{{
const auto expected = toml::table{{
{
R"(fruit)"sv, toml::array{
toml::table{{
@ -476,7 +477,7 @@ TEST_CASE("conformance - iarna/valid")
parsing_should_succeed(FILE_LINE_ARGS, spec_array_of_tables_3, [](toml::table&& tbl)
{
auto expected = toml::table{{
const auto expected = toml::table{{
{
R"(points)"sv, toml::array{
toml::table{{
@ -502,7 +503,7 @@ TEST_CASE("conformance - iarna/valid")
parsing_should_succeed(FILE_LINE_ARGS, spec_boolean_1, [](toml::table&& tbl)
{
auto expected = toml::table{{
const auto expected = toml::table{{
{ R"(bool1)"sv, true },
}};
REQUIRE(tbl == expected);
@ -510,7 +511,7 @@ TEST_CASE("conformance - iarna/valid")
parsing_should_succeed(FILE_LINE_ARGS, spec_boolean_2, [](toml::table&& tbl)
{
auto expected = toml::table{{
const auto expected = toml::table{{
{ R"(bool1)"sv, false },
}};
REQUIRE(tbl == expected);
@ -518,7 +519,7 @@ TEST_CASE("conformance - iarna/valid")
parsing_should_succeed(FILE_LINE_ARGS, spec_case_sensitive, [](toml::table&& tbl)
{
auto expected = toml::table{{
const auto expected = toml::table{{
{ R"(abc)"sv, 123 },
{ R"(ABC)"sv, 456 },
}};
@ -527,7 +528,7 @@ TEST_CASE("conformance - iarna/valid")
parsing_should_succeed(FILE_LINE_ARGS, spec_comment_mid_array, [](toml::table&& tbl)
{
auto expected = toml::table{{
const auto expected = toml::table{{
{
R"(abc)"sv, toml::array{
123,
@ -540,7 +541,7 @@ TEST_CASE("conformance - iarna/valid")
parsing_should_succeed(FILE_LINE_ARGS, spec_comment_mid_string, [](toml::table&& tbl)
{
auto expected = toml::table{{
const auto expected = toml::table{{
{ R"(another)"sv, R"(# This is not a comment)"sv },
}};
REQUIRE(tbl == expected);
@ -548,7 +549,7 @@ TEST_CASE("conformance - iarna/valid")
parsing_should_succeed(FILE_LINE_ARGS, spec_comment_tab, [](toml::table&& tbl)
{
auto expected = toml::table{{
const auto expected = toml::table{{
{ R"(key)"sv, R"(value)"sv },
}};
REQUIRE(tbl == expected);
@ -556,7 +557,7 @@ TEST_CASE("conformance - iarna/valid")
parsing_should_succeed(FILE_LINE_ARGS, spec_comment, [](toml::table&& tbl)
{
auto expected = toml::table{{
const auto expected = toml::table{{
{ R"(key)"sv, R"(value)"sv },
}};
REQUIRE(tbl == expected);
@ -564,7 +565,7 @@ TEST_CASE("conformance - iarna/valid")
parsing_should_succeed(FILE_LINE_ARGS, spec_date_local_1, [](toml::table&& tbl)
{
auto expected = toml::table{{
const auto expected = toml::table{{
{ R"(ld1)"sv, toml::date{ 1979, 5, 27 } },
}};
REQUIRE(tbl == expected);
@ -572,7 +573,7 @@ TEST_CASE("conformance - iarna/valid")
parsing_should_succeed(FILE_LINE_ARGS, spec_date_time_1, [](toml::table&& tbl)
{
auto expected = toml::table{{
const auto expected = toml::table{{
{ R"(odt1)"sv, toml::date_time{ { 1979, 5, 27 }, { 7, 32, 0, 0u }, { 0, 0 } } },
}};
REQUIRE(tbl == expected);
@ -580,7 +581,7 @@ TEST_CASE("conformance - iarna/valid")
parsing_should_succeed(FILE_LINE_ARGS, spec_date_time_2, [](toml::table&& tbl)
{
auto expected = toml::table{{
const auto expected = toml::table{{
{ R"(odt2)"sv, toml::date_time{ { 1979, 5, 27 }, { 0, 32, 0, 0u }, { -7, 0 } } },
}};
REQUIRE(tbl == expected);
@ -588,7 +589,7 @@ TEST_CASE("conformance - iarna/valid")
parsing_should_succeed(FILE_LINE_ARGS, spec_date_time_3, [](toml::table&& tbl)
{
auto expected = toml::table{{
const auto expected = toml::table{{
{ R"(odt3)"sv, toml::date_time{ { 1979, 5, 27 }, { 0, 32, 0, 999999000u }, { -7, 0 } } },
}};
REQUIRE(tbl == expected);
@ -596,7 +597,7 @@ TEST_CASE("conformance - iarna/valid")
parsing_should_succeed(FILE_LINE_ARGS, spec_date_time_4, [](toml::table&& tbl)
{
auto expected = toml::table{{
const auto expected = toml::table{{
{ R"(odt4)"sv, toml::date_time{ { 1979, 5, 27 }, { 7, 32, 0, 0u }, { 0, 0 } } },
}};
REQUIRE(tbl == expected);
@ -604,7 +605,7 @@ TEST_CASE("conformance - iarna/valid")
parsing_should_succeed(FILE_LINE_ARGS, spec_date_time_5, [](toml::table&& tbl)
{
auto expected = toml::table{{
const auto expected = toml::table{{
{ R"(odt5)"sv, toml::date_time{ { 1979, 5, 27 }, { 7, 32, 0, 123000000u }, { 0, 0 } } },
}};
REQUIRE(tbl == expected);
@ -612,7 +613,7 @@ TEST_CASE("conformance - iarna/valid")
parsing_should_succeed(FILE_LINE_ARGS, spec_date_time_local_1, [](toml::table&& tbl)
{
auto expected = toml::table{{
const auto expected = toml::table{{
{ R"(ldt1)"sv, toml::date_time{ { 1979, 5, 27 }, { 7, 32, 0, 0u } } },
}};
REQUIRE(tbl == expected);
@ -620,7 +621,7 @@ TEST_CASE("conformance - iarna/valid")
parsing_should_succeed(FILE_LINE_ARGS, spec_dotted_keys_1, [](toml::table&& tbl)
{
auto expected = toml::table{{
const auto expected = toml::table{{
{ R"(name)"sv, R"(Orange)"sv },
{
R"(physical)"sv, toml::table{{
@ -639,7 +640,7 @@ TEST_CASE("conformance - iarna/valid")
parsing_should_succeed(FILE_LINE_ARGS, spec_dotted_keys_2, [](toml::table&& tbl)
{
auto expected = toml::table{{
const auto expected = toml::table{{
{
R"(a)"sv, toml::table{{
{ R"(b)"sv, 23 },
@ -651,7 +652,7 @@ TEST_CASE("conformance - iarna/valid")
parsing_should_succeed(FILE_LINE_ARGS, spec_dotted_keys_3, [](toml::table&& tbl)
{
auto expected = toml::table{{
const auto expected = toml::table{{
{
R"(a)"sv, toml::table{{
{ R"(b)"sv, 23 },
@ -663,7 +664,7 @@ TEST_CASE("conformance - iarna/valid")
parsing_should_succeed(FILE_LINE_ARGS, spec_empty_key_name_1, [](toml::table&& tbl)
{
auto expected = toml::table{{
const auto expected = toml::table{{
{ R"()"sv, R"(blank)"sv },
}};
REQUIRE(tbl == expected);
@ -671,7 +672,7 @@ TEST_CASE("conformance - iarna/valid")
parsing_should_succeed(FILE_LINE_ARGS, spec_empty_key_name_2, [](toml::table&& tbl)
{
auto expected = toml::table{{
const auto expected = toml::table{{
{ R"()"sv, R"(blank)"sv },
}};
REQUIRE(tbl == expected);
@ -679,7 +680,7 @@ TEST_CASE("conformance - iarna/valid")
parsing_should_succeed(FILE_LINE_ARGS, spec_extend_dotted_object_1, [](toml::table&& tbl)
{
auto expected = toml::table{{
const auto expected = toml::table{{
{
R"(fruit)"sv, toml::table{{
{
@ -696,7 +697,7 @@ TEST_CASE("conformance - iarna/valid")
parsing_should_succeed(FILE_LINE_ARGS, spec_extend_dotted_object_2, [](toml::table&& tbl)
{
auto expected = toml::table{{
const auto expected = toml::table{{
{
R"(apple)"sv, toml::table{{
{ R"(type)"sv, R"(fruit)"sv },
@ -717,7 +718,7 @@ TEST_CASE("conformance - iarna/valid")
parsing_should_succeed(FILE_LINE_ARGS, spec_extend_dotted_object_3, [](toml::table&& tbl)
{
auto expected = toml::table{{
const auto expected = toml::table{{
{
R"(apple)"sv, toml::table{{
{ R"(type)"sv, R"(fruit)"sv },
@ -738,7 +739,7 @@ TEST_CASE("conformance - iarna/valid")
parsing_should_succeed(FILE_LINE_ARGS, spec_float_1, [](toml::table&& tbl)
{
auto expected = toml::table{{
const auto expected = toml::table{{
{ R"(flt1)"sv, 1.0 },
}};
REQUIRE(tbl == expected);
@ -746,7 +747,7 @@ TEST_CASE("conformance - iarna/valid")
parsing_should_succeed(FILE_LINE_ARGS, spec_float_10, [](toml::table&& tbl)
{
auto expected = toml::table{{
const auto expected = toml::table{{
{ R"(sf1)"sv, std::numeric_limits<double>::infinity() },
}};
REQUIRE(tbl == expected);
@ -754,7 +755,7 @@ TEST_CASE("conformance - iarna/valid")
parsing_should_succeed(FILE_LINE_ARGS, spec_float_11, [](toml::table&& tbl)
{
auto expected = toml::table{{
const auto expected = toml::table{{
{ R"(sf2)"sv, std::numeric_limits<double>::infinity() },
}};
REQUIRE(tbl == expected);
@ -762,7 +763,7 @@ TEST_CASE("conformance - iarna/valid")
parsing_should_succeed(FILE_LINE_ARGS, spec_float_12, [](toml::table&& tbl)
{
auto expected = toml::table{{
const auto expected = toml::table{{
{ R"(sf2)"sv, -std::numeric_limits<double>::infinity() },
}};
REQUIRE(tbl == expected);
@ -770,7 +771,7 @@ TEST_CASE("conformance - iarna/valid")
parsing_should_succeed(FILE_LINE_ARGS, spec_float_13, [](toml::table&& tbl)
{
auto expected = toml::table{{
const auto expected = toml::table{{
{ R"(sf4)"sv, std::numeric_limits<double>::quiet_NaN() },
}};
REQUIRE(tbl == expected);
@ -778,7 +779,7 @@ TEST_CASE("conformance - iarna/valid")
parsing_should_succeed(FILE_LINE_ARGS, spec_float_14, [](toml::table&& tbl)
{
auto expected = toml::table{{
const auto expected = toml::table{{
{ R"(sf5)"sv, std::numeric_limits<double>::quiet_NaN() },
}};
REQUIRE(tbl == expected);
@ -786,7 +787,7 @@ TEST_CASE("conformance - iarna/valid")
parsing_should_succeed(FILE_LINE_ARGS, spec_float_15, [](toml::table&& tbl)
{
auto expected = toml::table{{
const auto expected = toml::table{{
{ R"(sf6)"sv, std::numeric_limits<double>::quiet_NaN() },
}};
REQUIRE(tbl == expected);
@ -794,7 +795,7 @@ TEST_CASE("conformance - iarna/valid")
parsing_should_succeed(FILE_LINE_ARGS, spec_float_2, [](toml::table&& tbl)
{
auto expected = toml::table{{
const auto expected = toml::table{{
{ R"(flt2)"sv, 3.1415 },
}};
REQUIRE(tbl == expected);
@ -802,7 +803,7 @@ TEST_CASE("conformance - iarna/valid")
parsing_should_succeed(FILE_LINE_ARGS, spec_float_3, [](toml::table&& tbl)
{
auto expected = toml::table{{
const auto expected = toml::table{{
{ R"(flt3)"sv, -0.01 },
}};
REQUIRE(tbl == expected);
@ -810,7 +811,7 @@ TEST_CASE("conformance - iarna/valid")
parsing_should_succeed(FILE_LINE_ARGS, spec_float_4, [](toml::table&& tbl)
{
auto expected = toml::table{{
const auto expected = toml::table{{
{ R"(flt4)"sv, 5e+22 },
}};
REQUIRE(tbl == expected);
@ -818,7 +819,7 @@ TEST_CASE("conformance - iarna/valid")
parsing_should_succeed(FILE_LINE_ARGS, spec_float_5, [](toml::table&& tbl)
{
auto expected = toml::table{{
const auto expected = toml::table{{
{ R"(flt5)"sv, 1000000.0 },
}};
REQUIRE(tbl == expected);
@ -826,7 +827,7 @@ TEST_CASE("conformance - iarna/valid")
parsing_should_succeed(FILE_LINE_ARGS, spec_float_6, [](toml::table&& tbl)
{
auto expected = toml::table{{
const auto expected = toml::table{{
{ R"(flt6)"sv, -0.02 },
}};
REQUIRE(tbl == expected);
@ -834,7 +835,7 @@ TEST_CASE("conformance - iarna/valid")
parsing_should_succeed(FILE_LINE_ARGS, spec_float_7, [](toml::table&& tbl)
{
auto expected = toml::table{{
const auto expected = toml::table{{
{ R"(flt7)"sv, 6.626e-34 },
}};
REQUIRE(tbl == expected);
@ -842,7 +843,7 @@ TEST_CASE("conformance - iarna/valid")
parsing_should_succeed(FILE_LINE_ARGS, spec_float_8, [](toml::table&& tbl)
{
auto expected = toml::table{{
const auto expected = toml::table{{
{ R"(flt8)"sv, 224617.445991228 },
}};
REQUIRE(tbl == expected);
@ -850,7 +851,7 @@ TEST_CASE("conformance - iarna/valid")
parsing_should_succeed(FILE_LINE_ARGS, spec_float_9, [](toml::table&& tbl)
{
auto expected = toml::table{{
const auto expected = toml::table{{
{ R"(flt9)"sv, -0.0 },
}};
REQUIRE(tbl == expected);
@ -858,7 +859,7 @@ TEST_CASE("conformance - iarna/valid")
parsing_should_succeed(FILE_LINE_ARGS, spec_int_1, [](toml::table&& tbl)
{
auto expected = toml::table{{
const auto expected = toml::table{{
{ R"(int1)"sv, 99 },
}};
REQUIRE(tbl == expected);
@ -866,7 +867,7 @@ TEST_CASE("conformance - iarna/valid")
parsing_should_succeed(FILE_LINE_ARGS, spec_int_2, [](toml::table&& tbl)
{
auto expected = toml::table{{
const auto expected = toml::table{{
{ R"(int2)"sv, 42 },
}};
REQUIRE(tbl == expected);
@ -874,7 +875,7 @@ TEST_CASE("conformance - iarna/valid")
parsing_should_succeed(FILE_LINE_ARGS, spec_int_3, [](toml::table&& tbl)
{
auto expected = toml::table{{
const auto expected = toml::table{{
{ R"(int3)"sv, 0 },
}};
REQUIRE(tbl == expected);
@ -882,7 +883,7 @@ TEST_CASE("conformance - iarna/valid")
parsing_should_succeed(FILE_LINE_ARGS, spec_int_3a, [](toml::table&& tbl)
{
auto expected = toml::table{{
const auto expected = toml::table{{
{ R"(int3)"sv, 0 },
}};
REQUIRE(tbl == expected);
@ -890,7 +891,7 @@ TEST_CASE("conformance - iarna/valid")
parsing_should_succeed(FILE_LINE_ARGS, spec_int_3b, [](toml::table&& tbl)
{
auto expected = toml::table{{
const auto expected = toml::table{{
{ R"(int3)"sv, 0 },
}};
REQUIRE(tbl == expected);
@ -898,7 +899,7 @@ TEST_CASE("conformance - iarna/valid")
parsing_should_succeed(FILE_LINE_ARGS, spec_int_4, [](toml::table&& tbl)
{
auto expected = toml::table{{
const auto expected = toml::table{{
{ R"(int4)"sv, -17 },
}};
REQUIRE(tbl == expected);
@ -906,7 +907,7 @@ TEST_CASE("conformance - iarna/valid")
parsing_should_succeed(FILE_LINE_ARGS, spec_int_5, [](toml::table&& tbl)
{
auto expected = toml::table{{
const auto expected = toml::table{{
{ R"(int5)"sv, 1000 },
}};
REQUIRE(tbl == expected);
@ -914,7 +915,7 @@ TEST_CASE("conformance - iarna/valid")
parsing_should_succeed(FILE_LINE_ARGS, spec_int_6, [](toml::table&& tbl)
{
auto expected = toml::table{{
const auto expected = toml::table{{
{ R"(int6)"sv, 5349221 },
}};
REQUIRE(tbl == expected);
@ -922,7 +923,7 @@ TEST_CASE("conformance - iarna/valid")
parsing_should_succeed(FILE_LINE_ARGS, spec_int_7, [](toml::table&& tbl)
{
auto expected = toml::table{{
const auto expected = toml::table{{
{ R"(int7)"sv, 12345 },
}};
REQUIRE(tbl == expected);
@ -930,7 +931,7 @@ TEST_CASE("conformance - iarna/valid")
parsing_should_succeed(FILE_LINE_ARGS, spec_int_bin1, [](toml::table&& tbl)
{
auto expected = toml::table{{
const auto expected = toml::table{{
{ R"(bin1)"sv, 214 },
}};
REQUIRE(tbl == expected);
@ -938,7 +939,7 @@ TEST_CASE("conformance - iarna/valid")
parsing_should_succeed(FILE_LINE_ARGS, spec_int_hex1, [](toml::table&& tbl)
{
auto expected = toml::table{{
const auto expected = toml::table{{
{ R"(hex1)"sv, 3735928559 },
}};
REQUIRE(tbl == expected);
@ -946,7 +947,7 @@ TEST_CASE("conformance - iarna/valid")
parsing_should_succeed(FILE_LINE_ARGS, spec_int_hex2, [](toml::table&& tbl)
{
auto expected = toml::table{{
const auto expected = toml::table{{
{ R"(hex2)"sv, 3735928559 },
}};
REQUIRE(tbl == expected);
@ -954,7 +955,7 @@ TEST_CASE("conformance - iarna/valid")
parsing_should_succeed(FILE_LINE_ARGS, spec_int_hex3, [](toml::table&& tbl)
{
auto expected = toml::table{{
const auto expected = toml::table{{
{ R"(hex3)"sv, 3735928559 },
}};
REQUIRE(tbl == expected);
@ -962,7 +963,7 @@ TEST_CASE("conformance - iarna/valid")
parsing_should_succeed(FILE_LINE_ARGS, spec_int_max, [](toml::table&& tbl)
{
auto expected = toml::table{{
const auto expected = toml::table{{
{ R"(max)"sv, INT64_MAX },
}};
REQUIRE(tbl == expected);
@ -970,7 +971,7 @@ TEST_CASE("conformance - iarna/valid")
parsing_should_succeed(FILE_LINE_ARGS, spec_int_min, [](toml::table&& tbl)
{
auto expected = toml::table{{
const auto expected = toml::table{{
{ R"(min)"sv, INT64_MIN },
}};
REQUIRE(tbl == expected);
@ -978,7 +979,7 @@ TEST_CASE("conformance - iarna/valid")
parsing_should_succeed(FILE_LINE_ARGS, spec_int_oct1, [](toml::table&& tbl)
{
auto expected = toml::table{{
const auto expected = toml::table{{
{ R"(oct1)"sv, 342391 },
}};
REQUIRE(tbl == expected);
@ -986,7 +987,7 @@ TEST_CASE("conformance - iarna/valid")
parsing_should_succeed(FILE_LINE_ARGS, spec_int_oct2, [](toml::table&& tbl)
{
auto expected = toml::table{{
const auto expected = toml::table{{
{ R"(oct2)"sv, 493 },
}};
REQUIRE(tbl == expected);
@ -994,7 +995,7 @@ TEST_CASE("conformance - iarna/valid")
parsing_should_succeed(FILE_LINE_ARGS, spec_key_value_pair_1, [](toml::table&& tbl)
{
auto expected = toml::table{{
const auto expected = toml::table{{
{ R"(key)"sv, R"(value)"sv },
}};
REQUIRE(tbl == expected);
@ -1002,7 +1003,7 @@ TEST_CASE("conformance - iarna/valid")
parsing_should_succeed(FILE_LINE_ARGS, spec_key_value_pair_2, [](toml::table&& tbl)
{
auto expected = toml::table{{
const auto expected = toml::table{{
{ R"(bare_key)"sv, R"(value)"sv },
}};
REQUIRE(tbl == expected);
@ -1010,7 +1011,7 @@ TEST_CASE("conformance - iarna/valid")
parsing_should_succeed(FILE_LINE_ARGS, spec_key_value_pair_3, [](toml::table&& tbl)
{
auto expected = toml::table{{
const auto expected = toml::table{{
{ R"(bare-key)"sv, R"(value)"sv },
}};
REQUIRE(tbl == expected);
@ -1018,7 +1019,7 @@ TEST_CASE("conformance - iarna/valid")
parsing_should_succeed(FILE_LINE_ARGS, spec_key_value_pair_4, [](toml::table&& tbl)
{
auto expected = toml::table{{
const auto expected = toml::table{{
{ R"(1234)"sv, R"(value)"sv },
}};
REQUIRE(tbl == expected);
@ -1026,7 +1027,7 @@ TEST_CASE("conformance - iarna/valid")
parsing_should_succeed(FILE_LINE_ARGS, spec_key_value_pair_5, [](toml::table&& tbl)
{
auto expected = toml::table{{
const auto expected = toml::table{{
{ R"(1234)"sv, R"(value)"sv },
}};
REQUIRE(tbl == expected);
@ -1034,7 +1035,7 @@ TEST_CASE("conformance - iarna/valid")
parsing_should_succeed(FILE_LINE_ARGS, spec_key_value_pair_6, [](toml::table&& tbl)
{
auto expected = toml::table{{
const auto expected = toml::table{{
{ R"(-)"sv, 1 },
}};
REQUIRE(tbl == expected);
@ -1042,7 +1043,7 @@ TEST_CASE("conformance - iarna/valid")
parsing_should_succeed(FILE_LINE_ARGS, spec_key_value_pair_7, [](toml::table&& tbl)
{
auto expected = toml::table{{
const auto expected = toml::table{{
{ R"(_)"sv, 1 },
}};
REQUIRE(tbl == expected);
@ -1050,7 +1051,7 @@ TEST_CASE("conformance - iarna/valid")
parsing_should_succeed(FILE_LINE_ARGS, spec_key_value_pair_8, [](toml::table&& tbl)
{
auto expected = toml::table{{
const auto expected = toml::table{{
{ R"(-_-_-_-_-)"sv, 1 },
}};
REQUIRE(tbl == expected);
@ -1058,7 +1059,7 @@ TEST_CASE("conformance - iarna/valid")
parsing_should_succeed(FILE_LINE_ARGS, spec_key_value_pair_9, [](toml::table&& tbl)
{
auto expected = toml::table{{
const auto expected = toml::table{{
{
R"(3)"sv, toml::table{{
{ R"(14159)"sv, R"(pi)"sv },
@ -1068,19 +1069,9 @@ TEST_CASE("conformance - iarna/valid")
REQUIRE(tbl == expected);
});
#if UNICODE_LITERALS_OK
parsing_should_succeed(FILE_LINE_ARGS, spec_quoted_basic_keys_1, [](toml::table&& tbl)
{
auto expected = toml::table{{
{ R"(ʎǝʞ)"sv, R"(value)"sv },
}};
REQUIRE(tbl == expected);
});
#endif // UNICODE_LITERALS_OK
parsing_should_succeed(FILE_LINE_ARGS, spec_quoted_literal_keys_1, [](toml::table&& tbl)
{
auto expected = toml::table{{
const auto expected = toml::table{{
{ R"(quoted "value")"sv, R"(value)"sv },
}};
REQUIRE(tbl == expected);
@ -1088,7 +1079,7 @@ TEST_CASE("conformance - iarna/valid")
parsing_should_succeed(FILE_LINE_ARGS, spec_readme_example, [](toml::table&& tbl)
{
auto expected = toml::table{{
const auto expected = toml::table{{
{ R"(title)"sv, R"(TOML Example)"sv },
{
R"(owner)"sv, toml::table{{
@ -1154,7 +1145,7 @@ TEST_CASE("conformance - iarna/valid")
parsing_should_succeed(FILE_LINE_ARGS, spec_string_basic_multiline_1, [](toml::table&& tbl)
{
auto expected = toml::table{{
const auto expected = toml::table{{
{ R"(str1)"sv, R"(Roses are red
Violets are blue)"sv },
}};
@ -1163,7 +1154,7 @@ Violets are blue)"sv },
parsing_should_succeed(FILE_LINE_ARGS, spec_string_basic_multiline_2, [](toml::table&& tbl)
{
auto expected = toml::table{{
const auto expected = toml::table{{
{ R"(str)"sv, R"(The quick brown fox jumps over the lazy dog.)"sv },
}};
REQUIRE(tbl == expected);
@ -1171,7 +1162,7 @@ Violets are blue)"sv },
parsing_should_succeed(FILE_LINE_ARGS, spec_string_basic_multiline_3, [](toml::table&& tbl)
{
auto expected = toml::table{{
const auto expected = toml::table{{
{ R"(str)"sv, R"(The quick brown fox jumps over the lazy dog.)"sv },
}};
REQUIRE(tbl == expected);
@ -1179,7 +1170,7 @@ Violets are blue)"sv },
parsing_should_succeed(FILE_LINE_ARGS, spec_string_basic_multiline_5, [](toml::table&& tbl)
{
auto expected = toml::table{{
const auto expected = toml::table{{
{ R"(ml-escaped-nl)"sv, R"( foo bar \
baz \quux)"sv },
}};
@ -1188,7 +1179,7 @@ Violets are blue)"sv },
parsing_should_succeed(FILE_LINE_ARGS, spec_string_basic_multiline_6, [](toml::table&& tbl)
{
auto expected = toml::table{{
const auto expected = toml::table{{
{ R"(str4)"sv, R"(Here are two quotation marks: "". Simple enough.)"sv },
}};
REQUIRE(tbl == expected);
@ -1196,7 +1187,7 @@ Violets are blue)"sv },
parsing_should_succeed(FILE_LINE_ARGS, spec_string_basic_multiline_7, [](toml::table&& tbl)
{
auto expected = toml::table{{
const auto expected = toml::table{{
{ R"(str5)"sv, R"(Here are three quotation marks: """.)"sv },
}};
REQUIRE(tbl == expected);
@ -1204,7 +1195,7 @@ Violets are blue)"sv },
parsing_should_succeed(FILE_LINE_ARGS, spec_string_basic_multiline_8, [](toml::table&& tbl)
{
auto expected = toml::table{{
const auto expected = toml::table{{
{ R"(str6)"sv, R"(Here are fifteen quotation marks: """"""""""""""".)"sv },
}};
REQUIRE(tbl == expected);
@ -1212,7 +1203,7 @@ Violets are blue)"sv },
parsing_should_succeed(FILE_LINE_ARGS, spec_string_basic_multiline_9, [](toml::table&& tbl)
{
auto expected = toml::table{{
const auto expected = toml::table{{
{ R"(str7)"sv, R"("This," she said, "is just a pointless statement.")"sv },
}};
REQUIRE(tbl == expected);
@ -1220,7 +1211,7 @@ Violets are blue)"sv },
parsing_should_succeed(FILE_LINE_ARGS, spec_string_basic_tab_multiline, [](toml::table&& tbl)
{
auto expected = toml::table{{
const auto expected = toml::table{{
{ R"(str)"sv, R"(This is a tab)"sv },
}};
REQUIRE(tbl == expected);
@ -1228,26 +1219,15 @@ Violets are blue)"sv },
parsing_should_succeed(FILE_LINE_ARGS, spec_string_basic_tab, [](toml::table&& tbl)
{
auto expected = toml::table{{
const auto expected = toml::table{{
{ R"(str)"sv, R"(This is a tab)"sv },
}};
REQUIRE(tbl == expected);
});
#if UNICODE_LITERALS_OK
parsing_should_succeed(FILE_LINE_ARGS, spec_string_basic, [](toml::table&& tbl)
{
auto expected = toml::table{{
{ R"(str)"sv, R"(I'm a string. "You can quote me". Name José
Location SF.)"sv },
}};
REQUIRE(tbl == expected);
});
#endif // UNICODE_LITERALS_OK
parsing_should_succeed(FILE_LINE_ARGS, spec_string_literal_1, [](toml::table&& tbl)
{
auto expected = toml::table{{
const auto expected = toml::table{{
{ R"(winpath)"sv, R"(C:\Users\nodejs\templates)"sv },
}};
REQUIRE(tbl == expected);
@ -1255,7 +1235,7 @@ Location SF.)"sv },
parsing_should_succeed(FILE_LINE_ARGS, spec_string_literal_2, [](toml::table&& tbl)
{
auto expected = toml::table{{
const auto expected = toml::table{{
{ R"(winpath2)"sv, R"(\\ServerX\admin$\system32\)"sv },
}};
REQUIRE(tbl == expected);
@ -1263,7 +1243,7 @@ Location SF.)"sv },
parsing_should_succeed(FILE_LINE_ARGS, spec_string_literal_3, [](toml::table&& tbl)
{
auto expected = toml::table{{
const auto expected = toml::table{{
{ R"(quoted)"sv, R"(Tom "Dubs" Preston-Werner)"sv },
}};
REQUIRE(tbl == expected);
@ -1271,7 +1251,7 @@ Location SF.)"sv },
parsing_should_succeed(FILE_LINE_ARGS, spec_string_literal_4, [](toml::table&& tbl)
{
auto expected = toml::table{{
const auto expected = toml::table{{
{ R"(regex)"sv, R"(<\i\c*\s*>)"sv },
}};
REQUIRE(tbl == expected);
@ -1279,7 +1259,7 @@ Location SF.)"sv },
parsing_should_succeed(FILE_LINE_ARGS, spec_string_literal_multiline_1, [](toml::table&& tbl)
{
auto expected = toml::table{{
const auto expected = toml::table{{
{ R"(regex2)"sv, R"(I [dw]on't need \d{2} apples)"sv },
}};
REQUIRE(tbl == expected);
@ -1287,7 +1267,7 @@ Location SF.)"sv },
parsing_should_succeed(FILE_LINE_ARGS, spec_string_literal_multiline_2, [](toml::table&& tbl)
{
auto expected = toml::table{{
const auto expected = toml::table{{
{ R"(lines)"sv, R"(The first newline is
trimmed in raw strings.
All other whitespace
@ -1299,7 +1279,7 @@ trimmed in raw strings.
parsing_should_succeed(FILE_LINE_ARGS, spec_string_literal_multiline_3, [](toml::table&& tbl)
{
auto expected = toml::table{{
const auto expected = toml::table{{
{ R"(quot15)"sv, R"(Here are fifteen quotation marks: """"""""""""""")"sv },
}};
REQUIRE(tbl == expected);
@ -1307,7 +1287,7 @@ trimmed in raw strings.
parsing_should_succeed(FILE_LINE_ARGS, spec_string_literal_multiline_4, [](toml::table&& tbl)
{
auto expected = toml::table{{
const auto expected = toml::table{{
{ R"(str)"sv, R"('That,' she said, 'is still pointless.')"sv },
}};
REQUIRE(tbl == expected);
@ -1315,7 +1295,7 @@ trimmed in raw strings.
parsing_should_succeed(FILE_LINE_ARGS, spec_table_1, [](toml::table&& tbl)
{
auto expected = toml::table{{
const auto expected = toml::table{{
{
R"(table-1)"sv, toml::table{{
{ R"(key1)"sv, R"(some string)"sv },
@ -1334,7 +1314,7 @@ trimmed in raw strings.
parsing_should_succeed(FILE_LINE_ARGS, spec_table_2, [](toml::table&& tbl)
{
auto expected = toml::table{{
const auto expected = toml::table{{
{
R"(dog)"sv, toml::table{{
{
@ -1354,7 +1334,7 @@ trimmed in raw strings.
parsing_should_succeed(FILE_LINE_ARGS, spec_table_3, [](toml::table&& tbl)
{
auto expected = toml::table{{
const auto expected = toml::table{{
{
R"(a)"sv, toml::table{{
{
@ -1370,7 +1350,7 @@ trimmed in raw strings.
parsing_should_succeed(FILE_LINE_ARGS, spec_table_4, [](toml::table&& tbl)
{
auto expected = toml::table{{
const auto expected = toml::table{{
{
R"(d)"sv, toml::table{{
{
@ -1386,7 +1366,7 @@ trimmed in raw strings.
parsing_should_succeed(FILE_LINE_ARGS, spec_table_5, [](toml::table&& tbl)
{
auto expected = toml::table{{
const auto expected = toml::table{{
{
R"(g)"sv, toml::table{{
{
@ -1400,27 +1380,9 @@ trimmed in raw strings.
REQUIRE(tbl == expected);
});
#if UNICODE_LITERALS_OK
parsing_should_succeed(FILE_LINE_ARGS, spec_table_6, [](toml::table&& tbl)
{
auto expected = toml::table{{
{
R"(j)"sv, toml::table{{
{
R"(ʞ)"sv, toml::table{{
{ R"(l)"sv, toml::table{} },
}}
},
}}
},
}};
REQUIRE(tbl == expected);
});
#endif // UNICODE_LITERALS_OK
parsing_should_succeed(FILE_LINE_ARGS, spec_table_7, [](toml::table&& tbl)
{
auto expected = toml::table{{
const auto expected = toml::table{{
{
R"(x)"sv, toml::table{{
{
@ -1440,7 +1402,7 @@ trimmed in raw strings.
parsing_should_succeed(FILE_LINE_ARGS, spec_table_8, [](toml::table&& tbl)
{
auto expected = toml::table{{
const auto expected = toml::table{{
{
R"(fruit)"sv, toml::table{{
{
@ -1466,7 +1428,7 @@ trimmed in raw strings.
parsing_should_succeed(FILE_LINE_ARGS, spec_table_inline_1, [](toml::table&& tbl)
{
auto expected = toml::table{{
const auto expected = toml::table{{
{
R"(name)"sv, toml::table{{
{ R"(first)"sv, R"(Tom)"sv },
@ -1479,7 +1441,7 @@ trimmed in raw strings.
parsing_should_succeed(FILE_LINE_ARGS, spec_table_inline_2, [](toml::table&& tbl)
{
auto expected = toml::table{{
const auto expected = toml::table{{
{
R"(point)"sv, toml::table{{
{ R"(x)"sv, 1 },
@ -1492,7 +1454,7 @@ trimmed in raw strings.
parsing_should_succeed(FILE_LINE_ARGS, spec_table_inline_3, [](toml::table&& tbl)
{
auto expected = toml::table{{
const auto expected = toml::table{{
{
R"(animal)"sv, toml::table{{
{
@ -1508,7 +1470,7 @@ trimmed in raw strings.
parsing_should_succeed(FILE_LINE_ARGS, spec_table, [](toml::table&& tbl)
{
auto expected = toml::table{{
const auto expected = toml::table{{
{ R"(table)"sv, toml::table{} },
}};
REQUIRE(tbl == expected);
@ -1516,11 +1478,47 @@ trimmed in raw strings.
parsing_should_succeed(FILE_LINE_ARGS, spec_time_1, [](toml::table&& tbl)
{
auto expected = toml::table{{
const auto expected = toml::table{{
{ R"(lt1)"sv, toml::time{ 7, 32, 0, 0 } },
}};
REQUIRE(tbl == expected);
});
#if UNICODE_LITERALS_OK
parsing_should_succeed(FILE_LINE_ARGS, spec_quoted_basic_keys_1, [](toml::table&& tbl)
{
const auto expected = toml::table{{
{ R"(ʎǝʞ)"sv, R"(value)"sv },
}};
REQUIRE(tbl == expected);
});
parsing_should_succeed(FILE_LINE_ARGS, spec_string_basic, [](toml::table&& tbl)
{
const auto expected = toml::table{{
{ R"(str)"sv, R"(I'm a string. "You can quote me". Name José
Location SF.)"sv },
}};
REQUIRE(tbl == expected);
});
parsing_should_succeed(FILE_LINE_ARGS, spec_table_6, [](toml::table&& tbl)
{
const auto expected = toml::table{{
{
R"(j)"sv, toml::table{{
{
R"(ʞ)"sv, toml::table{{
{ R"(l)"sv, toml::table{} },
}}
},
}}
},
}};
REQUIRE(tbl == expected);
});
#endif // UNICODE_LITERALS_OK
}

114
toml.hpp
View File

@ -408,12 +408,21 @@
#endif
#ifndef DOXYGEN
#if defined(_WIN32) && !defined(TOML_WINDOWS_COMPAT)
#define TOML_WINDOWS_COMPAT 1
#ifdef _WIN32
#ifndef TOML_WINDOWS_COMPAT
#define TOML_WINDOWS_COMPAT 1
#endif
#if TOML_WINDOWS_COMPAT && !defined(TOML_INCLUDE_WINDOWS_H)
#define TOML_INCLUDE_WINDOWS_H 0
#endif
#endif
#if !defined(_WIN32) || !defined(TOML_WINDOWS_COMPAT)
#undef TOML_WINDOWS_COMPAT
#define TOML_WINDOWS_COMPAT 0
#define TOML_WINDOWS_COMPAT 0
#endif
#if !TOML_WINDOWS_COMPAT
#undef TOML_INCLUDE_WINDOWS_H
#define TOML_INCLUDE_WINDOWS_H 0
#endif
#endif
@ -620,24 +629,42 @@ is no longer necessary.
#define TOML_ARM 0
#endif
#define TOML_MAKE_BITOPS(type) \
#define TOML_MAKE_FLAGS_(name, op) \
[[nodiscard]] \
TOML_ALWAYS_INLINE \
TOML_ATTR(const) \
TOML_ATTR(flatten) \
constexpr type operator & (type lhs, type rhs) noexcept \
constexpr name operator op(name lhs, name rhs) noexcept \
{ \
return static_cast<type>(::toml::impl::unwrap_enum(lhs) & ::toml::impl::unwrap_enum(rhs)); \
using under = std::underlying_type_t<name>; \
return static_cast<name>(static_cast<under>(lhs) op static_cast<under>(rhs)); \
} \
constexpr name& operator TOML_CONCAT(op, =)(name & lhs, name rhs) noexcept \
{ \
return lhs = (lhs op rhs); \
} \
static_assert(true, "")
#define TOML_MAKE_FLAGS(name) \
TOML_MAKE_FLAGS_(name, &); \
TOML_MAKE_FLAGS_(name, |); \
TOML_MAKE_FLAGS_(name, ^); \
[[nodiscard]] \
TOML_ALWAYS_INLINE \
TOML_ATTR(const) \
constexpr name operator~(name val) noexcept \
{ \
using under = std::underlying_type_t<name>; \
return static_cast<name>(~static_cast<under>(val)); \
} \
[[nodiscard]] \
TOML_ALWAYS_INLINE \
TOML_ATTR(const) \
TOML_ATTR(flatten) \
constexpr type operator | (type lhs, type rhs) noexcept \
constexpr bool operator!(name val) noexcept \
{ \
return static_cast<type>(::toml::impl::unwrap_enum(lhs) | ::toml::impl::unwrap_enum(rhs)); \
using under = std::underlying_type_t<name>; \
return !static_cast<under>(val); \
} \
static_assert(true)
static_assert(true, "")
#ifndef TOML_LIFETIME_HOOKS
#define TOML_LIFETIME_HOOKS 0
@ -1571,7 +1598,7 @@ TOML_NAMESPACE_START
format_as_hexadecimal = 3,
};
TOML_MAKE_BITOPS(value_flags);
TOML_MAKE_FLAGS(value_flags);
enum class format_flags : uint8_t
{
@ -1585,7 +1612,7 @@ TOML_NAMESPACE_START
allow_value_format_flags = 8,
};
TOML_MAKE_BITOPS(format_flags);
TOML_MAKE_FLAGS(format_flags);
template <typename Char>
inline std::basic_ostream<Char>& operator << (std::basic_ostream<Char>& lhs, node_type rhs)
@ -12098,27 +12125,34 @@ TOML_NAMESPACE_END;
#if TOML_WINDOWS_COMPAT
#ifndef _WINDOWS_
extern "C"
{
int __stdcall WideCharToMultiByte(
unsigned int CodePage,
unsigned long dwFlags,
const wchar_t* lpWideCharStr,
int cchWideChar,
char* lpMultiByteStr,
int cbMultiByte,
const char* lpDefaultChar,
int* lpUsedDefaultChar
);
int __stdcall MultiByteToWideChar(
unsigned int CodePage,
unsigned long dwFlags,
const char* lpMultiByteStr,
int cbMultiByte,
wchar_t* lpWideCharStr,
int cchWideChar
);
}
#if TOML_INCLUDE_WINDOWS_H
#include <Windows.h>
#else
extern "C"
{
__declspec(dllimport)
int __stdcall WideCharToMultiByte(
unsigned int CodePage,
unsigned long dwFlags,
const wchar_t* lpWideCharStr,
int cchWideChar,
char* lpMultiByteStr,
int cbMultiByte,
const char* lpDefaultChar,
int* lpUsedDefaultChar
);
__declspec(dllimport)
int __stdcall MultiByteToWideChar(
unsigned int CodePage,
unsigned long dwFlags,
const char* lpMultiByteStr,
int cbMultiByte,
wchar_t* lpWideCharStr,
int cchWideChar
);
}
#endif
#endif // _WINDOWS_
TOML_IMPL_NAMESPACE_START
@ -12130,13 +12164,13 @@ TOML_IMPL_NAMESPACE_START
return {};
std::string s;
const auto len = WideCharToMultiByte(
const auto len = ::WideCharToMultiByte(
65001, 0, str.data(), static_cast<int>(str.length()), nullptr, 0, nullptr, nullptr
);
if (len)
{
s.resize(static_cast<size_t>(len));
WideCharToMultiByte(65001, 0, str.data(), static_cast<int>(str.length()), s.data(), len, nullptr, nullptr);
::WideCharToMultiByte(65001, 0, str.data(), static_cast<int>(str.length()), s.data(), len, nullptr, nullptr);
}
return s;
}
@ -12148,11 +12182,11 @@ TOML_IMPL_NAMESPACE_START
return {};
std::wstring s;
const auto len = MultiByteToWideChar(65001, 0, str.data(), static_cast<int>(str.length()), nullptr, 0);
const auto len = ::MultiByteToWideChar(65001, 0, str.data(), static_cast<int>(str.length()), nullptr, 0);
if (len)
{
s.resize(static_cast<size_t>(len));
MultiByteToWideChar(65001, 0, str.data(), static_cast<int>(str.length()), s.data(), len);
::MultiByteToWideChar(65001, 0, str.data(), static_cast<int>(str.length()), s.data(), len);
}
return s;
}
@ -12420,6 +12454,7 @@ TOML_POP_WARNINGS; // TOML_DISABLE_SPAM_WARNINGS
#undef TOML_IMPLEMENTATION
#undef TOML_IMPL_NAMESPACE_END
#undef TOML_IMPL_NAMESPACE_START
#undef TOML_INCLUDE_WINDOWS_H
#undef TOML_INT128
#undef TOML_INTELLISENSE
#undef TOML_INTERNAL_LINKAGE
@ -12431,7 +12466,8 @@ TOML_POP_WARNINGS; // TOML_DISABLE_SPAM_WARNINGS
#undef TOML_LAUNDER
#undef TOML_LIFETIME_HOOKS
#undef TOML_LIKELY
#undef TOML_MAKE_BITOPS
#undef TOML_MAKE_FLAGS_
#undef TOML_MAKE_FLAGS
#undef TOML_MAKE_VERSION
#undef TOML_MAY_THROW
#undef TOML_MSVC

View File

@ -19,7 +19,7 @@ from datetime import datetime, date, time
def sanitize(s):
s = re.sub(r'[ _:;\/-]+', '_', s, 0, re.I | re.M)
if s in ('bool', 'float', 'int', 'double', 'auto'):
if s in ('bool', 'float', 'int', 'double', 'auto', 'array', 'table'):
s = s + '_'
return s
@ -135,15 +135,11 @@ class TomlPPTable:
s += '\n' + indent + '\t{ '
if isinstance(val, (TomlPPTable, TomlPPArray)) and len(val) > 0:
s += '\n' + indent + '\t\t{},'.format(python_value_to_tomlpp(str(key)))
#s += '\n' + val.render(indent + '\t\t')
s += ' ' + val.render(indent + '\t\t')
s += '\n' + indent + '\t'
else:
s += '{}, {} '.format(python_value_to_tomlpp(str(key)), python_value_to_tomlpp(val))
s += '},'
#else:
#s += '}\n'
s += '\n' + indent + '}}'
return s
@ -170,11 +166,11 @@ def json_to_python(val):
return True if val["value"].lower() == "true" else False
elif val_type == "array":
return json_to_python(val["value"])
elif val_type in ("datetime", "date", "time", "datetime-local"):
elif val_type in ("datetime", "date", "time", "datetime-local", "date-local", "time-local"):
dt_val = dateutil.parser.parse(val["value"])
if val_type == "date":
if val_type in ("date", "date-local"):
return dt_val.date()
elif val_type == "time":
elif val_type in ("time", "time-local"):
return dt_val.time()
else:
return dt_val
@ -218,9 +214,9 @@ class TomlTest:
def __init__(self, file_path, is_valid_case):
self.__name = file_path.stem
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.condition = ''
self.requires_unicode = False
self.__conditions = []
if is_valid_case:
self.__expected = True
path_base = str(Path(file_path.parent, file_path.stem))
@ -246,6 +242,20 @@ class TomlTest:
def identifier(self):
return self.__identifier
def group(self):
return self.__group
def add_condition(self, cond):
self.__conditions.append(cond)
return self
def condition(self):
if not self.__conditions or not self.__conditions[0]:
return ''
if len(self.__conditions) == 1:
return rf'{self.__conditions[0]}'
return rf'{" && ".join([rf"{c}" for c in self.__conditions])}'
def data(self):
return self.__data
@ -265,15 +275,43 @@ def load_tests(source_folder, is_valid_set, ignore_list):
utils.assert_existing_directory(source_folder)
files = utils.get_all_files(source_folder, all="*.toml")
if ignore_list:
files = [f for f in files if f.stem not in ignore_list]
return [TomlTest(f, is_valid_set) for f in files]
files_ = []
for f in files:
ignored = False
for ignore in ignore_list:
if isinstance(ignore, str):
if f.stem == ignore:
ignored = True
break
elif ignore.fullmatch(f.stem) is not None: # regex
ignored = True
break
if not ignored:
files_.append(f)
files = files_
tests = []
for f in files:
try:
tests.append(TomlTest(f, is_valid_set))
except Exception as e:
print(rf'Error reading {f}, skipping...', file=sys.stderr)
return tests
def set_condition(tests, condition, names):
def add_condition(tests, condition, names):
for test in tests:
if test.name() in names:
test.condition = condition
matched = False
for name in names:
if isinstance(name, str):
if test.name() == name:
matched = True
break
elif name.fullmatch(test.name()) is not None: # regex
matched = True
break
if matched:
test.add_condition(condition)
@ -281,8 +319,12 @@ def load_valid_inputs(tests, extern_root):
tests['valid']['burntsushi'] = load_tests(Path(extern_root, 'toml-test', 'tests', 'valid'), True, (
# newline/escape handling tests. these get broken by I/O (I test them separately)
'string-escapes',
# bugged: https://github.com/BurntSushi/toml-test/issues/58
'datetime'
# causes MSVC to run out of heap space during compilation O_o
'inline-table-key-dotted',
# broken by the json reader
'key-alphanum',
# breaks clang:
'multiline-string',
))
tests['valid']['iarna'] = load_tests(Path(extern_root, 'toml-spec-tests', 'values'), True, (
# these are stress-tests for 'large' datasets. I test these separately. Having them inline in C++ code is insane.
@ -297,18 +339,8 @@ def load_valid_inputs(tests, extern_root):
'qa-table-inline-1000',
'qa-table-inline-nested-1000',
# newline/escape handling tests. these get broken by I/O (I test them separately)
'spec-newline-1',
'spec-newline-2',
'spec-newline-3',
'spec-string-escape-1',
'spec-string-escape-2',
'spec-string-escape-3',
'spec-string-escape-4',
'spec-string-escape-5',
'spec-string-escape-6',
'spec-string-escape-7',
'spec-string-escape-8',
'spec-string-escape-9',
re.compile(r'spec-newline-.*'),
re.compile(r'spec-string-escape-.*'),
# bugged: https://github.com/iarna/toml-spec-tests/issues/3
'spec-date-time-6',
'spec-date-time-local-2',
@ -322,41 +354,25 @@ def load_valid_inputs(tests, extern_root):
def load_invalid_inputs(tests, extern_root):
tests['invalid']['burntsushi'] = load_tests(Path(extern_root, 'toml-test', 'tests', 'invalid'), False, (
# false negatives after TOML 0.4.0
'array-mixed-types-arrays-and-ints',
'array-mixed-types-ints-and-floats',
'array-mixed-types-strings-and-ints'
re.compile('array-mixed.*'),
# these break IO/git/visual studio (i test them elsewhere)
re.compile('.*(bom|control).*'),
'encoding-utf16',
))
set_condition(tests['invalid']['burntsushi'], '!TOML_LANG_UNRELEASED', (
'datetime-malformed-no-secs',
'inline-table-linebreak',
add_condition(tests['invalid']['burntsushi'], '!TOML_LANG_UNRELEASED', (
'datetime-no-secs',
re.compile(r'inline-table-linebreak-.*'),
'inline-table-trailing-comma',
'key-special-character',
'multi-line-inline-table',
'string-byte-escapes'
'string-basic-byte-escapes',
))
tests['invalid']['iarna'] = load_tests(Path(extern_root, 'toml-spec-tests', 'errors'), False, (
# I test these explicitly in the other test files (they get broken by I/O)
'comment-control-1',
'comment-control-2',
'comment-control-3',
'comment-control-4',
'string-basic-control-1',
'string-basic-control-2',
'string-basic-control-3',
'string-basic-control-4',
'string-basic-multiline-control-1',
'string-basic-multiline-control-2',
'string-basic-multiline-control-3',
'string-basic-multiline-control-4',
'string-literal-control-1',
'string-literal-control-2',
'string-literal-control-3',
'string-literal-control-4',
'string-literal-multiline-control-1',
'string-literal-multiline-control-2',
'string-literal-multiline-control-3',
'string-literal-multiline-control-4'
# these break IO/git/visual studio (i test them elsewhere)
re.compile('.*(bom|control).*'),
))
set_condition(tests['invalid']['iarna'], '!TOML_LANG_UNRELEASED', (
add_condition(tests['invalid']['iarna'], '!TOML_LANG_UNRELEASED', (
'inline-table-trailing-comma',
))
@ -370,16 +386,29 @@ def requires_unicode(s):
def write_test_file(name, test_cases):
def write_test_file(name, all_tests):
conditions = set()
for test in test_cases:
conditions.add(test.condition)
for test in all_tests:
unicode = requires_unicode(str(test))
if not unicode and not isinstance(test.expected(), bool):
unicode = requires_unicode(test.expected().render())
if unicode:
test.add_condition(r'UNICODE_LITERALS_OK')
tests_by_group = {}
for test in all_tests:
if test.group() not in tests_by_group:
tests_by_group[test.group()] = {}
cond = test.condition()
if cond not in tests_by_group[test.group()]:
tests_by_group[test.group()][cond] = []
tests_by_group[test.group()][cond].append(test)
all_tests = tests_by_group
test_file_path = Path(utils.entry_script_dir(), '..', 'tests', rf'conformance_{sanitize(name.strip())}.cpp').resolve()
print(rf'Writing to {test_file_path}')
with open(test_file_path, 'w', encoding='utf-8', newline='\n') as test_file:
write = lambda txt: print(txt, file=test_file)
write = lambda txt,end='\n': print(txt, file=test_file, end=end)
# preamble
write('// This file is a part of toml++ and is subject to the the terms of the MIT license.')
@ -397,16 +426,18 @@ def write_test_file(name, test_cases):
write('TOML_DISABLE_WARNINGS; // unused variable spam')
write('')
write('namespace')
write('{')
for test in test_cases:
s = f'\t{test}'
test.requires_unicode = requires_unicode(s)
if test.requires_unicode:
write('\t#if UNICODE_LITERALS_OK')
write(s)
write('\t#endif // UNICODE_LITERALS_OK')
else:
write(s)
write('{', end='')
for group, conditions in all_tests.items():
for condition, tests in conditions.items():
write('')
if condition != '':
write(f'#if {condition}');
write('')
for test in tests:
write(f'\t{test}')
if condition != '':
write('')
write(f'#endif // {condition}');
write('}')
write('')
write('TOML_ENABLE_WARNINGS;')
@ -414,50 +445,46 @@ def write_test_file(name, test_cases):
# tests
write(f'TEST_CASE("conformance - {name}")')
write('{')
for condition in conditions:
if condition != '':
write('')
write(f'\t#if {condition}');
for test in test_cases:
if test.condition != condition:
continue
expected = test.expected()
if isinstance(expected, bool):
if expected:
write(f'\tparsing_should_succeed(FILE_LINE_ARGS, {test.identifier()});')
else:
write(f'\tparsing_should_fail(FILE_LINE_ARGS, {test.identifier()});')
else:
s = expected.render('\t\t')
if not test.requires_unicode:
test.requires_unicode = requires_unicode(s)
if test.requires_unicode:
write('\t#if UNICODE_LITERALS_OK')
write(f'\tparsing_should_succeed(FILE_LINE_ARGS, {test.identifier()}, [](toml::table&& tbl)')
write('\t{')
write(f'\t\tauto expected = {s};')
write('\t\tREQUIRE(tbl == expected);')
write('\t});')
if test.requires_unicode:
write('\t#endif // UNICODE_LITERALS_OK')
write('{', end='')
for group, conditions in all_tests.items():
for condition, tests in conditions.items():
if condition != '':
write('')
if condition != '':
write(f'\t#endif // {condition}');
write(f'#if {condition}');
for test in tests:
write('')
expected = test.expected()
if isinstance(expected, bool):
if expected:
write(f'\tparsing_should_succeed(FILE_LINE_ARGS, {test.identifier()});')
else:
write(f'\tparsing_should_fail(FILE_LINE_ARGS, {test.identifier()});')
else:
s = expected.render('\t\t')
write(f'\tparsing_should_succeed(FILE_LINE_ARGS, {test.identifier()}, [](toml::table&& tbl)')
write('\t{')
write(f'\t\tconst auto expected = {s};')
write('\t\tREQUIRE(tbl == expected);')
write('\t});')
if condition != '':
write('')
write(f'#endif // {condition}');
write('}')
write('')
def main():
extern_root = Path(utils.entry_script_dir(), '..', 'external').resolve()
utils.assert_existing_directory(extern_root)
assert extern_root.exists()
tests = { 'valid': dict(), 'invalid': dict() }
load_valid_inputs(tests, extern_root)
load_invalid_inputs(tests, extern_root)
for test_type, test_groups in tests.items():
for test_group, test_cases in test_groups.items():
write_test_file('{}/{}'.format(test_group, test_type), test_cases )
all_tests = { 'valid': dict(), 'invalid': dict() }
load_valid_inputs(all_tests, extern_root)
load_invalid_inputs(all_tests, extern_root)
for validity, sources in all_tests.items():
for source, tests in sources.items():
write_test_file('{}/{}'.format(source, validity), tests )
if __name__ == '__main__':