mirror of
https://github.com/marzer/tomlplusplus.git
synced 2024-09-04 14:09:11 +00:00
removed internal operator""_sz (ADL is a cruel mistress)
also: - applied clang-format to tests - added some missing `TOML_API`
This commit is contained in:
parent
7da912c45e
commit
dbc078202d
@ -156,7 +156,6 @@ StatementMacros:
|
||||
- TOML_ALWAYS_INLINE
|
||||
- TOML_API
|
||||
- TOML_ATTR
|
||||
- TOML_CONSTEVAL
|
||||
- TOML_EXTERNAL_LINKAGE
|
||||
- TOML_INTERNAL_LINKAGE
|
||||
- TOML_MEMBER_ATTR
|
||||
|
1
cpp.hint
1
cpp.hint
@ -6,7 +6,6 @@
|
||||
#define TOML_ABSTRACT_BASE
|
||||
#define TOML_EMPTY_BASES
|
||||
#define TOML_MAY_THROW
|
||||
#define TOML_CONSTEVAL constexpr
|
||||
#define TOML_CONSTRAINED_TEMPLATE(cond, ...) template <__VA_ARGS__>
|
||||
#define TOML_LIKELY(...) (__VA_ARGS__)
|
||||
#define TOML_UNLIKELY(...) (__VA_ARGS__)
|
||||
|
@ -356,14 +356,13 @@ TOML_NAMESPACE_START
|
||||
/// \tparam ElemTypes One of the TOML node or value types (or a type promotable to one).
|
||||
/// \param val The node or value used to initialize element 0.
|
||||
/// \param vals The nodes or values used to initialize elements 1...N.
|
||||
TOML_CONSTRAINED_TEMPLATE((sizeof...(ElemTypes) > 0_sz
|
||||
|| !std::is_same_v<impl::remove_cvref_t<ElemType>, array>),
|
||||
TOML_CONSTRAINED_TEMPLATE((sizeof...(ElemTypes) > 0 || !std::is_same_v<impl::remove_cvref_t<ElemType>, array>),
|
||||
typename ElemType,
|
||||
typename... ElemTypes)
|
||||
TOML_NODISCARD_CTOR
|
||||
explicit array(ElemType&& val, ElemTypes&&... vals)
|
||||
{
|
||||
elements.reserve(sizeof...(ElemTypes) + 1_sz);
|
||||
elements.reserve(sizeof...(ElemTypes) + 1u);
|
||||
emplace_back_if_not_empty_view(static_cast<ElemType&&>(val));
|
||||
if constexpr (sizeof...(ElemTypes) > 0)
|
||||
{
|
||||
@ -659,7 +658,7 @@ TOML_NAMESPACE_START
|
||||
const auto start_idx = static_cast<size_t>(pos.raw_ - elements.cbegin());
|
||||
preinsertion_resize(start_idx, count);
|
||||
size_t i = start_idx;
|
||||
for (size_t e = start_idx + count - 1_sz; i < e; i++)
|
||||
for (size_t e = start_idx + count - 1u; i < e; i++)
|
||||
elements[i].reset(impl::make_node(val));
|
||||
|
||||
//# potentially move the initial value into the last element
|
||||
@ -1087,7 +1086,7 @@ TOML_NAMESPACE_START
|
||||
|
||||
if (lhs.size() != rhs.size())
|
||||
return false;
|
||||
if (rhs.size() == 0_sz)
|
||||
if (rhs.size() == 0u)
|
||||
return true;
|
||||
|
||||
size_t i{};
|
||||
|
@ -94,14 +94,14 @@ TOML_NAMESPACE_START
|
||||
void array::preinsertion_resize(size_t idx, size_t count) noexcept
|
||||
{
|
||||
TOML_ASSERT(idx <= elements.size());
|
||||
TOML_ASSERT(count >= 1_sz);
|
||||
TOML_ASSERT(count >= 1u);
|
||||
const auto old_size = elements.size();
|
||||
const auto new_size = old_size + count;
|
||||
const auto inserting_at_end = idx == old_size;
|
||||
elements.resize(new_size);
|
||||
if (!inserting_at_end)
|
||||
{
|
||||
for (size_t left = old_size, right = new_size - 1_sz; left-- > idx; right--)
|
||||
for (size_t left = old_size, right = new_size - 1u; left-- > idx; right--)
|
||||
elements[right] = std::move(elements[left]);
|
||||
}
|
||||
}
|
||||
@ -165,7 +165,7 @@ TOML_NAMESPACE_START
|
||||
for (size_t i = 0, e = elements.size(); i < e; i++)
|
||||
{
|
||||
auto arr = elements[i]->as_array();
|
||||
leaves += arr ? arr->total_leaf_count() : 1_sz;
|
||||
leaves += arr ? arr->total_leaf_count() : size_t{ 1 };
|
||||
}
|
||||
return leaves;
|
||||
}
|
||||
@ -195,14 +195,14 @@ TOML_NAMESPACE_START
|
||||
|
||||
bool requires_flattening = false;
|
||||
size_t size_after_flattening = elements.size();
|
||||
for (size_t i = elements.size(); i-- > 0_sz;)
|
||||
for (size_t i = elements.size(); i-- > 0u;)
|
||||
{
|
||||
auto arr = elements[i]->as_array();
|
||||
if (!arr)
|
||||
continue;
|
||||
size_after_flattening--; // discount the array itself
|
||||
const auto leaf_count = arr->total_leaf_count();
|
||||
if (leaf_count > 0_sz)
|
||||
if (leaf_count > 0u)
|
||||
{
|
||||
requires_flattening = true;
|
||||
size_after_flattening += leaf_count;
|
||||
@ -228,8 +228,8 @@ TOML_NAMESPACE_START
|
||||
|
||||
std::unique_ptr<node> arr_storage = std::move(elements[i]);
|
||||
const auto leaf_count = arr->total_leaf_count();
|
||||
if (leaf_count > 1_sz)
|
||||
preinsertion_resize(i + 1_sz, leaf_count - 1_sz);
|
||||
if (leaf_count > 1u)
|
||||
preinsertion_resize(i + 1u, leaf_count - 1u);
|
||||
flatten_child(std::move(*arr), i); // increments i
|
||||
}
|
||||
|
||||
|
@ -46,7 +46,7 @@ TOML_NAMESPACE_START
|
||||
std::vector<std::string> key_path_;
|
||||
bool pending_table_separator_ = false;
|
||||
|
||||
static constexpr size_t line_wrap_cols = 120_sz;
|
||||
static constexpr size_t line_wrap_cols = 120;
|
||||
|
||||
TOML_NODISCARD
|
||||
TOML_API
|
||||
|
@ -45,7 +45,7 @@ TOML_NAMESPACE_START
|
||||
if (requires_quotes)
|
||||
{
|
||||
std::string s;
|
||||
s.reserve(str.length() + 2_sz);
|
||||
s.reserve(str.length() + 2u);
|
||||
s += '"';
|
||||
for (auto c : str)
|
||||
{
|
||||
@ -75,11 +75,11 @@ TOML_NAMESPACE_START
|
||||
{
|
||||
auto& n = *reinterpret_cast<const table*>(&node);
|
||||
if (n.empty())
|
||||
return 2_sz; // "{}"
|
||||
size_t weight = 3_sz; // "{ }"
|
||||
return 2u; // "{}"
|
||||
size_t weight = 3u; // "{ }"
|
||||
for (auto&& [k, v] : n)
|
||||
{
|
||||
weight += k.length() + count_inline_columns(v) + 2_sz; // + ", "
|
||||
weight += k.length() + count_inline_columns(v) + 2u; // + ", "
|
||||
if (weight >= line_wrap_cols)
|
||||
break;
|
||||
}
|
||||
@ -90,11 +90,11 @@ TOML_NAMESPACE_START
|
||||
{
|
||||
auto& n = *reinterpret_cast<const array*>(&node);
|
||||
if (n.empty())
|
||||
return 2_sz; // "[]"
|
||||
size_t weight = 3_sz; // "[ ]"
|
||||
return 2u; // "[]"
|
||||
size_t weight = 3u; // "[ ]"
|
||||
for (auto& elem : n)
|
||||
{
|
||||
weight += count_inline_columns(elem) + 2_sz; // + ", "
|
||||
weight += count_inline_columns(elem) + 2u; // + ", "
|
||||
if (weight >= line_wrap_cols)
|
||||
break;
|
||||
}
|
||||
@ -104,7 +104,7 @@ TOML_NAMESPACE_START
|
||||
case node_type::string:
|
||||
{
|
||||
auto& n = *reinterpret_cast<const value<std::string>*>(&node);
|
||||
return n.get().length() + 2_sz; // + ""
|
||||
return n.get().length() + 2u; // + ""
|
||||
}
|
||||
|
||||
case node_type::integer:
|
||||
@ -112,14 +112,14 @@ TOML_NAMESPACE_START
|
||||
auto& n = *reinterpret_cast<const value<int64_t>*>(&node);
|
||||
auto v = n.get();
|
||||
if (!v)
|
||||
return 1_sz;
|
||||
return 1u;
|
||||
size_t weight = {};
|
||||
if (v < 0)
|
||||
{
|
||||
weight += 1;
|
||||
weight += 1u;
|
||||
v *= -1;
|
||||
}
|
||||
return weight + static_cast<size_t>(log10(static_cast<double>(v))) + 1_sz;
|
||||
return weight + static_cast<size_t>(log10(static_cast<double>(v))) + 1u;
|
||||
}
|
||||
|
||||
case node_type::floating_point:
|
||||
@ -127,21 +127,21 @@ TOML_NAMESPACE_START
|
||||
auto& n = *reinterpret_cast<const value<double>*>(&node);
|
||||
auto v = n.get();
|
||||
if (v == 0.0)
|
||||
return 3_sz; // "0.0"
|
||||
size_t weight = 2_sz; // ".0"
|
||||
return 3u; // "0.0"
|
||||
size_t weight = 2u; // ".0"
|
||||
if (v < 0.0)
|
||||
{
|
||||
weight += 1;
|
||||
weight += 1u;
|
||||
v *= -1.0;
|
||||
}
|
||||
return weight + static_cast<size_t>(log10(v)) + 1_sz;
|
||||
return weight + static_cast<size_t>(log10(v)) + 1u;
|
||||
break;
|
||||
}
|
||||
|
||||
case node_type::boolean: return 5_sz;
|
||||
case node_type::boolean: return 5u;
|
||||
case node_type::date: [[fallthrough]];
|
||||
case node_type::time: return 10_sz;
|
||||
case node_type::date_time: return 30_sz;
|
||||
case node_type::time: return 10u;
|
||||
case node_type::date_time: return 30u;
|
||||
case node_type::none: TOML_UNREACHABLE;
|
||||
default: TOML_UNREACHABLE;
|
||||
}
|
||||
@ -267,7 +267,7 @@ TOML_NAMESPACE_START
|
||||
|
||||
for (size_t i = 0; i < arr.size(); i++)
|
||||
{
|
||||
if (i > 0_sz)
|
||||
if (i > 0u)
|
||||
{
|
||||
impl::print_to_stream(base::stream(), ',');
|
||||
if (!multiline)
|
||||
@ -309,7 +309,7 @@ TOML_NAMESPACE_START
|
||||
static constexpr auto is_non_inline_array_of_tables = [](auto&& nde) noexcept
|
||||
{
|
||||
auto arr = nde.as_array();
|
||||
return arr && arr->is_array_of_tables() && !arr->template get_as<table>(0_sz)->is_inline();
|
||||
return arr && arr->is_array_of_tables() && !arr->template get_as<table>(0u)->is_inline();
|
||||
};
|
||||
|
||||
// values, arrays, and inline tables/table arrays
|
||||
@ -372,7 +372,7 @@ TOML_NAMESPACE_START
|
||||
}
|
||||
}
|
||||
bool skip_self = false;
|
||||
if (child_value_count == 0_sz && (child_table_count > 0_sz || child_table_array_count > 0_sz))
|
||||
if (child_value_count == 0u && (child_table_count > 0u || child_table_array_count > 0u))
|
||||
skip_self = true;
|
||||
|
||||
key_path_.push_back(make_key_segment(k));
|
||||
|
@ -110,15 +110,6 @@ TOML_NAMESPACE_START
|
||||
class parse_result;
|
||||
#endif
|
||||
TOML_ABI_NAMESPACE_END; // TOML_EXCEPTIONS
|
||||
|
||||
TOML_NODISCARD
|
||||
TOML_ATTR(const)
|
||||
TOML_ALWAYS_INLINE
|
||||
TOML_CONSTEVAL
|
||||
size_t operator"" _sz(unsigned long long n) noexcept
|
||||
{
|
||||
return static_cast<size_t>(n);
|
||||
}
|
||||
}
|
||||
TOML_NAMESPACE_END;
|
||||
|
||||
|
@ -68,7 +68,7 @@ TOML_NAMESPACE_START
|
||||
base::increase_indent();
|
||||
for (size_t i = 0; i < arr.size(); i++)
|
||||
{
|
||||
if (i > 0_sz)
|
||||
if (i > 0u)
|
||||
impl::print_to_stream(base::stream(), ',');
|
||||
base::print_newline(true);
|
||||
base::print_indent();
|
||||
|
@ -51,7 +51,7 @@ TOML_ANON_NAMESPACE_START
|
||||
template <typename Char>
|
||||
class utf8_byte_stream<std::basic_string_view<Char>>
|
||||
{
|
||||
static_assert(sizeof(Char) == 1_sz);
|
||||
static_assert(sizeof(Char) == 1);
|
||||
|
||||
private:
|
||||
std::basic_string_view<Char> source_;
|
||||
@ -65,20 +65,20 @@ TOML_ANON_NAMESPACE_START
|
||||
// trim trailing nulls
|
||||
const size_t initial_len = source_.length();
|
||||
size_t actual_len = initial_len;
|
||||
for (size_t i = actual_len; i-- > 0_sz;)
|
||||
for (size_t i = actual_len; i-- > 0u;)
|
||||
{
|
||||
if (source_[i] != Char{}) // not '\0'
|
||||
{
|
||||
actual_len = i + 1_sz;
|
||||
actual_len = i + 1u;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (initial_len != actual_len)
|
||||
source_ = source_.substr(0_sz, actual_len);
|
||||
source_ = source_.substr(0u, actual_len);
|
||||
|
||||
// skip bom
|
||||
if (actual_len >= 3_sz && memcmp(utf8_byte_order_mark.data(), source_.data(), 3_sz) == 0)
|
||||
position_ += 3_sz;
|
||||
if (actual_len >= 3u && memcmp(utf8_byte_order_mark.data(), source_.data(), 3u) == 0)
|
||||
position_ += 3u;
|
||||
}
|
||||
|
||||
TOML_NODISCARD
|
||||
@ -114,7 +114,7 @@ TOML_ANON_NAMESPACE_START
|
||||
template <typename Char>
|
||||
class utf8_byte_stream<std::basic_istream<Char>>
|
||||
{
|
||||
static_assert(sizeof(Char) == 1_sz);
|
||||
static_assert(sizeof(Char) == 1);
|
||||
|
||||
private:
|
||||
std::basic_istream<Char>* source_;
|
||||
@ -130,7 +130,7 @@ TOML_ANON_NAMESPACE_START
|
||||
const auto initial_pos = source_->tellg();
|
||||
Char bom[3];
|
||||
source_->read(bom, 3);
|
||||
if (source_->bad() || (source_->gcount() == 3 && memcmp(utf8_byte_order_mark.data(), bom, 3_sz) == 0))
|
||||
if (source_->bad() || (source_->gcount() == 3 && memcmp(utf8_byte_order_mark.data(), bom, 3u) == 0))
|
||||
return;
|
||||
|
||||
source_->clear();
|
||||
@ -178,7 +178,7 @@ TOML_ANON_NAMESPACE_START
|
||||
TOML_NODISCARD
|
||||
std::string_view as_view() const noexcept
|
||||
{
|
||||
return bytes[3] ? std::string_view{ bytes, 4_sz } : std::string_view{ bytes };
|
||||
return bytes[3] ? std::string_view{ bytes, 4u } : std::string_view{ bytes };
|
||||
}
|
||||
|
||||
TOML_NODISCARD
|
||||
@ -269,7 +269,7 @@ TOML_ANON_NAMESPACE_START
|
||||
{
|
||||
TOML_ERROR_CHECK;
|
||||
|
||||
auto& prev = codepoints_[(cp_idx_ - 1_sz) % 2_sz];
|
||||
auto& prev = codepoints_[(cp_idx_ - 1u) % 2u];
|
||||
|
||||
if (stream_.eof())
|
||||
return nullptr;
|
||||
@ -333,7 +333,7 @@ TOML_ANON_NAMESPACE_START
|
||||
|
||||
TOML_ERROR_CHECK;
|
||||
|
||||
auto& current = codepoints_[cp_idx_ % 2_sz];
|
||||
auto& current = codepoints_[cp_idx_ % 2u];
|
||||
current.bytes[current_byte_count_++] = static_cast<char>(next_byte);
|
||||
if (decoder_.has_code_point())
|
||||
{
|
||||
@ -966,7 +966,7 @@ TOML_IMPL_NAMESPACE_START
|
||||
TOML_NEVER_INLINE
|
||||
void set_error_at(source_position pos, const T&... reason) const TOML_MAY_THROW
|
||||
{
|
||||
static_assert(sizeof...(T) > 0_sz);
|
||||
static_assert(sizeof...(T) > 0);
|
||||
#if !TOML_EXCEPTIONS
|
||||
if (err)
|
||||
return;
|
||||
@ -991,7 +991,7 @@ TOML_IMPL_NAMESPACE_START
|
||||
set_error_at(current_position(1), reason...);
|
||||
}
|
||||
|
||||
void go_back(size_t count = 1_sz) noexcept
|
||||
void go_back(size_t count = 1) noexcept
|
||||
{
|
||||
return_if_error();
|
||||
assert_or_assume(count);
|
||||
@ -1034,7 +1034,7 @@ TOML_IMPL_NAMESPACE_START
|
||||
recording_buffer.append(cp->as_view());
|
||||
}
|
||||
|
||||
void stop_recording(size_t pop_bytes = 0_sz) noexcept
|
||||
void stop_recording(size_t pop_bytes = 0) noexcept
|
||||
{
|
||||
return_if_error();
|
||||
|
||||
@ -1043,7 +1043,7 @@ TOML_IMPL_NAMESPACE_START
|
||||
{
|
||||
if (pop_bytes >= recording_buffer.length())
|
||||
recording_buffer.clear();
|
||||
else if (pop_bytes == 1_sz)
|
||||
else if (pop_bytes == 1u)
|
||||
recording_buffer.pop_back();
|
||||
else
|
||||
recording_buffer.erase(recording_buffer.begin()
|
||||
@ -1322,7 +1322,7 @@ TOML_IMPL_NAMESPACE_START
|
||||
if (multi_line)
|
||||
{
|
||||
size_t lookaheads = {};
|
||||
size_t consecutive_delimiters = 1_sz;
|
||||
size_t consecutive_delimiters = 1;
|
||||
do
|
||||
{
|
||||
advance_and_return_if_error({});
|
||||
@ -1332,30 +1332,30 @@ TOML_IMPL_NAMESPACE_START
|
||||
else
|
||||
break;
|
||||
}
|
||||
while (lookaheads < 4_sz);
|
||||
while (lookaheads < 4u);
|
||||
|
||||
switch (consecutive_delimiters)
|
||||
{
|
||||
// """ " (one quote somewhere in a ML string)
|
||||
case 1_sz:
|
||||
case 1:
|
||||
str += '"';
|
||||
skipping_whitespace = false;
|
||||
continue;
|
||||
|
||||
// """ "" (two quotes somewhere in a ML string)
|
||||
case 2_sz:
|
||||
case 2:
|
||||
str.append("\"\""sv);
|
||||
skipping_whitespace = false;
|
||||
continue;
|
||||
|
||||
// """ """ (the end of the string)
|
||||
case 3_sz: return str;
|
||||
case 3: return str;
|
||||
|
||||
// """ """" (one at the end of the string)
|
||||
case 4_sz: str += '"'; return str;
|
||||
case 4: str += '"'; return str;
|
||||
|
||||
// """ """"" (two quotes at the end of the string)
|
||||
case 5_sz:
|
||||
case 5:
|
||||
str.append("\"\""sv);
|
||||
advance_and_return_if_error({}); // skip the last '"'
|
||||
return str;
|
||||
@ -1451,7 +1451,7 @@ TOML_IMPL_NAMESPACE_START
|
||||
if (multi_line)
|
||||
{
|
||||
size_t lookaheads = {};
|
||||
size_t consecutive_delimiters = 1_sz;
|
||||
size_t consecutive_delimiters = 1;
|
||||
do
|
||||
{
|
||||
advance_and_return_if_error({});
|
||||
@ -1461,24 +1461,24 @@ TOML_IMPL_NAMESPACE_START
|
||||
else
|
||||
break;
|
||||
}
|
||||
while (lookaheads < 4_sz);
|
||||
while (lookaheads < 4u);
|
||||
|
||||
switch (consecutive_delimiters)
|
||||
{
|
||||
// ''' ' (one quote somewhere in a ML string)
|
||||
case 1_sz: str += '\''; continue;
|
||||
case 1: str += '\''; continue;
|
||||
|
||||
// ''' '' (two quotes somewhere in a ML string)
|
||||
case 2_sz: str.append("''"sv); continue;
|
||||
case 2: str.append("''"sv); continue;
|
||||
|
||||
// ''' ''' (the end of the string)
|
||||
case 3_sz: return str;
|
||||
case 3: return str;
|
||||
|
||||
// ''' '''' (one at the end of the string)
|
||||
case 4_sz: str += '\''; return str;
|
||||
case 4: str += '\''; return str;
|
||||
|
||||
// ''' ''''' (two quotes at the end of the string)
|
||||
case 5_sz:
|
||||
case 5:
|
||||
str.append("''"sv);
|
||||
advance_and_return_if_error({}); // skip the last '
|
||||
return str;
|
||||
@ -1561,7 +1561,7 @@ TOML_IMPL_NAMESPACE_START
|
||||
{
|
||||
// step back two characters so that the current
|
||||
// character is the string delimiter
|
||||
go_back(2_sz);
|
||||
go_back(2u);
|
||||
|
||||
return { first == U'\'' ? parse_literal_string(false) : parse_basic_string(false), false };
|
||||
}
|
||||
@ -1871,7 +1871,7 @@ TOML_IMPL_NAMESPACE_START
|
||||
set_error_and_return_default("expected exponent digit or sign, saw '"sv, to_sv(*cp), "'"sv);
|
||||
|
||||
// 0x.p-0 (mantissa is just '.')
|
||||
else if (fragments[0].length == 0_sz && fragments[1].length == 0_sz)
|
||||
else if (fragments[0].length == 0u && fragments[1].length == 0u)
|
||||
set_error_and_return_default("expected hexadecimal digit, saw '"sv, to_sv(*cp), "'"sv);
|
||||
|
||||
else
|
||||
@ -1906,7 +1906,7 @@ TOML_IMPL_NAMESPACE_START
|
||||
}
|
||||
|
||||
// sanity-check ending state
|
||||
if (current_fragment != fragments + 2 || current_fragment->length == 0_sz)
|
||||
if (current_fragment != fragments + 2 || current_fragment->length == 0u)
|
||||
{
|
||||
set_error_and_return_if_eof({});
|
||||
set_error_and_return_default("missing exponent"sv);
|
||||
@ -1937,7 +1937,7 @@ TOML_IMPL_NAMESPACE_START
|
||||
|
||||
// calculate value
|
||||
auto place = 1u;
|
||||
for (size_t i = 0; i < f.length - 1_sz; i++)
|
||||
for (size_t i = 0; i < f.length - 1u; i++)
|
||||
place *= base;
|
||||
uint32_t val{};
|
||||
while (place)
|
||||
@ -2051,7 +2051,7 @@ TOML_IMPL_NAMESPACE_START
|
||||
}
|
||||
|
||||
// single digits can be converted trivially
|
||||
if (length == 1_sz)
|
||||
if (length == 1u)
|
||||
{
|
||||
if constexpr (base == 16)
|
||||
return static_cast<int64_t>(hex_to_dec(chars[0]));
|
||||
@ -2101,7 +2101,7 @@ TOML_IMPL_NAMESPACE_START
|
||||
|
||||
// "YYYY"
|
||||
uint32_t digits[4];
|
||||
if (!consume_digit_sequence(digits, 4_sz))
|
||||
if (!consume_digit_sequence(digits, 4u))
|
||||
set_error_and_return_default("expected 4-digit year, saw '"sv, to_sv(cp), "'"sv);
|
||||
const auto year = digits[3] + digits[2] * 10u + digits[1] * 100u + digits[0] * 1000u;
|
||||
const auto is_leap_year = (year % 4u == 0u) && ((year % 100u != 0u) || (year % 400u == 0u));
|
||||
@ -2113,7 +2113,7 @@ TOML_IMPL_NAMESPACE_START
|
||||
advance_and_return_if_error_or_eof({});
|
||||
|
||||
// "MM"
|
||||
if (!consume_digit_sequence(digits, 2_sz))
|
||||
if (!consume_digit_sequence(digits, 2u))
|
||||
set_error_and_return_default("expected 2-digit month, saw '"sv, to_sv(cp), "'"sv);
|
||||
const auto month = digits[1] + digits[0] * 10u;
|
||||
if (month == 0u || month > 12u)
|
||||
@ -2130,7 +2130,7 @@ TOML_IMPL_NAMESPACE_START
|
||||
advance_and_return_if_error_or_eof({});
|
||||
|
||||
// "DD"
|
||||
if (!consume_digit_sequence(digits, 2_sz))
|
||||
if (!consume_digit_sequence(digits, 2u))
|
||||
set_error_and_return_default("expected 2-digit day, saw '"sv, to_sv(cp), "'"sv);
|
||||
const auto day = digits[1] + digits[0] * 10u;
|
||||
if (day == 0u || day > max_days_in_month)
|
||||
@ -2153,11 +2153,11 @@ TOML_IMPL_NAMESPACE_START
|
||||
assert_or_assume(is_decimal_digit(*cp));
|
||||
push_parse_scope("time"sv);
|
||||
|
||||
static constexpr auto max_digits = 9_sz;
|
||||
static constexpr size_t max_digits = 9;
|
||||
uint32_t digits[max_digits];
|
||||
|
||||
// "HH"
|
||||
if (!consume_digit_sequence(digits, 2_sz))
|
||||
if (!consume_digit_sequence(digits, 2u))
|
||||
set_error_and_return_default("expected 2-digit hour, saw '"sv, to_sv(cp), "'"sv);
|
||||
const auto hour = digits[1] + digits[0] * 10u;
|
||||
if (hour > 23u)
|
||||
@ -2171,7 +2171,7 @@ TOML_IMPL_NAMESPACE_START
|
||||
advance_and_return_if_error_or_eof({});
|
||||
|
||||
// "MM"
|
||||
if (!consume_digit_sequence(digits, 2_sz))
|
||||
if (!consume_digit_sequence(digits, 2u))
|
||||
set_error_and_return_default("expected 2-digit minute, saw '"sv, to_sv(cp), "'"sv);
|
||||
const auto minute = digits[1] + digits[0] * 10u;
|
||||
if (minute > 59u)
|
||||
@ -2195,7 +2195,7 @@ TOML_IMPL_NAMESPACE_START
|
||||
advance_and_return_if_error_or_eof({});
|
||||
|
||||
// "SS"
|
||||
if (!consume_digit_sequence(digits, 2_sz))
|
||||
if (!consume_digit_sequence(digits, 2u))
|
||||
set_error_and_return_default("expected 2-digit second, saw '"sv, to_sv(cp), "'"sv);
|
||||
const auto second = digits[1] + digits[0] * 10u;
|
||||
if (second > 59u)
|
||||
@ -2211,7 +2211,7 @@ TOML_IMPL_NAMESPACE_START
|
||||
advance_and_return_if_error_or_eof({});
|
||||
|
||||
// "FFFFFFFFF"
|
||||
auto digit_count = consume_variable_length_digit_sequence(digits, max_digits);
|
||||
size_t digit_count = consume_variable_length_digit_sequence(digits, max_digits);
|
||||
if (!digit_count)
|
||||
{
|
||||
set_error_and_return_if_eof({});
|
||||
@ -2228,7 +2228,7 @@ TOML_IMPL_NAMESPACE_START
|
||||
|
||||
uint32_t value = 0u;
|
||||
uint32_t place = 1u;
|
||||
for (auto i = digit_count; i-- > 0_sz;)
|
||||
for (auto i = digit_count; i-- > 0u;)
|
||||
{
|
||||
value += digits[i] * place;
|
||||
place *= 10u;
|
||||
@ -2280,7 +2280,7 @@ TOML_IMPL_NAMESPACE_START
|
||||
|
||||
// "HH"
|
||||
int digits[2];
|
||||
if (!consume_digit_sequence(digits, 2_sz))
|
||||
if (!consume_digit_sequence(digits, 2u))
|
||||
set_error_and_return_default("expected 2-digit hour, saw '"sv, to_sv(cp), "'"sv);
|
||||
const auto hour = digits[1] + digits[0] * 10;
|
||||
if (hour > 23)
|
||||
@ -2294,7 +2294,7 @@ TOML_IMPL_NAMESPACE_START
|
||||
advance_and_return_if_error_or_eof({});
|
||||
|
||||
// "MM"
|
||||
if (!consume_digit_sequence(digits, 2_sz))
|
||||
if (!consume_digit_sequence(digits, 2u))
|
||||
set_error_and_return_default("expected 2-digit minute, saw '"sv, to_sv(cp), "'"sv);
|
||||
const auto minute = digits[1] + digits[0] * 10;
|
||||
if (minute > 59)
|
||||
@ -2464,19 +2464,19 @@ TOML_IMPL_NAMESPACE_START
|
||||
switch (static_cast<char32_t>(c | 32u))
|
||||
{
|
||||
case U'b':
|
||||
if (char_count == 2_sz && has_any(begins_zero))
|
||||
if (char_count == 2u && has_any(begins_zero))
|
||||
add_trait(has_b);
|
||||
break;
|
||||
|
||||
case U'e':
|
||||
if (char_count > 1_sz
|
||||
if (char_count > 1u
|
||||
&& has_none(has_b | has_o | has_p | has_t | has_x | has_z | has_colon)
|
||||
&& (has_none(has_plus | has_minus) || has_any(begins_sign)))
|
||||
add_trait(has_e);
|
||||
break;
|
||||
|
||||
case U'o':
|
||||
if (char_count == 2_sz && has_any(begins_zero))
|
||||
if (char_count == 2u && has_any(begins_zero))
|
||||
add_trait(has_o);
|
||||
break;
|
||||
|
||||
@ -2486,8 +2486,8 @@ TOML_IMPL_NAMESPACE_START
|
||||
break;
|
||||
|
||||
case U'x':
|
||||
if ((char_count == 2_sz && has_any(begins_zero))
|
||||
|| (char_count == 3_sz && has_any(begins_sign) && chars[1] == U'0'))
|
||||
if ((char_count == 2u && has_any(begins_zero))
|
||||
|| (char_count == 3u && has_any(begins_sign) && chars[1] == U'0'))
|
||||
add_trait(has_x);
|
||||
break;
|
||||
|
||||
@ -2519,7 +2519,7 @@ TOML_IMPL_NAMESPACE_START
|
||||
return_if_error({});
|
||||
|
||||
// force further scanning if this could have been a date-time with a space instead of a T
|
||||
if (char_count == 10_sz && traits == (bdigit_msk | has_minus) && chars[4] == U'-' && chars[7] == U'-'
|
||||
if (char_count == 10u && traits == (bdigit_msk | has_minus) && chars[4] == U'-' && chars[7] == U'-'
|
||||
&& !is_eof() && *cp == U' ')
|
||||
{
|
||||
const auto pre_advance_count = advance_count;
|
||||
@ -2532,7 +2532,7 @@ TOML_IMPL_NAMESPACE_START
|
||||
go_back(advance_count - pre_advance_count);
|
||||
advance_count = pre_advance_count;
|
||||
traits = pre_scan_traits;
|
||||
char_count = 10_sz;
|
||||
char_count = 10u;
|
||||
};
|
||||
|
||||
advance_and_return_if_error({});
|
||||
@ -2550,19 +2550,19 @@ TOML_IMPL_NAMESPACE_START
|
||||
scan();
|
||||
return_if_error({});
|
||||
|
||||
if (char_count == 12_sz)
|
||||
if (char_count == 12u)
|
||||
backpedal();
|
||||
}
|
||||
}
|
||||
|
||||
// set the reader back to where we started
|
||||
go_back(advance_count);
|
||||
if (char_count < utf8_buffered_reader::max_history_length - 1_sz)
|
||||
if (char_count < utf8_buffered_reader::max_history_length - 1u)
|
||||
chars[char_count] = U'\0';
|
||||
|
||||
// if after scanning ahead we still only have one value character,
|
||||
// the only valid value type is an integer.
|
||||
if (char_count == 1_sz)
|
||||
if (char_count == 1u)
|
||||
{
|
||||
if (has_any(begins_zero | begins_digit))
|
||||
{
|
||||
@ -2579,7 +2579,7 @@ TOML_IMPL_NAMESPACE_START
|
||||
|
||||
// now things that can be identified from two or more characters
|
||||
return_if_error({});
|
||||
assert_or_assume(char_count >= 2_sz);
|
||||
assert_or_assume(char_count >= 2u);
|
||||
|
||||
// do some 'fuzzy matching' where there's no ambiguity, since that allows the specific
|
||||
// typed parse functions to take over and show better diagnostics if there's an issue
|
||||
@ -2605,7 +2605,7 @@ TOML_IMPL_NAMESPACE_START
|
||||
else if (has_any(begins_sign))
|
||||
{
|
||||
// single-digit signed integers
|
||||
if (char_count == 2_sz && has_any(has_digits))
|
||||
if (char_count == 2u && has_any(has_digits))
|
||||
{
|
||||
val = new value{ static_cast<int64_t>(chars[1] - U'0') * (chars[0] == U'-' ? -1LL : 1LL) };
|
||||
advance(); // skip the sign
|
||||
@ -2911,7 +2911,7 @@ TOML_IMPL_NAMESPACE_START
|
||||
// get the key
|
||||
start_recording();
|
||||
auto key = parse_key();
|
||||
stop_recording(1_sz);
|
||||
stop_recording(1u);
|
||||
|
||||
// skip past any whitespace that followed the key
|
||||
consume_leading_whitespace();
|
||||
@ -2977,7 +2977,7 @@ TOML_IMPL_NAMESPACE_START
|
||||
// get the actual key
|
||||
start_recording();
|
||||
key = parse_key();
|
||||
stop_recording(1_sz);
|
||||
stop_recording(1u);
|
||||
return_if_error({});
|
||||
|
||||
// skip past any whitespace that followed the key
|
||||
@ -3006,7 +3006,7 @@ TOML_IMPL_NAMESPACE_START
|
||||
|
||||
// check if each parent is a table/table array, or can be created implicitly as a table.
|
||||
auto parent = &root;
|
||||
for (size_t i = 0; i < key.segments.size() - 1_sz; i++)
|
||||
for (size_t i = 0; i < key.segments.size() - 1u; i++)
|
||||
{
|
||||
auto child = parent->get(key.segments[i]);
|
||||
if (!child)
|
||||
@ -3134,13 +3134,13 @@ TOML_IMPL_NAMESPACE_START
|
||||
auto kvp = parse_key_value_pair();
|
||||
return_if_error();
|
||||
|
||||
TOML_ASSERT(kvp.key.segments.size() >= 1_sz);
|
||||
TOML_ASSERT(kvp.key.segments.size() >= 1u);
|
||||
|
||||
// if it's a dotted kvp we need to spawn the sub-tables if necessary,
|
||||
// and set the target table to the second-to-last one in the chain
|
||||
if (kvp.key.segments.size() > 1_sz)
|
||||
if (kvp.key.segments.size() > 1u)
|
||||
{
|
||||
for (size_t i = 0; i < kvp.key.segments.size() - 1_sz; i++)
|
||||
for (size_t i = 0; i < kvp.key.segments.size() - 1u; i++)
|
||||
{
|
||||
auto child = tab->get(kvp.key.segments[i]);
|
||||
if (!child)
|
||||
@ -3525,7 +3525,7 @@ TOML_ANON_NAMESPACE_START
|
||||
|
||||
// open file with a custom-sized stack buffer
|
||||
std::ifstream file;
|
||||
char file_buffer[sizeof(void*) * 1024_sz];
|
||||
char file_buffer[sizeof(void*) * 1024u];
|
||||
file.rdbuf()->pubsetbuf(file_buffer, sizeof(file_buffer));
|
||||
file.open(file_path_str, std::ifstream::in | std::ifstream::binary | std::ifstream::ate);
|
||||
if (!file.is_open())
|
||||
|
@ -531,13 +531,6 @@
|
||||
#define TOML_UNREACHABLE TOML_ASSERT(false)
|
||||
#endif
|
||||
|
||||
#if defined(__cpp_consteval) && __cpp_consteval >= 201811 && !defined(_MSC_VER)
|
||||
// https://developercommunity.visualstudio.com/t/Erroneous-C7595-error-with-consteval-in/1404234
|
||||
#define TOML_CONSTEVAL consteval
|
||||
#else
|
||||
#define TOML_CONSTEVAL constexpr
|
||||
#endif
|
||||
|
||||
#ifdef __has_cpp_attribute
|
||||
#define TOML_HAS_ATTR(...) __has_cpp_attribute(__VA_ARGS__)
|
||||
#else
|
||||
@ -758,7 +751,9 @@
|
||||
#define TOML_EXTERNAL_LINKAGE inline
|
||||
#define TOML_INTERNAL_LINKAGE inline
|
||||
#else
|
||||
#define TOML_ANON_NAMESPACE_START static_assert(TOML_IMPLEMENTATION); using namespace toml; namespace
|
||||
#define TOML_ANON_NAMESPACE_START static_assert(TOML_IMPLEMENTATION); \
|
||||
using namespace toml; \
|
||||
namespace
|
||||
#define TOML_ANON_NAMESPACE_END static_assert(true)
|
||||
#define TOML_ANON_NAMESPACE
|
||||
#define TOML_EXTERNAL_LINKAGE
|
||||
|
@ -314,26 +314,26 @@ TOML_IMPL_NAMESPACE_START
|
||||
TOML_EXTERNAL_LINKAGE
|
||||
void print_to_stream(std::ostream & stream, const toml::date& val)
|
||||
{
|
||||
print_integer_leftpad_zeros(stream, val.year, 4_sz);
|
||||
print_integer_leftpad_zeros(stream, val.year, 4u);
|
||||
stream.put('-');
|
||||
print_integer_leftpad_zeros(stream, val.month, 2_sz);
|
||||
print_integer_leftpad_zeros(stream, val.month, 2u);
|
||||
stream.put('-');
|
||||
print_integer_leftpad_zeros(stream, val.day, 2_sz);
|
||||
print_integer_leftpad_zeros(stream, val.day, 2u);
|
||||
}
|
||||
|
||||
TOML_EXTERNAL_LINKAGE
|
||||
void print_to_stream(std::ostream & stream, const toml::time& val)
|
||||
{
|
||||
print_integer_leftpad_zeros(stream, val.hour, 2_sz);
|
||||
print_integer_leftpad_zeros(stream, val.hour, 2u);
|
||||
stream.put(':');
|
||||
print_integer_leftpad_zeros(stream, val.minute, 2_sz);
|
||||
print_integer_leftpad_zeros(stream, val.minute, 2u);
|
||||
stream.put(':');
|
||||
print_integer_leftpad_zeros(stream, val.second, 2_sz);
|
||||
print_integer_leftpad_zeros(stream, val.second, 2u);
|
||||
if (val.nanosecond && val.nanosecond <= 999999999u)
|
||||
{
|
||||
stream.put('.');
|
||||
auto ns = val.nanosecond;
|
||||
size_t digits = 9_sz;
|
||||
size_t digits = 9u;
|
||||
while (ns % 10u == 0u)
|
||||
{
|
||||
ns /= 10u;
|
||||
@ -363,13 +363,13 @@ TOML_IMPL_NAMESPACE_START
|
||||
const auto hours = mins / 60;
|
||||
if (hours)
|
||||
{
|
||||
print_integer_leftpad_zeros(stream, static_cast<unsigned int>(hours), 2_sz);
|
||||
print_integer_leftpad_zeros(stream, static_cast<unsigned int>(hours), 2u);
|
||||
mins -= hours * 60;
|
||||
}
|
||||
else
|
||||
print_to_stream(stream, "00"sv);
|
||||
stream.put(':');
|
||||
print_integer_leftpad_zeros(stream, static_cast<unsigned int>(mins), 2_sz);
|
||||
print_integer_leftpad_zeros(stream, static_cast<unsigned int>(mins), 2u);
|
||||
}
|
||||
|
||||
TOML_EXTERNAL_LINKAGE
|
||||
|
@ -377,12 +377,15 @@ TOML_NAMESPACE_START
|
||||
}
|
||||
|
||||
TOML_NODISCARD
|
||||
TOML_API
|
||||
bool is_homogeneous(node_type ntype) const noexcept final;
|
||||
|
||||
TOML_NODISCARD
|
||||
TOML_API
|
||||
bool is_homogeneous(node_type ntype, node*& first_nonmatch) noexcept final;
|
||||
|
||||
TOML_NODISCARD
|
||||
TOML_API
|
||||
bool is_homogeneous(node_type ntype, const node*& first_nonmatch) const noexcept final;
|
||||
|
||||
template <typename ElemType = void>
|
||||
|
@ -78,7 +78,6 @@ TOML_POP_WARNINGS;
|
||||
#undef TOML_COMPILER_EXCEPTIONS
|
||||
#undef TOML_CONCAT
|
||||
#undef TOML_CONCAT_1
|
||||
#undef TOML_CONSTEVAL
|
||||
#undef TOML_CONSTRAINED_TEMPLATE
|
||||
#undef TOML_CPP
|
||||
#undef TOML_DISABLE_ARITHMETIC_WARNINGS
|
||||
|
@ -1,38 +0,0 @@
|
||||
// This file is a part of toml++ and is subject to the the terms of the MIT license.
|
||||
// Copyright (c) Mark Gillard <mark.gillard@outlook.com.au>
|
||||
// See https://github.com/marzer/tomlplusplus/blob/master/LICENSE for the full license text.
|
||||
// SPDX-License-Identifier: MIT
|
||||
|
||||
#pragma once
|
||||
#include "settings.h"
|
||||
|
||||
#ifdef __clang__
|
||||
#pragma clang diagnostic push
|
||||
#pragma clang diagnostic ignored "-Weverything"
|
||||
#elif defined (__GNUC__)
|
||||
#pragma GCC diagnostic push
|
||||
#pragma GCC diagnostic ignored "-Wall"
|
||||
#pragma GCC diagnostic ignored "-Wextra"
|
||||
#pragma GCC diagnostic ignored "-Wpadded"
|
||||
#pragma GCC diagnostic ignored "-Wfloat-equal"
|
||||
#elif defined(_MSC_VER)
|
||||
#pragma warning(push, 0)
|
||||
#pragma warning(disable : 4365)
|
||||
#pragma warning(disable : 4868)
|
||||
#pragma warning(disable : 5105)
|
||||
#endif
|
||||
|
||||
#if __has_include(<Catch2/single_include/catch2/catch.hpp>)
|
||||
#include <Catch2/single_include/catch2/catch.hpp>
|
||||
#else
|
||||
#error Catch2 is missing! You probably need to fetch submodules ("git submodule update --init --depth 1 external/Catch2")
|
||||
#endif
|
||||
|
||||
#ifdef __clang__
|
||||
#pragma clang diagnostic pop
|
||||
#elif defined(__GNUC__)
|
||||
#pragma GCC diagnostic pop
|
||||
#elif defined(_MSC_VER)
|
||||
#pragma warning(pop)
|
||||
#endif
|
||||
|
@ -4,6 +4,7 @@
|
||||
// SPDX-License-Identifier: MIT
|
||||
//-----
|
||||
// this file was generated by generate_conformance_tests.py - do not modify it directly
|
||||
// clang-format off
|
||||
|
||||
#include "tests.h"
|
||||
using namespace toml::impl;
|
||||
|
@ -4,6 +4,7 @@
|
||||
// SPDX-License-Identifier: MIT
|
||||
//-----
|
||||
// this file was generated by generate_conformance_tests.py - do not modify it directly
|
||||
// clang-format off
|
||||
|
||||
#include "tests.h"
|
||||
using namespace toml::impl;
|
||||
|
@ -4,6 +4,7 @@
|
||||
// SPDX-License-Identifier: MIT
|
||||
//-----
|
||||
// this file was generated by generate_conformance_tests.py - do not modify it directly
|
||||
// clang-format off
|
||||
|
||||
#include "tests.h"
|
||||
using namespace toml::impl;
|
||||
|
@ -4,6 +4,7 @@
|
||||
// SPDX-License-Identifier: MIT
|
||||
//-----
|
||||
// this file was generated by generate_conformance_tests.py - do not modify it directly
|
||||
// clang-format off
|
||||
|
||||
#include "tests.h"
|
||||
using namespace toml::impl;
|
||||
@ -1531,4 +1532,3 @@ Location SF.)"sv },
|
||||
|
||||
#endif // UNICODE_LITERALS_OK
|
||||
}
|
||||
|
||||
|
@ -5,17 +5,17 @@
|
||||
|
||||
#include "settings.h"
|
||||
#if !TOML_HEADER_ONLY
|
||||
#define TOML_IMPLEMENTATION
|
||||
#define TOML_IMPLEMENTATION
|
||||
#endif
|
||||
|
||||
#if USE_TARTANLLAMA_OPTIONAL
|
||||
#include "tloptional.h"
|
||||
#include "lib_tloptional.h"
|
||||
#endif
|
||||
|
||||
#if USE_SINGLE_HEADER
|
||||
#include "../toml.hpp"
|
||||
#include "../toml.hpp"
|
||||
#else
|
||||
#include "../include/toml++/toml.h"
|
||||
#include "../include/toml++/toml.h"
|
||||
#endif
|
||||
|
||||
namespace toml
|
||||
@ -23,7 +23,7 @@ namespace toml
|
||||
using std::declval;
|
||||
using std::is_same_v;
|
||||
|
||||
#define CHECK_NODE_TYPE_MAPPING(T, expected) \
|
||||
#define CHECK_NODE_TYPE_MAPPING(T, expected) \
|
||||
static_assert(impl::node_type_of<T> == expected); \
|
||||
static_assert(impl::node_type_of<T&> == expected); \
|
||||
static_assert(impl::node_type_of<T&&> == expected); \
|
||||
@ -47,8 +47,7 @@ namespace toml
|
||||
CHECK_NODE_TYPE_MAPPING(toml::array, node_type::array);
|
||||
CHECK_NODE_TYPE_MAPPING(toml::table, node_type::table);
|
||||
|
||||
|
||||
#define CHECK_CAN_REPRESENT_NATIVE(T, expected) \
|
||||
#define CHECK_CAN_REPRESENT_NATIVE(T, expected) \
|
||||
static_assert((impl::value_traits<T>::is_native || impl::value_traits<T>::can_represent_native) == expected)
|
||||
|
||||
CHECK_CAN_REPRESENT_NATIVE(time, true);
|
||||
@ -65,216 +64,216 @@ namespace toml
|
||||
CHECK_CAN_REPRESENT_NATIVE(uint64_t, false);
|
||||
CHECK_CAN_REPRESENT_NATIVE(float, false);
|
||||
CHECK_CAN_REPRESENT_NATIVE(double, true);
|
||||
#ifdef TOML_INT128
|
||||
#ifdef TOML_INT128
|
||||
CHECK_CAN_REPRESENT_NATIVE(TOML_INT128, true);
|
||||
CHECK_CAN_REPRESENT_NATIVE(TOML_UINT128, false);
|
||||
#endif
|
||||
#ifdef TOML_FP16
|
||||
#endif
|
||||
#ifdef TOML_FP16
|
||||
CHECK_CAN_REPRESENT_NATIVE(TOML_FP16, false);
|
||||
#endif
|
||||
#ifdef TOML_FLOAT16
|
||||
#endif
|
||||
#ifdef TOML_FLOAT16
|
||||
CHECK_CAN_REPRESENT_NATIVE(TOML_FLOAT16, false);
|
||||
#endif
|
||||
#ifdef TOML_FLOAT128
|
||||
#endif
|
||||
#ifdef TOML_FLOAT128
|
||||
CHECK_CAN_REPRESENT_NATIVE(TOML_FLOAT128, true);
|
||||
#endif
|
||||
#endif
|
||||
|
||||
CHECK_CAN_REPRESENT_NATIVE(char*, false);
|
||||
CHECK_CAN_REPRESENT_NATIVE(char*const, false);
|
||||
CHECK_CAN_REPRESENT_NATIVE(char* const, false);
|
||||
CHECK_CAN_REPRESENT_NATIVE(char[2], false);
|
||||
CHECK_CAN_REPRESENT_NATIVE(const char[2], false);
|
||||
CHECK_CAN_REPRESENT_NATIVE(char(&)[2], false);
|
||||
CHECK_CAN_REPRESENT_NATIVE(const char(&)[2], false);
|
||||
CHECK_CAN_REPRESENT_NATIVE(char (&)[2], false);
|
||||
CHECK_CAN_REPRESENT_NATIVE(const char (&)[2], false);
|
||||
CHECK_CAN_REPRESENT_NATIVE(char(&&)[2], false);
|
||||
CHECK_CAN_REPRESENT_NATIVE(const char(&&)[2], false);
|
||||
CHECK_CAN_REPRESENT_NATIVE(const char*, true);
|
||||
CHECK_CAN_REPRESENT_NATIVE(const char*const, true);
|
||||
CHECK_CAN_REPRESENT_NATIVE(const char* const, true);
|
||||
CHECK_CAN_REPRESENT_NATIVE(std::string, true);
|
||||
CHECK_CAN_REPRESENT_NATIVE(std::string_view, true);
|
||||
#if TOML_HAS_CHAR8
|
||||
#if TOML_HAS_CHAR8
|
||||
CHECK_CAN_REPRESENT_NATIVE(char8_t*, false);
|
||||
CHECK_CAN_REPRESENT_NATIVE(char8_t*const, false);
|
||||
CHECK_CAN_REPRESENT_NATIVE(char8_t* const, false);
|
||||
CHECK_CAN_REPRESENT_NATIVE(char8_t[2], false);
|
||||
CHECK_CAN_REPRESENT_NATIVE(const char8_t[2], false);
|
||||
CHECK_CAN_REPRESENT_NATIVE(char8_t(&)[2], false);
|
||||
CHECK_CAN_REPRESENT_NATIVE(const char8_t(&)[2], false);
|
||||
CHECK_CAN_REPRESENT_NATIVE(char8_t (&)[2], false);
|
||||
CHECK_CAN_REPRESENT_NATIVE(const char8_t (&)[2], false);
|
||||
CHECK_CAN_REPRESENT_NATIVE(char(&&)[2], false);
|
||||
CHECK_CAN_REPRESENT_NATIVE(const char8_t(&&)[2], false);
|
||||
CHECK_CAN_REPRESENT_NATIVE(const char8_t*, true);
|
||||
CHECK_CAN_REPRESENT_NATIVE(const char8_t*const, true);
|
||||
CHECK_CAN_REPRESENT_NATIVE(const char8_t* const, true);
|
||||
CHECK_CAN_REPRESENT_NATIVE(std::u8string, true);
|
||||
CHECK_CAN_REPRESENT_NATIVE(std::u8string_view, true);
|
||||
#endif
|
||||
#endif
|
||||
CHECK_CAN_REPRESENT_NATIVE(wchar_t*, false);
|
||||
CHECK_CAN_REPRESENT_NATIVE(wchar_t*const, false);
|
||||
CHECK_CAN_REPRESENT_NATIVE(wchar_t* const, false);
|
||||
CHECK_CAN_REPRESENT_NATIVE(wchar_t[2], false);
|
||||
CHECK_CAN_REPRESENT_NATIVE(const wchar_t[2], false);
|
||||
CHECK_CAN_REPRESENT_NATIVE(wchar_t(&)[2], false);
|
||||
CHECK_CAN_REPRESENT_NATIVE(const wchar_t(&)[2], false);
|
||||
CHECK_CAN_REPRESENT_NATIVE(wchar_t (&)[2], false);
|
||||
CHECK_CAN_REPRESENT_NATIVE(const wchar_t (&)[2], false);
|
||||
CHECK_CAN_REPRESENT_NATIVE(wchar_t(&&)[2], false);
|
||||
CHECK_CAN_REPRESENT_NATIVE(const wchar_t(&&)[2], false);
|
||||
CHECK_CAN_REPRESENT_NATIVE(const wchar_t*, false);
|
||||
CHECK_CAN_REPRESENT_NATIVE(const wchar_t*const, false);
|
||||
CHECK_CAN_REPRESENT_NATIVE(const wchar_t* const, false);
|
||||
CHECK_CAN_REPRESENT_NATIVE(std::wstring, !!TOML_WINDOWS_COMPAT);
|
||||
CHECK_CAN_REPRESENT_NATIVE(std::wstring_view, false);
|
||||
|
||||
#define CHECK_VALUE_EXACT(T, expected) \
|
||||
#define CHECK_VALUE_EXACT(T, expected) \
|
||||
static_assert(is_same_v<decltype(declval<node>().value_exact<T>()), optional<expected>>); \
|
||||
static_assert(is_same_v<decltype(declval<node_view<node>>().value_exact<T>()), optional<expected>>); \
|
||||
static_assert(is_same_v<decltype(declval<node_view<const node>>().value_exact<T>()), optional<expected>>)
|
||||
|
||||
#define CHECK_VALUE_OR(T, expected) \
|
||||
#define CHECK_VALUE_OR(T, expected) \
|
||||
static_assert(is_same_v<decltype(declval<node>().value_or(declval<T>())), expected>); \
|
||||
static_assert(is_same_v<decltype(declval<node_view<node>>().value_or(declval<T>())), expected>); \
|
||||
static_assert(is_same_v<decltype(declval<node_view<const node>>().value_or(declval<T>())), expected>)
|
||||
|
||||
CHECK_VALUE_EXACT( time, time);
|
||||
CHECK_VALUE_EXACT( date, date);
|
||||
CHECK_VALUE_EXACT( date_time, date_time);
|
||||
CHECK_VALUE_EXACT( bool, bool);
|
||||
CHECK_VALUE_EXACT( double, double);
|
||||
CHECK_VALUE_EXACT( int64_t, int64_t);
|
||||
CHECK_VALUE_EXACT( const char*, const char*);
|
||||
CHECK_VALUE_EXACT( std::string_view, std::string_view);
|
||||
CHECK_VALUE_EXACT( std::string, std::string);
|
||||
#if TOML_HAS_CHAR8
|
||||
CHECK_VALUE_EXACT( const char8_t*, const char8_t*);
|
||||
CHECK_VALUE_EXACT( std::u8string_view, std::u8string_view);
|
||||
CHECK_VALUE_EXACT( std::u8string, std::u8string);
|
||||
#endif
|
||||
CHECK_VALUE_EXACT(time, time);
|
||||
CHECK_VALUE_EXACT(date, date);
|
||||
CHECK_VALUE_EXACT(date_time, date_time);
|
||||
CHECK_VALUE_EXACT(bool, bool);
|
||||
CHECK_VALUE_EXACT(double, double);
|
||||
CHECK_VALUE_EXACT(int64_t, int64_t);
|
||||
CHECK_VALUE_EXACT(const char*, const char*);
|
||||
CHECK_VALUE_EXACT(std::string_view, std::string_view);
|
||||
CHECK_VALUE_EXACT(std::string, std::string);
|
||||
#if TOML_HAS_CHAR8
|
||||
CHECK_VALUE_EXACT(const char8_t*, const char8_t*);
|
||||
CHECK_VALUE_EXACT(std::u8string_view, std::u8string_view);
|
||||
CHECK_VALUE_EXACT(std::u8string, std::u8string);
|
||||
#endif
|
||||
|
||||
CHECK_VALUE_OR( time, time);
|
||||
CHECK_VALUE_OR( time&, time);
|
||||
CHECK_VALUE_OR( time&&, time);
|
||||
CHECK_VALUE_OR( time const, time);
|
||||
CHECK_VALUE_OR( date, date);
|
||||
CHECK_VALUE_OR( date&, date);
|
||||
CHECK_VALUE_OR( date&&, date);
|
||||
CHECK_VALUE_OR( date const, date);
|
||||
CHECK_VALUE_OR( date_time, date_time);
|
||||
CHECK_VALUE_OR( date_time&, date_time);
|
||||
CHECK_VALUE_OR( date_time&&, date_time);
|
||||
CHECK_VALUE_OR( date_time const, date_time);
|
||||
CHECK_VALUE_OR( bool, bool);
|
||||
CHECK_VALUE_OR( bool&, bool);
|
||||
CHECK_VALUE_OR( bool&&, bool);
|
||||
CHECK_VALUE_OR( bool const, bool);
|
||||
CHECK_VALUE_OR( int32_t, int32_t);
|
||||
CHECK_VALUE_OR( int32_t&, int32_t);
|
||||
CHECK_VALUE_OR( int32_t&&, int32_t);
|
||||
CHECK_VALUE_OR( int32_t const, int32_t);
|
||||
CHECK_VALUE_OR( int64_t, int64_t);
|
||||
CHECK_VALUE_OR( int64_t&, int64_t);
|
||||
CHECK_VALUE_OR( int64_t&&, int64_t);
|
||||
CHECK_VALUE_OR( int64_t const, int64_t);
|
||||
#ifdef TOML_INT128
|
||||
CHECK_VALUE_OR( TOML_INT128, TOML_INT128);
|
||||
CHECK_VALUE_OR( TOML_INT128&, TOML_INT128);
|
||||
CHECK_VALUE_OR( TOML_INT128&&, TOML_INT128);
|
||||
CHECK_VALUE_OR( TOML_INT128 const, TOML_INT128);
|
||||
CHECK_VALUE_OR( TOML_UINT128, TOML_UINT128);
|
||||
CHECK_VALUE_OR( TOML_UINT128&, TOML_UINT128);
|
||||
CHECK_VALUE_OR( TOML_UINT128&&, TOML_UINT128);
|
||||
CHECK_VALUE_OR( TOML_UINT128 const, TOML_UINT128);
|
||||
#endif
|
||||
CHECK_VALUE_OR( float, float);
|
||||
CHECK_VALUE_OR( float&, float);
|
||||
CHECK_VALUE_OR( float&&, float);
|
||||
CHECK_VALUE_OR( float const, float);
|
||||
CHECK_VALUE_OR( double, double);
|
||||
CHECK_VALUE_OR( double&, double);
|
||||
CHECK_VALUE_OR( double&&, double);
|
||||
CHECK_VALUE_OR( double const, double);
|
||||
#ifdef TOML_FLOAT128
|
||||
CHECK_VALUE_OR( TOML_FLOAT128, TOML_FLOAT128);
|
||||
CHECK_VALUE_OR( TOML_FLOAT128&, TOML_FLOAT128);
|
||||
CHECK_VALUE_OR( TOML_FLOAT128&&, TOML_FLOAT128);
|
||||
CHECK_VALUE_OR( TOML_FLOAT128 const, TOML_FLOAT128);
|
||||
#endif
|
||||
CHECK_VALUE_OR( char*, const char*);
|
||||
CHECK_VALUE_OR( char*&, const char*);
|
||||
CHECK_VALUE_OR( char*&&, const char*);
|
||||
CHECK_VALUE_OR( char*const, const char*);
|
||||
CHECK_VALUE_OR( char[2], const char*);
|
||||
CHECK_VALUE_OR( char(&)[2], const char*);
|
||||
CHECK_VALUE_OR( char(&&)[2], const char*);
|
||||
CHECK_VALUE_OR( const char*, const char*);
|
||||
CHECK_VALUE_OR( const char*&, const char*);
|
||||
CHECK_VALUE_OR( const char*&&, const char*);
|
||||
CHECK_VALUE_OR( const char*const, const char*);
|
||||
CHECK_VALUE_OR( const char[2], const char*);
|
||||
CHECK_VALUE_OR( const char(&)[2], const char*);
|
||||
CHECK_VALUE_OR( const char(&&)[2], const char*);
|
||||
CHECK_VALUE_OR( std::string_view, std::string_view);
|
||||
CHECK_VALUE_OR( std::string_view&, std::string_view);
|
||||
CHECK_VALUE_OR( std::string_view&&, std::string_view);
|
||||
CHECK_VALUE_OR( const std::string_view, std::string_view);
|
||||
CHECK_VALUE_OR( const std::string_view&, std::string_view);
|
||||
CHECK_VALUE_OR( const std::string_view&&, std::string_view);
|
||||
CHECK_VALUE_OR( std::string, std::string);
|
||||
CHECK_VALUE_OR( std::string&, std::string);
|
||||
CHECK_VALUE_OR( std::string&&, std::string);
|
||||
CHECK_VALUE_OR( const std::string, std::string);
|
||||
CHECK_VALUE_OR( const std::string&, std::string);
|
||||
CHECK_VALUE_OR( const std::string&&, std::string);
|
||||
#if TOML_HAS_CHAR8
|
||||
CHECK_VALUE_OR( char8_t*, const char8_t*);
|
||||
CHECK_VALUE_OR( char8_t*&, const char8_t*);
|
||||
CHECK_VALUE_OR( char8_t*&&, const char8_t*);
|
||||
CHECK_VALUE_OR( char8_t*const, const char8_t*);
|
||||
CHECK_VALUE_OR( char8_t[2], const char8_t*);
|
||||
CHECK_VALUE_OR( char8_t(&)[2], const char8_t*);
|
||||
CHECK_VALUE_OR( char8_t(&&)[2], const char8_t*);
|
||||
CHECK_VALUE_OR( const char8_t*, const char8_t*);
|
||||
CHECK_VALUE_OR( const char8_t*&, const char8_t*);
|
||||
CHECK_VALUE_OR( const char8_t*&&, const char8_t*);
|
||||
CHECK_VALUE_OR( const char8_t*const, const char8_t*);
|
||||
CHECK_VALUE_OR( const char8_t[2], const char8_t*);
|
||||
CHECK_VALUE_OR( const char8_t(&)[2], const char8_t*);
|
||||
CHECK_VALUE_OR( const char8_t(&&)[2], const char8_t*);
|
||||
CHECK_VALUE_OR( std::u8string_view, std::u8string_view);
|
||||
CHECK_VALUE_OR( std::u8string_view&, std::u8string_view);
|
||||
CHECK_VALUE_OR( std::u8string_view&&, std::u8string_view);
|
||||
CHECK_VALUE_OR( const std::u8string_view, std::u8string_view);
|
||||
CHECK_VALUE_OR( const std::u8string_view&, std::u8string_view);
|
||||
CHECK_VALUE_OR( const std::u8string_view&&, std::u8string_view);
|
||||
CHECK_VALUE_OR( std::u8string, std::u8string);
|
||||
CHECK_VALUE_OR( std::u8string&, std::u8string);
|
||||
CHECK_VALUE_OR( std::u8string&&, std::u8string);
|
||||
CHECK_VALUE_OR( const std::u8string, std::u8string);
|
||||
CHECK_VALUE_OR( const std::u8string&, std::u8string);
|
||||
CHECK_VALUE_OR( const std::u8string&&, std::u8string);
|
||||
#endif
|
||||
#if TOML_WINDOWS_COMPAT
|
||||
CHECK_VALUE_OR( wchar_t*, std::wstring);
|
||||
CHECK_VALUE_OR( wchar_t*&, std::wstring);
|
||||
CHECK_VALUE_OR( wchar_t*&&, std::wstring);
|
||||
CHECK_VALUE_OR( wchar_t*const, std::wstring);
|
||||
CHECK_VALUE_OR( wchar_t[2], std::wstring);
|
||||
CHECK_VALUE_OR( wchar_t(&)[2], std::wstring);
|
||||
CHECK_VALUE_OR( wchar_t(&&)[2], std::wstring);
|
||||
CHECK_VALUE_OR( const wchar_t*, std::wstring);
|
||||
CHECK_VALUE_OR( const wchar_t*&, std::wstring);
|
||||
CHECK_VALUE_OR( const wchar_t*&&, std::wstring);
|
||||
CHECK_VALUE_OR( const wchar_t*const, std::wstring);
|
||||
CHECK_VALUE_OR( const wchar_t[2], std::wstring);
|
||||
CHECK_VALUE_OR( const wchar_t(&)[2], std::wstring);
|
||||
CHECK_VALUE_OR( const wchar_t(&&)[2], std::wstring);
|
||||
CHECK_VALUE_OR( std::wstring_view, std::wstring);
|
||||
CHECK_VALUE_OR( std::wstring_view&, std::wstring);
|
||||
CHECK_VALUE_OR( std::wstring_view&&, std::wstring);
|
||||
CHECK_VALUE_OR( const std::wstring_view, std::wstring);
|
||||
CHECK_VALUE_OR( const std::wstring_view&, std::wstring);
|
||||
CHECK_VALUE_OR( const std::wstring_view&&, std::wstring);
|
||||
CHECK_VALUE_OR( std::wstring, std::wstring);
|
||||
CHECK_VALUE_OR( std::wstring&, std::wstring);
|
||||
CHECK_VALUE_OR( std::wstring&&, std::wstring);
|
||||
CHECK_VALUE_OR( const std::wstring, std::wstring);
|
||||
CHECK_VALUE_OR( const std::wstring&, std::wstring);
|
||||
CHECK_VALUE_OR( const std::wstring&&, std::wstring);
|
||||
#endif
|
||||
CHECK_VALUE_OR(time, time);
|
||||
CHECK_VALUE_OR(time&, time);
|
||||
CHECK_VALUE_OR(time&&, time);
|
||||
CHECK_VALUE_OR(time const, time);
|
||||
CHECK_VALUE_OR(date, date);
|
||||
CHECK_VALUE_OR(date&, date);
|
||||
CHECK_VALUE_OR(date&&, date);
|
||||
CHECK_VALUE_OR(date const, date);
|
||||
CHECK_VALUE_OR(date_time, date_time);
|
||||
CHECK_VALUE_OR(date_time&, date_time);
|
||||
CHECK_VALUE_OR(date_time&&, date_time);
|
||||
CHECK_VALUE_OR(date_time const, date_time);
|
||||
CHECK_VALUE_OR(bool, bool);
|
||||
CHECK_VALUE_OR(bool&, bool);
|
||||
CHECK_VALUE_OR(bool&&, bool);
|
||||
CHECK_VALUE_OR(bool const, bool);
|
||||
CHECK_VALUE_OR(int32_t, int32_t);
|
||||
CHECK_VALUE_OR(int32_t&, int32_t);
|
||||
CHECK_VALUE_OR(int32_t&&, int32_t);
|
||||
CHECK_VALUE_OR(int32_t const, int32_t);
|
||||
CHECK_VALUE_OR(int64_t, int64_t);
|
||||
CHECK_VALUE_OR(int64_t&, int64_t);
|
||||
CHECK_VALUE_OR(int64_t&&, int64_t);
|
||||
CHECK_VALUE_OR(int64_t const, int64_t);
|
||||
#ifdef TOML_INT128
|
||||
CHECK_VALUE_OR(TOML_INT128, TOML_INT128);
|
||||
CHECK_VALUE_OR(TOML_INT128&, TOML_INT128);
|
||||
CHECK_VALUE_OR(TOML_INT128&&, TOML_INT128);
|
||||
CHECK_VALUE_OR(TOML_INT128 const, TOML_INT128);
|
||||
CHECK_VALUE_OR(TOML_UINT128, TOML_UINT128);
|
||||
CHECK_VALUE_OR(TOML_UINT128&, TOML_UINT128);
|
||||
CHECK_VALUE_OR(TOML_UINT128&&, TOML_UINT128);
|
||||
CHECK_VALUE_OR(TOML_UINT128 const, TOML_UINT128);
|
||||
#endif
|
||||
CHECK_VALUE_OR(float, float);
|
||||
CHECK_VALUE_OR(float&, float);
|
||||
CHECK_VALUE_OR(float&&, float);
|
||||
CHECK_VALUE_OR(float const, float);
|
||||
CHECK_VALUE_OR(double, double);
|
||||
CHECK_VALUE_OR(double&, double);
|
||||
CHECK_VALUE_OR(double&&, double);
|
||||
CHECK_VALUE_OR(double const, double);
|
||||
#ifdef TOML_FLOAT128
|
||||
CHECK_VALUE_OR(TOML_FLOAT128, TOML_FLOAT128);
|
||||
CHECK_VALUE_OR(TOML_FLOAT128&, TOML_FLOAT128);
|
||||
CHECK_VALUE_OR(TOML_FLOAT128&&, TOML_FLOAT128);
|
||||
CHECK_VALUE_OR(TOML_FLOAT128 const, TOML_FLOAT128);
|
||||
#endif
|
||||
CHECK_VALUE_OR(char*, const char*);
|
||||
CHECK_VALUE_OR(char*&, const char*);
|
||||
CHECK_VALUE_OR(char*&&, const char*);
|
||||
CHECK_VALUE_OR(char* const, const char*);
|
||||
CHECK_VALUE_OR(char[2], const char*);
|
||||
CHECK_VALUE_OR(char (&)[2], const char*);
|
||||
CHECK_VALUE_OR(char(&&)[2], const char*);
|
||||
CHECK_VALUE_OR(const char*, const char*);
|
||||
CHECK_VALUE_OR(const char*&, const char*);
|
||||
CHECK_VALUE_OR(const char*&&, const char*);
|
||||
CHECK_VALUE_OR(const char* const, const char*);
|
||||
CHECK_VALUE_OR(const char[2], const char*);
|
||||
CHECK_VALUE_OR(const char (&)[2], const char*);
|
||||
CHECK_VALUE_OR(const char(&&)[2], const char*);
|
||||
CHECK_VALUE_OR(std::string_view, std::string_view);
|
||||
CHECK_VALUE_OR(std::string_view&, std::string_view);
|
||||
CHECK_VALUE_OR(std::string_view&&, std::string_view);
|
||||
CHECK_VALUE_OR(const std::string_view, std::string_view);
|
||||
CHECK_VALUE_OR(const std::string_view&, std::string_view);
|
||||
CHECK_VALUE_OR(const std::string_view&&, std::string_view);
|
||||
CHECK_VALUE_OR(std::string, std::string);
|
||||
CHECK_VALUE_OR(std::string&, std::string);
|
||||
CHECK_VALUE_OR(std::string&&, std::string);
|
||||
CHECK_VALUE_OR(const std::string, std::string);
|
||||
CHECK_VALUE_OR(const std::string&, std::string);
|
||||
CHECK_VALUE_OR(const std::string&&, std::string);
|
||||
#if TOML_HAS_CHAR8
|
||||
CHECK_VALUE_OR(char8_t*, const char8_t*);
|
||||
CHECK_VALUE_OR(char8_t*&, const char8_t*);
|
||||
CHECK_VALUE_OR(char8_t*&&, const char8_t*);
|
||||
CHECK_VALUE_OR(char8_t* const, const char8_t*);
|
||||
CHECK_VALUE_OR(char8_t[2], const char8_t*);
|
||||
CHECK_VALUE_OR(char8_t (&)[2], const char8_t*);
|
||||
CHECK_VALUE_OR(char8_t(&&)[2], const char8_t*);
|
||||
CHECK_VALUE_OR(const char8_t*, const char8_t*);
|
||||
CHECK_VALUE_OR(const char8_t*&, const char8_t*);
|
||||
CHECK_VALUE_OR(const char8_t*&&, const char8_t*);
|
||||
CHECK_VALUE_OR(const char8_t* const, const char8_t*);
|
||||
CHECK_VALUE_OR(const char8_t[2], const char8_t*);
|
||||
CHECK_VALUE_OR(const char8_t (&)[2], const char8_t*);
|
||||
CHECK_VALUE_OR(const char8_t(&&)[2], const char8_t*);
|
||||
CHECK_VALUE_OR(std::u8string_view, std::u8string_view);
|
||||
CHECK_VALUE_OR(std::u8string_view&, std::u8string_view);
|
||||
CHECK_VALUE_OR(std::u8string_view&&, std::u8string_view);
|
||||
CHECK_VALUE_OR(const std::u8string_view, std::u8string_view);
|
||||
CHECK_VALUE_OR(const std::u8string_view&, std::u8string_view);
|
||||
CHECK_VALUE_OR(const std::u8string_view&&, std::u8string_view);
|
||||
CHECK_VALUE_OR(std::u8string, std::u8string);
|
||||
CHECK_VALUE_OR(std::u8string&, std::u8string);
|
||||
CHECK_VALUE_OR(std::u8string&&, std::u8string);
|
||||
CHECK_VALUE_OR(const std::u8string, std::u8string);
|
||||
CHECK_VALUE_OR(const std::u8string&, std::u8string);
|
||||
CHECK_VALUE_OR(const std::u8string&&, std::u8string);
|
||||
#endif
|
||||
#if TOML_WINDOWS_COMPAT
|
||||
CHECK_VALUE_OR(wchar_t*, std::wstring);
|
||||
CHECK_VALUE_OR(wchar_t*&, std::wstring);
|
||||
CHECK_VALUE_OR(wchar_t*&&, std::wstring);
|
||||
CHECK_VALUE_OR(wchar_t* const, std::wstring);
|
||||
CHECK_VALUE_OR(wchar_t[2], std::wstring);
|
||||
CHECK_VALUE_OR(wchar_t (&)[2], std::wstring);
|
||||
CHECK_VALUE_OR(wchar_t(&&)[2], std::wstring);
|
||||
CHECK_VALUE_OR(const wchar_t*, std::wstring);
|
||||
CHECK_VALUE_OR(const wchar_t*&, std::wstring);
|
||||
CHECK_VALUE_OR(const wchar_t*&&, std::wstring);
|
||||
CHECK_VALUE_OR(const wchar_t* const, std::wstring);
|
||||
CHECK_VALUE_OR(const wchar_t[2], std::wstring);
|
||||
CHECK_VALUE_OR(const wchar_t (&)[2], std::wstring);
|
||||
CHECK_VALUE_OR(const wchar_t(&&)[2], std::wstring);
|
||||
CHECK_VALUE_OR(std::wstring_view, std::wstring);
|
||||
CHECK_VALUE_OR(std::wstring_view&, std::wstring);
|
||||
CHECK_VALUE_OR(std::wstring_view&&, std::wstring);
|
||||
CHECK_VALUE_OR(const std::wstring_view, std::wstring);
|
||||
CHECK_VALUE_OR(const std::wstring_view&, std::wstring);
|
||||
CHECK_VALUE_OR(const std::wstring_view&&, std::wstring);
|
||||
CHECK_VALUE_OR(std::wstring, std::wstring);
|
||||
CHECK_VALUE_OR(std::wstring&, std::wstring);
|
||||
CHECK_VALUE_OR(std::wstring&&, std::wstring);
|
||||
CHECK_VALUE_OR(const std::wstring, std::wstring);
|
||||
CHECK_VALUE_OR(const std::wstring&, std::wstring);
|
||||
CHECK_VALUE_OR(const std::wstring&&, std::wstring);
|
||||
#endif
|
||||
|
||||
#define CHECK_INSERTED_AS(T, expected) \
|
||||
#define CHECK_INSERTED_AS(T, expected) \
|
||||
static_assert(std::is_same_v<expected, toml::inserted_type_of<T>>); \
|
||||
static_assert(std::is_same_v<expected, toml::inserted_type_of<const T>>); \
|
||||
static_assert(std::is_same_v<expected, toml::inserted_type_of<T&>>); \
|
||||
@ -297,12 +296,12 @@ namespace toml
|
||||
CHECK_INSERTED_AS(uint32_t, value<int64_t>);
|
||||
CHECK_INSERTED_AS(float, value<double>);
|
||||
CHECK_INSERTED_AS(double, value<double>);
|
||||
#ifdef TOML_FP16
|
||||
#ifdef TOML_FP16
|
||||
CHECK_INSERTED_AS(TOML_FP16, value<double>);
|
||||
#endif
|
||||
#ifdef TOML_FLOAT16
|
||||
#endif
|
||||
#ifdef TOML_FLOAT16
|
||||
CHECK_INSERTED_AS(TOML_FLOAT16, value<double>);
|
||||
#endif
|
||||
#endif
|
||||
|
||||
static_assert(is_same_v<decltype(declval<node&>().ref<double>()), double&>);
|
||||
static_assert(is_same_v<decltype(declval<node&&>().ref<double>()), double&&>);
|
||||
|
37
tests/lib_catch2.h
Normal file
37
tests/lib_catch2.h
Normal file
@ -0,0 +1,37 @@
|
||||
// This file is a part of toml++ and is subject to the the terms of the MIT license.
|
||||
// Copyright (c) Mark Gillard <mark.gillard@outlook.com.au>
|
||||
// See https://github.com/marzer/tomlplusplus/blob/master/LICENSE for the full license text.
|
||||
// SPDX-License-Identifier: MIT
|
||||
#pragma once
|
||||
|
||||
#include "settings.h"
|
||||
|
||||
#ifdef __clang__
|
||||
#pragma clang diagnostic push
|
||||
#pragma clang diagnostic ignored "-Weverything"
|
||||
#elif defined(__GNUC__)
|
||||
#pragma GCC diagnostic push
|
||||
#pragma GCC diagnostic ignored "-Wall"
|
||||
#pragma GCC diagnostic ignored "-Wextra"
|
||||
#pragma GCC diagnostic ignored "-Wpadded"
|
||||
#pragma GCC diagnostic ignored "-Wfloat-equal"
|
||||
#elif defined(_MSC_VER)
|
||||
#pragma warning(push, 0)
|
||||
#pragma warning(disable : 4365)
|
||||
#pragma warning(disable : 4868)
|
||||
#pragma warning(disable : 5105)
|
||||
#endif
|
||||
|
||||
#if __has_include(<Catch2/single_include/catch2/catch.hpp>)
|
||||
#include <Catch2/single_include/catch2/catch.hpp>
|
||||
#else
|
||||
#error Catch2 is missing! You probably need to fetch submodules ("git submodule update --init --depth 1 external/Catch2")
|
||||
#endif
|
||||
|
||||
#ifdef __clang__
|
||||
#pragma clang diagnostic pop
|
||||
#elif defined(__GNUC__)
|
||||
#pragma GCC diagnostic pop
|
||||
#elif defined(_MSC_VER)
|
||||
#pragma warning(pop)
|
||||
#endif
|
@ -2,13 +2,12 @@
|
||||
// Copyright (c) Mark Gillard <mark.gillard@outlook.com.au>
|
||||
// See https://github.com/marzer/tomlplusplus/blob/master/LICENSE for the full license text.
|
||||
// SPDX-License-Identifier: MIT
|
||||
|
||||
#pragma once
|
||||
|
||||
#ifdef __clang__
|
||||
#pragma clang diagnostic push
|
||||
#pragma clang diagnostic ignored "-Weverything"
|
||||
#elif defined (__GNUC__)
|
||||
#elif defined(__GNUC__)
|
||||
#pragma GCC diagnostic push
|
||||
#pragma GCC diagnostic ignored "-Wall"
|
||||
#pragma GCC diagnostic ignored "-Wextra"
|
||||
@ -17,14 +16,13 @@
|
||||
#endif
|
||||
|
||||
#if __has_include(<tloptional/include/tl/optional.hpp>)
|
||||
#include <tloptional/include/tl/optional.hpp>
|
||||
#include <tloptional/include/tl/optional.hpp>
|
||||
#else
|
||||
#error TartanLlama/optional is missing! You probably need to fetch submodules ("git submodule update --init --depth 1 external/tloptional")
|
||||
#error TartanLlama/optional is missing! You probably need to fetch submodules ("git submodule update --init --depth 1 external/tloptional")
|
||||
#endif
|
||||
|
||||
#ifdef __clang__
|
||||
#pragma clang diagnostic pop
|
||||
#elif defined (__GNUC__)
|
||||
#elif defined(__GNUC__)
|
||||
#pragma GCC diagnostic pop
|
||||
#endif
|
||||
|
@ -4,41 +4,71 @@
|
||||
// SPDX-License-Identifier: MIT
|
||||
|
||||
#define CATCH_CONFIG_RUNNER
|
||||
#include "catch2.h"
|
||||
#include "lib_catch2.h"
|
||||
#include <clocale>
|
||||
|
||||
#if LEAK_TESTS
|
||||
|
||||
#include <iostream>
|
||||
#include <iomanip>
|
||||
#include <atomic>
|
||||
#include "leakproof.h"
|
||||
using namespace std::string_view_literals;
|
||||
|
||||
namespace leakproof
|
||||
{
|
||||
static std::atomic_llong total_created_ = 0LL;
|
||||
static std::atomic_llong tables_ = 0LL;
|
||||
static std::atomic_llong arrays_ = 0LL;
|
||||
static std::atomic_llong values_ = 0LL;
|
||||
void table_created() noexcept { tables_++; total_created_++; }
|
||||
void array_created() noexcept { arrays_++; total_created_++; }
|
||||
void value_created() noexcept { values_++; total_created_++; }
|
||||
void table_destroyed() noexcept { tables_--; }
|
||||
void array_destroyed() noexcept { arrays_--; }
|
||||
void value_destroyed() noexcept { values_--; }
|
||||
|
||||
void table_created() noexcept
|
||||
{
|
||||
tables_++;
|
||||
total_created_++;
|
||||
}
|
||||
|
||||
void array_created() noexcept
|
||||
{
|
||||
arrays_++;
|
||||
total_created_++;
|
||||
}
|
||||
|
||||
void value_created() noexcept
|
||||
{
|
||||
values_++;
|
||||
total_created_++;
|
||||
}
|
||||
|
||||
void table_destroyed() noexcept
|
||||
{
|
||||
tables_--;
|
||||
}
|
||||
|
||||
void array_destroyed() noexcept
|
||||
{
|
||||
arrays_--;
|
||||
}
|
||||
|
||||
void value_destroyed() noexcept
|
||||
{
|
||||
values_--;
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif // LEAK_TESTS
|
||||
|
||||
int main(int argc, char* argv[])
|
||||
{
|
||||
#ifdef _WIN32
|
||||
#ifdef _WIN32
|
||||
SetConsoleOutputCP(65001);
|
||||
#endif
|
||||
#endif
|
||||
std::setlocale(LC_ALL, "");
|
||||
std::locale::global(std::locale(""));
|
||||
if (auto result = Catch::Session().run(argc, argv))
|
||||
return result;
|
||||
|
||||
#if LEAK_TESTS
|
||||
#if LEAK_TESTS
|
||||
constexpr auto handle_leak_result = [](std::string_view name, long long count) noexcept
|
||||
{
|
||||
std::cout << "\n"sv << name << ": "sv << std::right << std::setw(6) << count;
|
||||
@ -56,7 +86,7 @@ int main(int argc, char* argv[])
|
||||
std::cout << "\n(total objects created: "sv << leakproof::total_created_.load() << ")"sv;
|
||||
std::cout << "\n---------------------------------------"sv;
|
||||
return ok ? 0 : -1;
|
||||
#else
|
||||
#else
|
||||
return 0;
|
||||
#endif
|
||||
#endif
|
||||
}
|
||||
|
@ -64,8 +64,7 @@ TEST_CASE("arrays - moving")
|
||||
CHECK(!arr2.source().path);
|
||||
CHECK(arr2.size() == 0u);
|
||||
},
|
||||
filename
|
||||
);
|
||||
filename);
|
||||
}
|
||||
|
||||
TEST_CASE("arrays - copying")
|
||||
@ -116,8 +115,7 @@ TEST_CASE("arrays - copying")
|
||||
CHECK(arr3 == *arr1);
|
||||
CHECK(arr3 == arr2);
|
||||
},
|
||||
filename
|
||||
);
|
||||
filename);
|
||||
}
|
||||
|
||||
TEST_CASE("arrays - construction")
|
||||
@ -163,7 +161,7 @@ TEST_CASE("arrays - construction")
|
||||
CHECK(!arr.is_homogeneous());
|
||||
}
|
||||
|
||||
#if TOML_WINDOWS_COMPAT
|
||||
#if TOML_WINDOWS_COMPAT
|
||||
{
|
||||
array arr{ "mixed", "string"sv, L"test", L"kek"sv };
|
||||
CHECK(arr.size() == 4u);
|
||||
@ -174,7 +172,7 @@ TEST_CASE("arrays - construction")
|
||||
CHECK(*arr.get_as<std::string>(2) == "test"sv);
|
||||
CHECK(*arr.get_as<std::string>(3) == "kek"sv);
|
||||
}
|
||||
#endif // TOML_WINDOWS_COMPAT
|
||||
#endif // TOML_WINDOWS_COMPAT
|
||||
}
|
||||
|
||||
TEST_CASE("arrays - equality")
|
||||
@ -373,7 +371,7 @@ TEST_CASE("arrays - insertion and erasure")
|
||||
CHECK(*arr.get_as<double>(5u) == 3.0);
|
||||
}
|
||||
|
||||
#if TOML_WINDOWS_COMPAT
|
||||
#if TOML_WINDOWS_COMPAT
|
||||
|
||||
arr.clear();
|
||||
it = arr.insert(arr.cbegin(), L"test");
|
||||
@ -388,30 +386,37 @@ TEST_CASE("arrays - insertion and erasure")
|
||||
arr.emplace_back<std::string>(L"test4");
|
||||
REQUIRE(*arr.back().as_string() == "test4"sv);
|
||||
|
||||
#endif // TOML_WINDOWS_COMPAT
|
||||
#endif // TOML_WINDOWS_COMPAT
|
||||
}
|
||||
|
||||
TEST_CASE("arrays - flattening")
|
||||
{
|
||||
{
|
||||
array arr{
|
||||
1, 2, 3,
|
||||
1,
|
||||
2,
|
||||
3,
|
||||
array{ 4, 5 },
|
||||
6,
|
||||
array{},
|
||||
array{ 7, array{ 8, array{ 9 }, 10, array{}, }, 11 },
|
||||
array{ 7,
|
||||
array{
|
||||
8,
|
||||
array{ 9 },
|
||||
10,
|
||||
array{},
|
||||
},
|
||||
11 },
|
||||
};
|
||||
arr.flatten();
|
||||
REQUIRE(arr == array{ 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11 });
|
||||
}
|
||||
|
||||
{
|
||||
array arr{
|
||||
array{},
|
||||
array{inserter{array{}}},
|
||||
array{array{},array{array{},array{}},array{}},
|
||||
array{array{array{array{array{array{ 1 }}}}}}
|
||||
};
|
||||
array arr{ array{},
|
||||
array{ inserter{ array{} } },
|
||||
array{ array{}, array{ array{}, array{} }, array{} },
|
||||
array{ array{ array{ array{ array{ array{ 1 } } } } } } };
|
||||
arr.flatten();
|
||||
REQUIRE(arr == array{ 1 });
|
||||
}
|
||||
@ -442,7 +447,7 @@ TEST_CASE("arrays - resizing and truncation")
|
||||
REQUIRE(arr.size() == 2u);
|
||||
REQUIRE(arr == array{ 1, 2 });
|
||||
|
||||
//resize up to six elements
|
||||
// resize up to six elements
|
||||
arr.resize(6u, 42);
|
||||
REQUIRE(arr.size() == 6u);
|
||||
REQUIRE(arr == array{ 1, 2, 42, 42, 42, 42 });
|
||||
|
@ -52,19 +52,22 @@ TEST_CASE("parse_result - good parse")
|
||||
size_t tbl_iterations{};
|
||||
for (auto&& [k, v] : tbl)
|
||||
{
|
||||
(void)k; (void)v;
|
||||
(void)k;
|
||||
(void)v;
|
||||
tbl_iterations++;
|
||||
}
|
||||
size_t result_iterations{};
|
||||
for (auto& [k, v] : result)
|
||||
{
|
||||
(void)k; (void)v;
|
||||
(void)k;
|
||||
(void)v;
|
||||
result_iterations++;
|
||||
}
|
||||
size_t cresult_iterations{};
|
||||
for (auto [k, v] : cresult)
|
||||
{
|
||||
(void)k; (void)v;
|
||||
(void)k;
|
||||
(void)v;
|
||||
cresult_iterations++;
|
||||
}
|
||||
CHECK(tbl_iterations == tbl.size());
|
||||
@ -72,7 +75,6 @@ TEST_CASE("parse_result - good parse")
|
||||
CHECK(tbl_iterations == cresult_iterations);
|
||||
}
|
||||
|
||||
|
||||
TEST_CASE("parse_result - bad parse")
|
||||
{
|
||||
auto result = "key = trUe"_toml;
|
||||
@ -98,15 +100,16 @@ TEST_CASE("parse_result - bad parse")
|
||||
|
||||
for (auto [k, v] : result)
|
||||
{
|
||||
(void)k; (void)v;
|
||||
(void)k;
|
||||
(void)v;
|
||||
FAIL("This code should not run");
|
||||
}
|
||||
for (auto [k, v] : cresult)
|
||||
{
|
||||
(void)k; (void)v;
|
||||
(void)k;
|
||||
(void)v;
|
||||
FAIL("This code should not run");
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
#endif //!TOML_EXCEPTIONS
|
||||
|
@ -64,8 +64,7 @@ TEST_CASE("tables - moving")
|
||||
CHECK(tbl2.size() == 0u);
|
||||
CHECK(!tbl2["test"].as<table>());
|
||||
},
|
||||
filename
|
||||
);
|
||||
filename);
|
||||
}
|
||||
|
||||
TEST_CASE("tables - copying")
|
||||
@ -114,8 +113,7 @@ TEST_CASE("tables - copying")
|
||||
CHECK(tbl3 == tbl2);
|
||||
CHECK(tbl3 == tbl);
|
||||
},
|
||||
filename
|
||||
);
|
||||
filename);
|
||||
}
|
||||
|
||||
TEST_CASE("tables - construction")
|
||||
@ -132,9 +130,7 @@ TEST_CASE("tables - construction")
|
||||
}
|
||||
|
||||
{
|
||||
table tbl{{
|
||||
{ "foo"sv, 42 }
|
||||
}};
|
||||
table tbl{ { { "foo"sv, 42 } } };
|
||||
CHECK(tbl.size() == 1u);
|
||||
CHECK(!tbl.empty());
|
||||
CHECK(tbl.begin() != tbl.end());
|
||||
@ -144,12 +140,7 @@ TEST_CASE("tables - construction")
|
||||
}
|
||||
|
||||
{
|
||||
table tbl{{
|
||||
{ "foo"sv, 42 },
|
||||
{ "bar"sv, 10.0 },
|
||||
{ "kek"sv, false },
|
||||
{ "qux"sv, array{ 1 } }
|
||||
}};
|
||||
table tbl{ { { "foo"sv, 42 }, { "bar"sv, 10.0 }, { "kek"sv, false }, { "qux"sv, array{ 1 } } } };
|
||||
CHECK(tbl.size() == 4u);
|
||||
CHECK(!tbl.empty());
|
||||
REQUIRE(tbl.get_as<int64_t>("foo"sv));
|
||||
@ -162,14 +153,12 @@ TEST_CASE("tables - construction")
|
||||
CHECK(*tbl.get_as<array>("qux"sv) == array{ 1 });
|
||||
}
|
||||
|
||||
#if TOML_WINDOWS_COMPAT
|
||||
#if TOML_WINDOWS_COMPAT
|
||||
{
|
||||
table tbl{ {
|
||||
{ L"foo", L"test1" },
|
||||
table tbl{ { { L"foo", L"test1" },
|
||||
{ L"bar"sv, L"test2"sv },
|
||||
{ L"kek"s, L"test3"sv },
|
||||
{ L"qux"sv.data(), L"test4"sv.data() }
|
||||
} };
|
||||
{ L"qux"sv.data(), L"test4"sv.data() } } };
|
||||
CHECK(tbl.size() == 4u);
|
||||
CHECK(!tbl.empty());
|
||||
REQUIRE(tbl.get_as<std::string>("foo"sv));
|
||||
@ -181,46 +170,26 @@ TEST_CASE("tables - construction")
|
||||
REQUIRE(tbl.get_as<std::string>("qux"sv));
|
||||
CHECK(*tbl.get_as<std::string>("qux"sv) == "test4"sv);
|
||||
}
|
||||
#endif // TOML_WINDOWS_COMPAT
|
||||
#endif // TOML_WINDOWS_COMPAT
|
||||
}
|
||||
|
||||
TEST_CASE("tables - equality")
|
||||
{
|
||||
static constexpr const char* one = "one";
|
||||
|
||||
table tbl1{{
|
||||
{ one, 1 },
|
||||
{ "two", 2 },
|
||||
{ "three", 3 }
|
||||
}};
|
||||
table tbl1{ { { one, 1 }, { "two", 2 }, { "three", 3 } } };
|
||||
CHECK(tbl1 == tbl1);
|
||||
|
||||
table tbl2{{
|
||||
{ "one"sv, 1 },
|
||||
{ "two"sv, 2 },
|
||||
{ "three"sv, 3 }
|
||||
}};
|
||||
table tbl2{ { { "one"sv, 1 }, { "two"sv, 2 }, { "three"sv, 3 } } };
|
||||
CHECK(tbl1 == tbl2);
|
||||
|
||||
table tbl3{{
|
||||
{ "one"sv, 1 },
|
||||
{ "two"sv, 2 }
|
||||
}};
|
||||
table tbl3{ { { "one"sv, 1 }, { "two"sv, 2 } } };
|
||||
CHECK(tbl1 != tbl3);
|
||||
|
||||
table tbl4{{
|
||||
{ "one"sv, 1 },
|
||||
{ "two"sv, 2 },
|
||||
{ "three"sv, 3 },
|
||||
{ "four"sv, 4 }
|
||||
}};
|
||||
table tbl4{ { { "one"sv, 1 }, { "two"sv, 2 }, { "three"sv, 3 }, { "four"sv, 4 } } };
|
||||
CHECK(tbl1 != tbl4);
|
||||
|
||||
table tbl5{{
|
||||
{ "one"sv, 1 },
|
||||
{ "two"sv, 2 },
|
||||
{ "three"sv, 3.0 }
|
||||
}};
|
||||
table tbl5{ { { "one"sv, 1 }, { "two"sv, 2 }, { "three"sv, 3.0 } } };
|
||||
CHECK(tbl1 != tbl5);
|
||||
|
||||
table tbl6{};
|
||||
@ -260,7 +229,7 @@ TEST_CASE("tables - insertion and erasure")
|
||||
CHECK(!tbl.empty());
|
||||
REQUIRE(tbl.get_as<int64_t>("a"sv));
|
||||
CHECK(*tbl.get_as<int64_t>("a"sv) == 42);
|
||||
REQUIRE(tbl == table{{ { "a"sv, 42 } }});
|
||||
REQUIRE(tbl == table{ { { "a"sv, 42 } } });
|
||||
|
||||
res = tbl.insert("a", 69);
|
||||
CHECK(res.first == tbl.begin());
|
||||
@ -268,7 +237,7 @@ TEST_CASE("tables - insertion and erasure")
|
||||
CHECK(tbl.size() == 1u);
|
||||
REQUIRE(tbl.get_as<int64_t>("a"));
|
||||
CHECK(*tbl.get_as<int64_t>("a") == 42);
|
||||
REQUIRE(tbl == table{{ { "a"sv, 42 } }});
|
||||
REQUIRE(tbl == table{ { { "a"sv, 42 } } });
|
||||
|
||||
static constexpr const char* a = "a";
|
||||
res = tbl.insert_or_assign(a, 69);
|
||||
@ -277,7 +246,7 @@ TEST_CASE("tables - insertion and erasure")
|
||||
CHECK(tbl.size() == 1u);
|
||||
REQUIRE(tbl.get_as<int64_t>("a"));
|
||||
CHECK(*tbl.get_as<int64_t>("a") == 69);
|
||||
REQUIRE(tbl == table{{ { "a"sv, 69 } }});
|
||||
REQUIRE(tbl == table{ { { "a"sv, 69 } } });
|
||||
|
||||
res = tbl.insert_or_assign("b", "kek");
|
||||
CHECK(res.first == advance(tbl.begin(), 1));
|
||||
@ -285,7 +254,7 @@ TEST_CASE("tables - insertion and erasure")
|
||||
CHECK(tbl.size() == 2u);
|
||||
REQUIRE(tbl.get_as<std::string>("b"));
|
||||
CHECK(*tbl.get_as<std::string>("b") == "kek"sv);
|
||||
REQUIRE(tbl == table{{ { "a"sv, 69 }, { "b"sv, "kek" } }});
|
||||
REQUIRE(tbl == table{ { { "a"sv, 69 }, { "b"sv, "kek" } } });
|
||||
|
||||
res = tbl.emplace<array>("c", 1, 2, 3);
|
||||
CHECK(res.first == advance(tbl.begin(), 2));
|
||||
@ -293,7 +262,7 @@ TEST_CASE("tables - insertion and erasure")
|
||||
CHECK(tbl.size() == 3u);
|
||||
REQUIRE(tbl.get_as<array>("c"));
|
||||
CHECK(*tbl.get_as<array>("c") == array{ 1, 2, 3 });
|
||||
REQUIRE(tbl == table{{ { "a"sv, 69 }, { "b"sv, "kek"sv }, { "c"sv, array{ 1, 2, 3 } } }});
|
||||
REQUIRE(tbl == table{ { { "a"sv, 69 }, { "b"sv, "kek"sv }, { "c"sv, array{ 1, 2, 3 } } } });
|
||||
|
||||
res = tbl.emplace<int64_t>("c", 1);
|
||||
CHECK(res.first == advance(tbl.begin(), 2));
|
||||
@ -301,10 +270,10 @@ TEST_CASE("tables - insertion and erasure")
|
||||
CHECK(tbl.size() == 3u);
|
||||
REQUIRE(!tbl.get_as<int64_t>("c"));
|
||||
REQUIRE(tbl.get_as<array>("c"));
|
||||
REQUIRE(tbl == table{{ { "a"sv, 69 }, { "b"sv, "kek"s }, { "c"sv, array{ 1, 2, 3 } } }});
|
||||
REQUIRE(tbl == table{ { { "a"sv, 69 }, { "b"sv, "kek"s }, { "c"sv, array{ 1, 2, 3 } } } });
|
||||
|
||||
auto it = tbl.erase(tbl.cbegin());
|
||||
REQUIRE(tbl == table{{ { "b"sv, "kek" }, { "c"sv, array{ 1, 2, 3 } } }});
|
||||
REQUIRE(tbl == table{ { { "b"sv, "kek" }, { "c"sv, array{ 1, 2, 3 } } } });
|
||||
CHECK(it == tbl.begin());
|
||||
CHECK(tbl.size() == 2u);
|
||||
|
||||
@ -314,10 +283,10 @@ TEST_CASE("tables - insertion and erasure")
|
||||
CHECK(tbl.size() == 3u);
|
||||
REQUIRE(tbl.get_as<int64_t>("a"));
|
||||
CHECK(*tbl.get_as<int64_t>("a") == 69);
|
||||
REQUIRE(tbl == table{{ { "a"sv, 69 }, { "b"sv, "kek" }, { "c"sv, array{ 1, 2, 3 } } }});
|
||||
REQUIRE(tbl == table{ { { "a"sv, 69 }, { "b"sv, "kek" }, { "c"sv, array{ 1, 2, 3 } } } });
|
||||
|
||||
it = tbl.erase(advance(tbl.cbegin(), 1), advance(tbl.cbegin(), 3));
|
||||
REQUIRE(tbl == table{{ { "a"sv, 69 } }});
|
||||
REQUIRE(tbl == table{ { { "a"sv, 69 } } });
|
||||
CHECK(it == tbl.end());
|
||||
CHECK(tbl.size() == 1u);
|
||||
|
||||
@ -328,11 +297,7 @@ TEST_CASE("tables - insertion and erasure")
|
||||
|
||||
// void insert(Iter first, Iter last)
|
||||
{
|
||||
std::vector<std::pair<std::string, std::string>> vals{
|
||||
{ "foo", "foo" },
|
||||
{ "bar", "bar" },
|
||||
{ "kek", "kek" }
|
||||
};
|
||||
std::vector<std::pair<std::string, std::string>> vals{ { "foo", "foo" }, { "bar", "bar" }, { "kek", "kek" } };
|
||||
tbl.insert(vals.begin(), vals.end());
|
||||
CHECK(tbl.size() == 3u);
|
||||
REQUIRE(tbl.get_as<std::string>("foo"));
|
||||
@ -355,11 +320,7 @@ TEST_CASE("tables - insertion and erasure")
|
||||
|
||||
// void insert(Iter first, Iter last) (with move iterators)
|
||||
{
|
||||
std::vector<std::pair<std::string, std::string>> vals{
|
||||
{ "foo", "foo" },
|
||||
{ "bar", "bar" },
|
||||
{ "kek", "kek" }
|
||||
};
|
||||
std::vector<std::pair<std::string, std::string>> vals{ { "foo", "foo" }, { "bar", "bar" }, { "kek", "kek" } };
|
||||
tbl.insert(std::make_move_iterator(vals.begin()), std::make_move_iterator(vals.end()));
|
||||
CHECK(tbl.size() == 3u);
|
||||
REQUIRE(tbl.get_as<std::string>("foo"));
|
||||
@ -380,8 +341,7 @@ TEST_CASE("tables - insertion and erasure")
|
||||
tbl.clear();
|
||||
}
|
||||
|
||||
|
||||
#if TOML_WINDOWS_COMPAT
|
||||
#if TOML_WINDOWS_COMPAT
|
||||
|
||||
tbl.insert(L"a", L"test1");
|
||||
REQUIRE(*tbl.get_as<std::string>(L"a"sv) == "test1"sv);
|
||||
@ -395,7 +355,7 @@ TEST_CASE("tables - insertion and erasure")
|
||||
tbl.erase(L"a"s);
|
||||
CHECK(tbl.size() == 0u);
|
||||
|
||||
#endif // TOML_WINDOWS_COMPAT
|
||||
#endif // TOML_WINDOWS_COMPAT
|
||||
}
|
||||
|
||||
TEST_CASE("tables - printing")
|
||||
@ -458,4 +418,3 @@ c = 3)"sv;
|
||||
CHECK(to_string(some_toml) == some_toml);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -18,8 +18,9 @@ static constexpr T one = static_cast<T>(1);
|
||||
|
||||
TEST_CASE("values - construction")
|
||||
{
|
||||
#define CHECK_VALUE_INIT2(initializer, target_type, equiv) \
|
||||
do { \
|
||||
#define CHECK_VALUE_INIT2(initializer, target_type, equiv) \
|
||||
do \
|
||||
{ \
|
||||
auto v = value{ initializer }; \
|
||||
static_assert(std::is_same_v<decltype(v), value<target_type>>); \
|
||||
CHECK(v == equiv); \
|
||||
@ -29,10 +30,10 @@ TEST_CASE("values - construction")
|
||||
CHECK(v.is_homogeneous()); \
|
||||
CHECK(v.is_homogeneous<target_type>()); \
|
||||
CHECK(v.is_homogeneous(impl::node_type_of<target_type>)); \
|
||||
} while (false)
|
||||
} \
|
||||
while (false)
|
||||
|
||||
#define CHECK_VALUE_INIT(initializer, target_type) \
|
||||
CHECK_VALUE_INIT2(initializer, target_type, initializer)
|
||||
#define CHECK_VALUE_INIT(initializer, target_type) CHECK_VALUE_INIT2(initializer, target_type, initializer)
|
||||
|
||||
CHECK_VALUE_INIT(one<signed char>, int64_t);
|
||||
CHECK_VALUE_INIT(one<signed short>, int64_t);
|
||||
@ -50,14 +51,14 @@ TEST_CASE("values - construction")
|
||||
CHECK_VALUE_INIT("kek"s, std::string);
|
||||
CHECK_VALUE_INIT("kek"sv, std::string);
|
||||
CHECK_VALUE_INIT2("kek"sv.data(), std::string, "kek"sv);
|
||||
#if TOML_HAS_CHAR8
|
||||
#if TOML_HAS_CHAR8
|
||||
CHECK_VALUE_INIT2(u8"kek", std::string, "kek"sv);
|
||||
CHECK_VALUE_INIT2(u8"kek"s, std::string, "kek"sv);
|
||||
CHECK_VALUE_INIT2(u8"kek"sv, std::string, "kek"sv);
|
||||
CHECK_VALUE_INIT2(u8"kek"sv.data(), std::string, "kek"sv);
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#ifdef _WIN32
|
||||
#ifdef _WIN32
|
||||
CHECK_VALUE_INIT(one<BOOL>, int64_t);
|
||||
CHECK_VALUE_INIT(one<SHORT>, int64_t);
|
||||
CHECK_VALUE_INIT(one<INT>, int64_t);
|
||||
@ -75,16 +76,16 @@ TEST_CASE("values - construction")
|
||||
CHECK_VALUE_INIT2(one<DWORD64>, int64_t, 1u);
|
||||
CHECK_VALUE_INIT2(one<DWORDLONG>, int64_t, 1u);
|
||||
|
||||
#if TOML_WINDOWS_COMPAT
|
||||
#if TOML_WINDOWS_COMPAT
|
||||
|
||||
CHECK_VALUE_INIT2(L"kek", std::string, "kek"sv);
|
||||
CHECK_VALUE_INIT2(L"kek"s, std::string, "kek"sv);
|
||||
CHECK_VALUE_INIT2(L"kek"sv, std::string, "kek"sv);
|
||||
CHECK_VALUE_INIT2(L"kek"sv.data(), std::string, "kek"sv);
|
||||
|
||||
#endif // TOML_WINDOWS_COMPAT
|
||||
#endif // TOML_WINDOWS_COMPAT
|
||||
|
||||
#endif
|
||||
#endif
|
||||
}
|
||||
|
||||
TEST_CASE("values - printing")
|
||||
@ -132,10 +133,8 @@ TEST_CASE("values - printing")
|
||||
|
||||
TEST_CASE("nodes - value() int/float/bool conversions")
|
||||
{
|
||||
#define CHECK_VALUE_PASS(type, v) \
|
||||
CHECK(n.value<type>() == static_cast<type>(v))
|
||||
#define CHECK_VALUE_FAIL(type) \
|
||||
CHECK(!n.value<type>())
|
||||
#define CHECK_VALUE_PASS(type, v) CHECK(n.value<type>() == static_cast<type>(v))
|
||||
#define CHECK_VALUE_FAIL(type) CHECK(!n.value<type>())
|
||||
|
||||
// bools
|
||||
{
|
||||
@ -328,7 +327,6 @@ TEST_CASE("nodes - value() int/float/bool conversions")
|
||||
CHECK_VALUE_FAIL(toml::time);
|
||||
CHECK_VALUE_FAIL(toml::date_time);
|
||||
|
||||
|
||||
*val = 1.0;
|
||||
CHECK_VALUE_FAIL(bool);
|
||||
CHECK_VALUE_PASS(int8_t, 1);
|
||||
|
@ -7,8 +7,7 @@
|
||||
|
||||
TEST_CASE("parsing - arrays")
|
||||
{
|
||||
parsing_should_succeed(
|
||||
FILE_LINE_ARGS,
|
||||
parsing_should_succeed(FILE_LINE_ARGS,
|
||||
R"(
|
||||
integers = [ 1, 2, 3 ]
|
||||
integers2 = [
|
||||
@ -131,14 +130,12 @@ TEST_CASE("parsing - arrays")
|
||||
CHECK(tbl["integers"][0] == 1);
|
||||
CHECK(tbl["integers"][1] == 2);
|
||||
CHECK(tbl["integers"][2] == 3);
|
||||
}
|
||||
);
|
||||
});
|
||||
|
||||
// toml/issues/665 (heterogeneous arrays)
|
||||
#if TOML_LANG_AT_LEAST(1, 0, 0)
|
||||
// toml/issues/665 (heterogeneous arrays)
|
||||
#if TOML_LANG_AT_LEAST(1, 0, 0)
|
||||
|
||||
parsing_should_succeed(
|
||||
FILE_LINE_ARGS,
|
||||
parsing_should_succeed(FILE_LINE_ARGS,
|
||||
R"(
|
||||
# Mixed-type arrays are allowed
|
||||
numbers = [ 0.1, 0.2, 0.5, 1, 2, 5 ]
|
||||
@ -174,12 +171,11 @@ TEST_CASE("parsing - arrays")
|
||||
CHECK(tbl["contributors"][1]["name"] == "Baz Qux"sv);
|
||||
CHECK(tbl["contributors"][1]["email"] == "bazqux@example.com"sv);
|
||||
CHECK(tbl["contributors"][1]["url"] == "https://example.com/bazqux"sv);
|
||||
}
|
||||
);
|
||||
});
|
||||
|
||||
#else
|
||||
#else
|
||||
|
||||
parsing_should_fail(FILE_LINE_ARGS, "numbers = [ 0.1, 0.2, 0.5, 1, 2, 5 ]"sv);
|
||||
|
||||
#endif
|
||||
#endif
|
||||
}
|
||||
|
@ -7,8 +7,7 @@
|
||||
|
||||
TEST_CASE("parsing - booleans")
|
||||
{
|
||||
parsing_should_succeed(
|
||||
FILE_LINE_ARGS,
|
||||
parsing_should_succeed(FILE_LINE_ARGS,
|
||||
R"(
|
||||
bool1 = true
|
||||
bool2 = false
|
||||
@ -17,8 +16,7 @@ TEST_CASE("parsing - booleans")
|
||||
{
|
||||
CHECK(tbl["bool1"] == true);
|
||||
CHECK(tbl["bool2"] == false);
|
||||
}
|
||||
);
|
||||
});
|
||||
|
||||
// "Always lowercase."
|
||||
parsing_should_fail(FILE_LINE_ARGS, "bool = True"sv);
|
||||
|
@ -7,9 +7,9 @@
|
||||
|
||||
TEST_CASE("parsing - comments")
|
||||
{
|
||||
parsing_should_succeed(
|
||||
FILE_LINE_ARGS,
|
||||
R"(# This is a full-line comment
|
||||
parsing_should_succeed(FILE_LINE_ARGS,
|
||||
R"(
|
||||
# This is a full-line comment
|
||||
key = "value" # This is a comment at the end of a line
|
||||
another = "# This is not a comment"
|
||||
)"sv,
|
||||
@ -18,19 +18,13 @@ TEST_CASE("parsing - comments")
|
||||
CHECK(tbl.size() == 2);
|
||||
CHECK(tbl["key"] == "value"sv);
|
||||
CHECK(tbl["another"] == "# This is not a comment"sv);
|
||||
}
|
||||
);
|
||||
});
|
||||
|
||||
parsing_should_succeed(
|
||||
FILE_LINE_ARGS,
|
||||
parsing_should_succeed(FILE_LINE_ARGS,
|
||||
R"(# this = "looks like a KVP but is commented out)"sv,
|
||||
[](table&& tbl)
|
||||
{
|
||||
CHECK(tbl.size() == 0);
|
||||
}
|
||||
);
|
||||
[](table&& tbl) { CHECK(tbl.size() == 0); });
|
||||
|
||||
#if TOML_LANG_AT_LEAST(1, 0, 0)
|
||||
#if TOML_LANG_AT_LEAST(1, 0, 0)
|
||||
{
|
||||
// toml/issues/567 (disallow non-TAB control characters in comments)
|
||||
// 00 - 08
|
||||
@ -73,10 +67,10 @@ TEST_CASE("parsing - comments")
|
||||
// 7F
|
||||
parsing_should_fail(FILE_LINE_ARGS, "# \u007F"sv);
|
||||
}
|
||||
#else
|
||||
#else
|
||||
{
|
||||
parsing_should_succeed(FILE_LINE_ARGS, S(
|
||||
"## 00 - 08"
|
||||
parsing_should_succeed(FILE_LINE_ARGS,
|
||||
S("## 00 - 08"
|
||||
"# \u0000 "
|
||||
"# \u0001 "
|
||||
"# \u0002 "
|
||||
@ -110,8 +104,7 @@ TEST_CASE("parsing - comments")
|
||||
"# \u001E "
|
||||
"# \u001F "
|
||||
"## 7F "
|
||||
"# \u007F "sv
|
||||
));
|
||||
"# \u007F "sv));
|
||||
}
|
||||
#endif
|
||||
#endif
|
||||
}
|
||||
|
@ -7,8 +7,7 @@
|
||||
|
||||
TEST_CASE("parsing - floats")
|
||||
{
|
||||
parsing_should_succeed(
|
||||
FILE_LINE_ARGS,
|
||||
parsing_should_succeed(FILE_LINE_ARGS,
|
||||
R"(
|
||||
# fractional
|
||||
flt1 = +1.0
|
||||
@ -35,8 +34,7 @@ TEST_CASE("parsing - floats")
|
||||
CHECK(tbl["flt6"] == -2E-2);
|
||||
CHECK(tbl["flt7"].as<double>()->get() == 6.626e-34_a);
|
||||
CHECK(tbl["flt8"].as<double>()->get() == 224617.445991228_a);
|
||||
}
|
||||
);
|
||||
});
|
||||
|
||||
// "Each underscore must be surrounded by at least one digit on each side."
|
||||
parsing_should_fail(FILE_LINE_ARGS, "flt8 = 224_617.445_991_228_"sv);
|
||||
@ -44,15 +42,13 @@ TEST_CASE("parsing - floats")
|
||||
parsing_should_fail(FILE_LINE_ARGS, "flt8 = 224__617.445_991_228"sv);
|
||||
|
||||
// "Float values -0.0 and +0.0 are valid and should map according to IEEE 754."
|
||||
parsing_should_succeed(
|
||||
FILE_LINE_ARGS,
|
||||
parsing_should_succeed(FILE_LINE_ARGS,
|
||||
R"(zeroes = [-0.0, +0.0])"sv,
|
||||
[](table&& tbl)
|
||||
{
|
||||
CHECK(tbl["zeroes"][0] == -0.0);
|
||||
CHECK(tbl["zeroes"][1] == +0.0);
|
||||
}
|
||||
);
|
||||
});
|
||||
|
||||
// "A float consists of an integer part followed by a fractional part and/or an exponent part"
|
||||
// (i.e. omitting the leading digits before the '.' is not legal in TOML)
|
||||
@ -84,62 +80,62 @@ TEST_CASE("parsing - floats")
|
||||
parsing_should_fail(FILE_LINE_ARGS, "flt = -1.e-1"sv);
|
||||
|
||||
// value tests
|
||||
parse_expected_value( FILE_LINE_ARGS, "1e1"sv, 1e1);
|
||||
parse_expected_value( FILE_LINE_ARGS, "1e+1"sv, 1e+1);
|
||||
parse_expected_value( FILE_LINE_ARGS, "1e-1"sv, 1e-1);
|
||||
parse_expected_value( FILE_LINE_ARGS, "1.0"sv, 1.0);
|
||||
parse_expected_value( FILE_LINE_ARGS, "1.0e1"sv, 1.0e1);
|
||||
parse_expected_value( FILE_LINE_ARGS, "1.0e+1"sv, 1.0e+1);
|
||||
parse_expected_value( FILE_LINE_ARGS, "1.0e-1"sv, 1.0e-1);
|
||||
parse_expected_value( FILE_LINE_ARGS, "+1e1"sv, +1e1);
|
||||
parse_expected_value( FILE_LINE_ARGS, "+1.0"sv, +1.0);
|
||||
parse_expected_value( FILE_LINE_ARGS, "+1.0e1"sv, +1.0e1);
|
||||
parse_expected_value( FILE_LINE_ARGS, "+1.0e+1"sv, +1.0e+1);
|
||||
parse_expected_value( FILE_LINE_ARGS, "+1.0e-1"sv, +1.0e-1);
|
||||
parse_expected_value( FILE_LINE_ARGS, "-1.0e+1"sv, -1.0e+1);
|
||||
parse_expected_value( FILE_LINE_ARGS, "-1e1"sv, -1e1);
|
||||
parse_expected_value( FILE_LINE_ARGS, "-1.0"sv, -1.0);
|
||||
parse_expected_value( FILE_LINE_ARGS, "-1.0e1"sv, -1.0e1);
|
||||
parse_expected_value( FILE_LINE_ARGS, "-1.0e-1"sv, -1.0e-1);
|
||||
parse_expected_value( FILE_LINE_ARGS, "0.1"sv, 0.1);
|
||||
parse_expected_value( FILE_LINE_ARGS, "0.001"sv, 0.001);
|
||||
parse_expected_value( FILE_LINE_ARGS, "0.100"sv, 0.100);
|
||||
parse_expected_value( FILE_LINE_ARGS, "+3.14"sv, +3.14);
|
||||
parse_expected_value( FILE_LINE_ARGS, "-3.14"sv, -3.14);
|
||||
parse_expected_value( FILE_LINE_ARGS, "3.1415_9265_3589"sv, 3.141592653589);
|
||||
parse_expected_value( FILE_LINE_ARGS, "+3.1415_9265_3589"sv, +3.141592653589);
|
||||
parse_expected_value( FILE_LINE_ARGS, "-3.1415_9265_3589"sv, -3.141592653589);
|
||||
parse_expected_value( FILE_LINE_ARGS, "123_456.789"sv, 123456.789);
|
||||
parse_expected_value( FILE_LINE_ARGS, "+123_456.789"sv, +123456.789);
|
||||
parse_expected_value( FILE_LINE_ARGS, "-123_456.789"sv, -123456.789);
|
||||
parse_expected_value( FILE_LINE_ARGS, "+0.0"sv, +0.0);
|
||||
parse_expected_value( FILE_LINE_ARGS, "-0.0"sv, -0.0);
|
||||
parse_expected_value( FILE_LINE_ARGS, "1e10"sv, 1e10);
|
||||
parse_expected_value( FILE_LINE_ARGS, "1e+10"sv, 1e+10);
|
||||
parse_expected_value( FILE_LINE_ARGS, "1e-10"sv, 1e-10);
|
||||
parse_expected_value( FILE_LINE_ARGS, "+1e10"sv, +1e10);
|
||||
parse_expected_value( FILE_LINE_ARGS, "+1e+10"sv, +1e+10);
|
||||
parse_expected_value( FILE_LINE_ARGS, "+1e-10"sv, +1e-10);
|
||||
parse_expected_value( FILE_LINE_ARGS, "-1e10"sv, -1e10);
|
||||
parse_expected_value( FILE_LINE_ARGS, "-1e+10"sv, -1e+10);
|
||||
parse_expected_value( FILE_LINE_ARGS, "-1e-10"sv, -1e-10);
|
||||
parse_expected_value( FILE_LINE_ARGS, "123e-10"sv, 123e-10);
|
||||
parse_expected_value( FILE_LINE_ARGS, "1E10"sv, 1E10);
|
||||
parse_expected_value( FILE_LINE_ARGS, "1E+10"sv, 1E+10);
|
||||
parse_expected_value( FILE_LINE_ARGS, "1E-10"sv, 1E-10);
|
||||
parse_expected_value( FILE_LINE_ARGS, "123E-10"sv, 123E-10);
|
||||
parse_expected_value( FILE_LINE_ARGS, "1_2_3E-10"sv, 123E-10);
|
||||
parse_expected_value( FILE_LINE_ARGS, "1_2_3E-1_0"sv, 123E-10);
|
||||
parse_expected_value( FILE_LINE_ARGS, "+0e0"sv, +0e0);
|
||||
parse_expected_value( FILE_LINE_ARGS, "-0e0"sv, -0e0);
|
||||
parse_expected_value( FILE_LINE_ARGS, "1_2_3E-01"sv, 123E-01);
|
||||
parse_expected_value( FILE_LINE_ARGS, "1_2_3E-0_1"sv, 123E-01);
|
||||
parse_expected_value( FILE_LINE_ARGS, "6.02e23"sv, 6.02e23);
|
||||
parse_expected_value( FILE_LINE_ARGS, "6.02e+23"sv, 6.02e+23);
|
||||
parse_expected_value( FILE_LINE_ARGS, "1.112_650_06e-17"sv, 1.11265006e-17);
|
||||
parse_expected_value(FILE_LINE_ARGS, "1e1"sv, 1e1);
|
||||
parse_expected_value(FILE_LINE_ARGS, "1e+1"sv, 1e+1);
|
||||
parse_expected_value(FILE_LINE_ARGS, "1e-1"sv, 1e-1);
|
||||
parse_expected_value(FILE_LINE_ARGS, "1.0"sv, 1.0);
|
||||
parse_expected_value(FILE_LINE_ARGS, "1.0e1"sv, 1.0e1);
|
||||
parse_expected_value(FILE_LINE_ARGS, "1.0e+1"sv, 1.0e+1);
|
||||
parse_expected_value(FILE_LINE_ARGS, "1.0e-1"sv, 1.0e-1);
|
||||
parse_expected_value(FILE_LINE_ARGS, "+1e1"sv, +1e1);
|
||||
parse_expected_value(FILE_LINE_ARGS, "+1.0"sv, +1.0);
|
||||
parse_expected_value(FILE_LINE_ARGS, "+1.0e1"sv, +1.0e1);
|
||||
parse_expected_value(FILE_LINE_ARGS, "+1.0e+1"sv, +1.0e+1);
|
||||
parse_expected_value(FILE_LINE_ARGS, "+1.0e-1"sv, +1.0e-1);
|
||||
parse_expected_value(FILE_LINE_ARGS, "-1.0e+1"sv, -1.0e+1);
|
||||
parse_expected_value(FILE_LINE_ARGS, "-1e1"sv, -1e1);
|
||||
parse_expected_value(FILE_LINE_ARGS, "-1.0"sv, -1.0);
|
||||
parse_expected_value(FILE_LINE_ARGS, "-1.0e1"sv, -1.0e1);
|
||||
parse_expected_value(FILE_LINE_ARGS, "-1.0e-1"sv, -1.0e-1);
|
||||
parse_expected_value(FILE_LINE_ARGS, "0.1"sv, 0.1);
|
||||
parse_expected_value(FILE_LINE_ARGS, "0.001"sv, 0.001);
|
||||
parse_expected_value(FILE_LINE_ARGS, "0.100"sv, 0.100);
|
||||
parse_expected_value(FILE_LINE_ARGS, "+3.14"sv, +3.14);
|
||||
parse_expected_value(FILE_LINE_ARGS, "-3.14"sv, -3.14);
|
||||
parse_expected_value(FILE_LINE_ARGS, "3.1415_9265_3589"sv, 3.141592653589);
|
||||
parse_expected_value(FILE_LINE_ARGS, "+3.1415_9265_3589"sv, +3.141592653589);
|
||||
parse_expected_value(FILE_LINE_ARGS, "-3.1415_9265_3589"sv, -3.141592653589);
|
||||
parse_expected_value(FILE_LINE_ARGS, "123_456.789"sv, 123456.789);
|
||||
parse_expected_value(FILE_LINE_ARGS, "+123_456.789"sv, +123456.789);
|
||||
parse_expected_value(FILE_LINE_ARGS, "-123_456.789"sv, -123456.789);
|
||||
parse_expected_value(FILE_LINE_ARGS, "+0.0"sv, +0.0);
|
||||
parse_expected_value(FILE_LINE_ARGS, "-0.0"sv, -0.0);
|
||||
parse_expected_value(FILE_LINE_ARGS, "1e10"sv, 1e10);
|
||||
parse_expected_value(FILE_LINE_ARGS, "1e+10"sv, 1e+10);
|
||||
parse_expected_value(FILE_LINE_ARGS, "1e-10"sv, 1e-10);
|
||||
parse_expected_value(FILE_LINE_ARGS, "+1e10"sv, +1e10);
|
||||
parse_expected_value(FILE_LINE_ARGS, "+1e+10"sv, +1e+10);
|
||||
parse_expected_value(FILE_LINE_ARGS, "+1e-10"sv, +1e-10);
|
||||
parse_expected_value(FILE_LINE_ARGS, "-1e10"sv, -1e10);
|
||||
parse_expected_value(FILE_LINE_ARGS, "-1e+10"sv, -1e+10);
|
||||
parse_expected_value(FILE_LINE_ARGS, "-1e-10"sv, -1e-10);
|
||||
parse_expected_value(FILE_LINE_ARGS, "123e-10"sv, 123e-10);
|
||||
parse_expected_value(FILE_LINE_ARGS, "1E10"sv, 1E10);
|
||||
parse_expected_value(FILE_LINE_ARGS, "1E+10"sv, 1E+10);
|
||||
parse_expected_value(FILE_LINE_ARGS, "1E-10"sv, 1E-10);
|
||||
parse_expected_value(FILE_LINE_ARGS, "123E-10"sv, 123E-10);
|
||||
parse_expected_value(FILE_LINE_ARGS, "1_2_3E-10"sv, 123E-10);
|
||||
parse_expected_value(FILE_LINE_ARGS, "1_2_3E-1_0"sv, 123E-10);
|
||||
parse_expected_value(FILE_LINE_ARGS, "+0e0"sv, +0e0);
|
||||
parse_expected_value(FILE_LINE_ARGS, "-0e0"sv, -0e0);
|
||||
parse_expected_value(FILE_LINE_ARGS, "1_2_3E-01"sv, 123E-01);
|
||||
parse_expected_value(FILE_LINE_ARGS, "1_2_3E-0_1"sv, 123E-01);
|
||||
parse_expected_value(FILE_LINE_ARGS, "6.02e23"sv, 6.02e23);
|
||||
parse_expected_value(FILE_LINE_ARGS, "6.02e+23"sv, 6.02e+23);
|
||||
parse_expected_value(FILE_LINE_ARGS, "1.112_650_06e-17"sv, 1.11265006e-17);
|
||||
|
||||
// toml/issues/562 (hexfloats)
|
||||
#if TOML_LANG_UNRELEASED
|
||||
// toml/issues/562 (hexfloats)
|
||||
#if TOML_LANG_UNRELEASED
|
||||
parse_expected_value(FILE_LINE_ARGS, " 0x1.2p3"sv, 0x1.2p3);
|
||||
parse_expected_value(FILE_LINE_ARGS, " 0x10p1"sv, 0x10p1);
|
||||
parse_expected_value(FILE_LINE_ARGS, " 0x10p-1"sv, 0x10p-1);
|
||||
@ -159,7 +155,7 @@ TEST_CASE("parsing - floats")
|
||||
parse_expected_value(FILE_LINE_ARGS, " +0x10.1p+1"sv, +0x10.1p+1);
|
||||
parse_expected_value(FILE_LINE_ARGS, " -0x10.1p+1"sv, -0x10.1p+1);
|
||||
parse_expected_value(FILE_LINE_ARGS, " +0x10.1p-1"sv, +0x10.1p-1);
|
||||
#else
|
||||
#else
|
||||
parsing_should_fail(FILE_LINE_ARGS, " val = 0x10p1"sv);
|
||||
parsing_should_fail(FILE_LINE_ARGS, " val = 0x10p-1"sv);
|
||||
parsing_should_fail(FILE_LINE_ARGS, " val = 0x10p+1"sv);
|
||||
@ -178,13 +174,12 @@ TEST_CASE("parsing - floats")
|
||||
parsing_should_fail(FILE_LINE_ARGS, " val = +0x10.1p+1"sv);
|
||||
parsing_should_fail(FILE_LINE_ARGS, " val = -0x10.1p+1"sv);
|
||||
parsing_should_fail(FILE_LINE_ARGS, " val = +0x10.1p-1"sv);
|
||||
#endif
|
||||
#endif
|
||||
}
|
||||
|
||||
TEST_CASE("parsing - inf and nan")
|
||||
{
|
||||
parsing_should_succeed(
|
||||
FILE_LINE_ARGS,
|
||||
parsing_should_succeed(FILE_LINE_ARGS,
|
||||
R"(
|
||||
# infinity
|
||||
sf1 = inf # positive infinity
|
||||
@ -204,8 +199,7 @@ TEST_CASE("parsing - inf and nan")
|
||||
CHECK(impl::fpclassify(**tbl["sf4"].as<double>()) == impl::fp_class::nan);
|
||||
CHECK(impl::fpclassify(**tbl["sf5"].as<double>()) == impl::fp_class::nan);
|
||||
CHECK(impl::fpclassify(**tbl["sf6"].as<double>()) == impl::fp_class::nan);
|
||||
}
|
||||
);
|
||||
});
|
||||
|
||||
parsing_should_fail(FILE_LINE_ARGS, " val = NaN "sv);
|
||||
parsing_should_fail(FILE_LINE_ARGS, " val = Nan "sv);
|
||||
|
@ -7,8 +7,7 @@
|
||||
|
||||
TEST_CASE("parsing - integers (decimal)")
|
||||
{
|
||||
parsing_should_succeed(
|
||||
FILE_LINE_ARGS,
|
||||
parsing_should_succeed(FILE_LINE_ARGS,
|
||||
BOM_PREFIX R"(
|
||||
int1 = +99
|
||||
int2 = 42
|
||||
@ -27,8 +26,7 @@ TEST_CASE("parsing - integers (decimal)")
|
||||
CHECK(tbl["int5"] == 1000);
|
||||
CHECK(tbl["int6"] == 5349221);
|
||||
CHECK(tbl["int7"] == 12345);
|
||||
}
|
||||
);
|
||||
});
|
||||
|
||||
// "Each underscore must be surrounded by at least one digit on each side."
|
||||
parsing_should_fail(FILE_LINE_ARGS, "int5 = 1__000"sv);
|
||||
@ -45,15 +43,13 @@ TEST_CASE("parsing - integers (decimal)")
|
||||
parsing_should_fail(FILE_LINE_ARGS, "int7 = 01_2_3_4_5"sv);
|
||||
|
||||
// "Integer values -0 and +0 are valid and identical to an unprefixed zero."
|
||||
parsing_should_succeed(
|
||||
FILE_LINE_ARGS,
|
||||
parsing_should_succeed(FILE_LINE_ARGS,
|
||||
"zeroes = [-0, +0]"sv,
|
||||
[](table&& tbl)
|
||||
{
|
||||
CHECK(tbl["zeroes"][0] == 0);
|
||||
CHECK(tbl["zeroes"][1] == 0);
|
||||
}
|
||||
);
|
||||
});
|
||||
|
||||
// "64 bit (signed long) range expected (−9,223,372,036,854,775,808 to 9,223,372,036,854,775,807)."
|
||||
parse_expected_value(FILE_LINE_ARGS, "9223372036854775807"sv, INT64_MAX);
|
||||
@ -87,8 +83,7 @@ TEST_CASE("parsing - integers (decimal)")
|
||||
|
||||
TEST_CASE("parsing - integers (hex, bin, oct)")
|
||||
{
|
||||
parsing_should_succeed(
|
||||
FILE_LINE_ARGS,
|
||||
parsing_should_succeed(FILE_LINE_ARGS,
|
||||
R"(
|
||||
# hexadecimal with prefix `0x`
|
||||
hex1 = 0xDEADBEEF
|
||||
@ -110,8 +105,7 @@ TEST_CASE("parsing - integers (hex, bin, oct)")
|
||||
CHECK(tbl["oct1"] == 01234567);
|
||||
CHECK(tbl["oct2"] == 0755);
|
||||
CHECK(tbl["bin1"] == 0b11010110);
|
||||
}
|
||||
);
|
||||
});
|
||||
|
||||
// "leading + is not allowed"
|
||||
parsing_should_fail(FILE_LINE_ARGS, "hex1 = +0xDEADBEEF"sv);
|
||||
@ -123,8 +117,7 @@ TEST_CASE("parsing - integers (hex, bin, oct)")
|
||||
parsing_should_fail(FILE_LINE_ARGS, "bin1 = +0b11010110"sv);
|
||||
|
||||
// "leading zeros are allowed (after the prefix)"
|
||||
parsing_should_succeed(
|
||||
FILE_LINE_ARGS,
|
||||
parsing_should_succeed(FILE_LINE_ARGS,
|
||||
R"(
|
||||
hex1 = 0x000DEADBEEF
|
||||
hex2 = 0x00000deadbeef
|
||||
@ -141,8 +134,7 @@ TEST_CASE("parsing - integers (hex, bin, oct)")
|
||||
CHECK(tbl["oct1"] == 01234567);
|
||||
CHECK(tbl["oct2"] == 0755);
|
||||
CHECK(tbl["bin1"] == 0b11010110);
|
||||
}
|
||||
);
|
||||
});
|
||||
|
||||
// "***Non-negative*** integer values may also be expressed in hexadecimal, octal, or binary"
|
||||
parsing_should_fail(FILE_LINE_ARGS, "val = -0x1"sv);
|
||||
@ -153,7 +145,9 @@ TEST_CASE("parsing - integers (hex, bin, oct)")
|
||||
// (ignoring INT64_MIN because toml doesn't allow these forms to represent negative values)
|
||||
parse_expected_value(FILE_LINE_ARGS, "0x7FFFFFFFFFFFFFFF"sv, INT64_MAX);
|
||||
parse_expected_value(FILE_LINE_ARGS, "0o777777777777777777777"sv, INT64_MAX);
|
||||
parse_expected_value(FILE_LINE_ARGS, "0b111111111111111111111111111111111111111111111111111111111111111"sv, INT64_MAX);
|
||||
parse_expected_value(FILE_LINE_ARGS,
|
||||
"0b111111111111111111111111111111111111111111111111111111111111111"sv,
|
||||
INT64_MAX);
|
||||
parsing_should_fail(FILE_LINE_ARGS, "val = 0x8000000000000000"sv); // INT64_MAX + 1
|
||||
parsing_should_fail(FILE_LINE_ARGS, "val = 0o1000000000000000000000"sv);
|
||||
parsing_should_fail(FILE_LINE_ARGS, "val = 0b1000000000000000000000000000000000000000000000000000000000000000"sv);
|
||||
@ -175,5 +169,4 @@ TEST_CASE("parsing - integers (hex, bin, oct)")
|
||||
parse_expected_value(FILE_LINE_ARGS, "0b010000"sv, 0b10000);
|
||||
parse_expected_value(FILE_LINE_ARGS, "0b01_00_00"sv, 0b10000);
|
||||
parse_expected_value(FILE_LINE_ARGS, "0b111111"sv, 0b111111);
|
||||
|
||||
}
|
||||
|
@ -7,8 +7,7 @@
|
||||
|
||||
TEST_CASE("parsing - key-value pairs")
|
||||
{
|
||||
parsing_should_succeed(
|
||||
FILE_LINE_ARGS,
|
||||
parsing_should_succeed(FILE_LINE_ARGS,
|
||||
R"(
|
||||
key = "value"
|
||||
bare_key = "value"
|
||||
@ -24,14 +23,12 @@ TEST_CASE("parsing - key-value pairs")
|
||||
CHECK(tbl["bare-key"] == "value"sv);
|
||||
CHECK(tbl["1234"] == "value"sv);
|
||||
CHECK(tbl[""] == "blank"sv);
|
||||
}
|
||||
);
|
||||
});
|
||||
|
||||
parsing_should_fail(FILE_LINE_ARGS, R"(key = # INVALID)"sv);
|
||||
|
||||
#if UNICODE_LITERALS_OK
|
||||
parsing_should_succeed(
|
||||
FILE_LINE_ARGS,
|
||||
#if UNICODE_LITERALS_OK
|
||||
parsing_should_succeed(FILE_LINE_ARGS,
|
||||
R"(
|
||||
"127.0.0.1" = "value"
|
||||
"character encoding" = "value"
|
||||
@ -48,9 +45,8 @@ TEST_CASE("parsing - key-value pairs")
|
||||
CHECK(tbl["key2"] == "value"sv);
|
||||
CHECK(tbl["quoted \"value\""] == "value"sv);
|
||||
CHECK(tbl[""] == "blank"sv);
|
||||
}
|
||||
);
|
||||
#endif // UNICODE_LITERALS_OK
|
||||
});
|
||||
#endif // UNICODE_LITERALS_OK
|
||||
|
||||
parsing_should_fail(FILE_LINE_ARGS, R"(= "no key name")"sv);
|
||||
|
||||
@ -63,8 +59,7 @@ TEST_CASE("parsing - key-value pairs")
|
||||
|
||||
TEST_CASE("parsing - key-value pairs (dotted)")
|
||||
{
|
||||
parsing_should_succeed(
|
||||
FILE_LINE_ARGS,
|
||||
parsing_should_succeed(FILE_LINE_ARGS,
|
||||
R"(
|
||||
name = "Orange"
|
||||
physical.color = "orange"
|
||||
@ -80,12 +75,9 @@ TEST_CASE("parsing - key-value pairs (dotted)")
|
||||
CHECK(tbl["physical"]["shape"] == "round"sv);
|
||||
CHECK(tbl["site"]["google.com"] == true);
|
||||
CHECK(tbl["3"]["14159"] == "pi"sv);
|
||||
}
|
||||
);
|
||||
});
|
||||
|
||||
|
||||
parsing_should_succeed(
|
||||
FILE_LINE_ARGS,
|
||||
parsing_should_succeed(FILE_LINE_ARGS,
|
||||
R"(
|
||||
fruit.apple.smooth = true
|
||||
fruit.orange = 2
|
||||
@ -94,8 +86,7 @@ TEST_CASE("parsing - key-value pairs (dotted)")
|
||||
{
|
||||
CHECK(tbl["fruit"]["apple"]["smooth"] == true);
|
||||
CHECK(tbl["fruit"]["orange"] == 2);
|
||||
}
|
||||
);
|
||||
});
|
||||
|
||||
parsing_should_fail(FILE_LINE_ARGS, R"(
|
||||
# THIS IS INVALID
|
||||
@ -103,8 +94,7 @@ TEST_CASE("parsing - key-value pairs (dotted)")
|
||||
fruit.apple.smooth = true
|
||||
)"sv);
|
||||
|
||||
parsing_should_succeed(
|
||||
FILE_LINE_ARGS,
|
||||
parsing_should_succeed(FILE_LINE_ARGS,
|
||||
R"(
|
||||
# VALID BUT DISCOURAGED
|
||||
|
||||
@ -125,11 +115,9 @@ TEST_CASE("parsing - key-value pairs (dotted)")
|
||||
CHECK(tbl["orange"]["type"] == "fruit"sv);
|
||||
CHECK(tbl["orange"]["skin"] == "thick"sv);
|
||||
CHECK(tbl["orange"]["color"] == "orange"sv);
|
||||
}
|
||||
);
|
||||
});
|
||||
|
||||
parsing_should_succeed(
|
||||
FILE_LINE_ARGS,
|
||||
parsing_should_succeed(FILE_LINE_ARGS,
|
||||
R"(
|
||||
# RECOMMENDED
|
||||
|
||||
@ -149,14 +137,12 @@ TEST_CASE("parsing - key-value pairs (dotted)")
|
||||
CHECK(tbl["orange"]["type"] == "fruit"sv);
|
||||
CHECK(tbl["orange"]["skin"] == "thick"sv);
|
||||
CHECK(tbl["orange"]["color"] == "orange"sv);
|
||||
}
|
||||
);
|
||||
});
|
||||
|
||||
// toml/issues/644 ('+' in bare keys) & toml/issues/687 (unicode bare keys)
|
||||
#if UNICODE_LITERALS_OK
|
||||
#if TOML_LANG_UNRELEASED
|
||||
parsing_should_succeed(
|
||||
FILE_LINE_ARGS,
|
||||
// toml/issues/644 ('+' in bare keys) & toml/issues/687 (unicode bare keys)
|
||||
#if UNICODE_LITERALS_OK
|
||||
#if TOML_LANG_UNRELEASED
|
||||
parsing_should_succeed(FILE_LINE_ARGS,
|
||||
R"(
|
||||
key+1 = 0
|
||||
ʎǝʞ2 = 0
|
||||
@ -166,13 +152,12 @@ TEST_CASE("parsing - key-value pairs (dotted)")
|
||||
CHECK(tbl.size() == 2);
|
||||
CHECK(tbl["key+1"] == 0);
|
||||
CHECK(tbl["ʎǝʞ2"] == 0);
|
||||
}
|
||||
);
|
||||
#else
|
||||
});
|
||||
#else
|
||||
parsing_should_fail(FILE_LINE_ARGS, R"(key+1 = 0)"sv);
|
||||
parsing_should_fail(FILE_LINE_ARGS, R"(ʎǝʞ2 = 0)"sv);
|
||||
#endif
|
||||
#endif // UNICODE_LITERALS_OK
|
||||
#endif
|
||||
#endif // UNICODE_LITERALS_OK
|
||||
}
|
||||
|
||||
TEST_CASE("parsing - key-value pairs (string keys)")
|
||||
@ -244,10 +229,12 @@ TEST_CASE("parsing - key-value pairs (string keys)")
|
||||
parsing_should_fail(FILE_LINE_ARGS, R"(a."""b""" = 3)"sv);
|
||||
|
||||
// whitespace relevant (success test, values are NOTE equal)
|
||||
parsing_should_succeed(FILE_LINE_ARGS, R"(
|
||||
parsing_should_succeed(FILE_LINE_ARGS,
|
||||
R"(
|
||||
a = " to do "
|
||||
b = "to do"
|
||||
)"sv, [](table&& tbl)
|
||||
)"sv,
|
||||
[](table&& tbl)
|
||||
{
|
||||
CHECK(tbl["a"] == " to do "sv);
|
||||
CHECK(tbl["b"] == "to do"sv);
|
||||
@ -284,10 +271,12 @@ TEST_CASE("parsing - key-value pairs (string keys)")
|
||||
)"sv);
|
||||
|
||||
// inner quotes are not stripped from value, a & b are equal, value surrounded by quotes
|
||||
parsing_should_succeed(FILE_LINE_ARGS, R"(
|
||||
parsing_should_succeed(FILE_LINE_ARGS,
|
||||
R"(
|
||||
a = "\"quoted\""
|
||||
b = """"quoted""""
|
||||
)"sv, [](table&& tbl)
|
||||
)"sv,
|
||||
[](table&& tbl)
|
||||
{
|
||||
CHECK(tbl["a"] == "\"quoted\""sv);
|
||||
CHECK(tbl["b"] == "\"quoted\""sv);
|
||||
|
@ -7,8 +7,7 @@
|
||||
|
||||
TEST_CASE("parsing - strings")
|
||||
{
|
||||
parsing_should_succeed(
|
||||
FILE_LINE_ARGS,
|
||||
parsing_should_succeed(FILE_LINE_ARGS,
|
||||
R"(
|
||||
str = "I'm a string. \"You can quote me\". Name\tJos\u00E9\nLocation\tSF."
|
||||
|
||||
@ -23,14 +22,13 @@ Violets are blue"""
|
||||
)"sv,
|
||||
[](table&& tbl)
|
||||
{
|
||||
CHECK(tbl["str"] == "I'm a string. \"You can quote me\". Name\tJos\u00E9\nLocation\tSF."sv);
|
||||
CHECK(tbl["str"]
|
||||
== "I'm a string. \"You can quote me\". Name\tJos\u00E9\nLocation\tSF."sv);
|
||||
CHECK(tbl["str1"] == "Roses are red\nViolets are blue"sv);
|
||||
CHECK(tbl["str2"] == "\nRoses are red\nViolets are blue"sv);
|
||||
}
|
||||
);
|
||||
});
|
||||
|
||||
parsing_should_succeed(
|
||||
FILE_LINE_ARGS,
|
||||
parsing_should_succeed(FILE_LINE_ARGS,
|
||||
R"(
|
||||
# The following strings are byte-for-byte equivalent:
|
||||
str1 = "The quick brown fox jumps over the lazy dog."
|
||||
@ -66,13 +64,11 @@ str7 = """"This," she said, "is just a pointless statement.""""
|
||||
CHECK(tbl["str5"] == R"(Here are three quotation marks: """.)"sv);
|
||||
CHECK(tbl["str6"] == R"(Here are fifteen quotation marks: """"""""""""""".)"sv);
|
||||
CHECK(tbl["str7"] == R"("This," she said, "is just a pointless statement.")"sv);
|
||||
}
|
||||
);
|
||||
});
|
||||
|
||||
parsing_should_fail(FILE_LINE_ARGS, R"(str5 = """Here are three quotation marks: """.""")"sv);
|
||||
|
||||
parsing_should_succeed(
|
||||
FILE_LINE_ARGS,
|
||||
parsing_should_succeed(FILE_LINE_ARGS,
|
||||
R"(
|
||||
# What you see is what you get.
|
||||
winpath = 'C:\Users\nodejs\templates'
|
||||
@ -112,11 +108,9 @@ trimmed in raw strings.
|
||||
All other whitespace
|
||||
is preserved.
|
||||
)"sv);
|
||||
}
|
||||
);
|
||||
});
|
||||
|
||||
parsing_should_succeed(
|
||||
FILE_LINE_ARGS,
|
||||
parsing_should_succeed(FILE_LINE_ARGS,
|
||||
R"(
|
||||
quot15 = '''Here are fifteen quotation marks: """""""""""""""'''
|
||||
|
||||
@ -131,72 +125,58 @@ str = ''''That's still pointless', she said.'''
|
||||
CHECK(tbl["quot15"] == R"(Here are fifteen quotation marks: """"""""""""""")"sv);
|
||||
CHECK(tbl["apos15"] == R"(Here are fifteen apostrophes: ''''''''''''''')"sv);
|
||||
CHECK(tbl["str"] == R"('That's still pointless', she said.)"sv);
|
||||
}
|
||||
);
|
||||
});
|
||||
|
||||
parsing_should_fail(FILE_LINE_ARGS, R"(apos15 = '''Here are fifteen apostrophes: '''''''''''''''''' # INVALID)"sv);
|
||||
|
||||
// value tests
|
||||
parse_expected_value(
|
||||
FILE_LINE_ARGS,
|
||||
parse_expected_value(FILE_LINE_ARGS,
|
||||
R"("The quick brown fox jumps over the lazy dog")"sv,
|
||||
"The quick brown fox jumps over the lazy dog"sv);
|
||||
parse_expected_value(
|
||||
FILE_LINE_ARGS,
|
||||
parse_expected_value(FILE_LINE_ARGS,
|
||||
R"('The quick brown fox jumps over the lazy dog')"sv,
|
||||
"The quick brown fox jumps over the lazy dog"sv);
|
||||
parse_expected_value(
|
||||
FILE_LINE_ARGS,
|
||||
parse_expected_value(FILE_LINE_ARGS,
|
||||
R"("""The quick brown fox jumps over the lazy dog""")"sv,
|
||||
"The quick brown fox jumps over the lazy dog"sv);
|
||||
parse_expected_value(
|
||||
FILE_LINE_ARGS,
|
||||
parse_expected_value(FILE_LINE_ARGS,
|
||||
R"('''The quick brown fox jumps over the lazy dog''')"sv,
|
||||
"The quick brown fox jumps over the lazy dog"sv);
|
||||
|
||||
#if UNICODE_LITERALS_OK
|
||||
parse_expected_value(
|
||||
FILE_LINE_ARGS,
|
||||
R"("Ýôú'ℓℓ λáƭè ₥è áƒƭèř ƭλïƨ - #")"sv,
|
||||
R"(Ýôú'ℓℓ λáƭè ₥è áƒƭèř ƭλïƨ - #)"sv);
|
||||
parse_expected_value(
|
||||
FILE_LINE_ARGS,
|
||||
#if UNICODE_LITERALS_OK
|
||||
parse_expected_value(FILE_LINE_ARGS, R"("Ýôú'ℓℓ λáƭè ₥è áƒƭèř ƭλïƨ - #")"sv, R"(Ýôú'ℓℓ λáƭè ₥è áƒƭèř ƭλïƨ - #)"sv);
|
||||
parse_expected_value(FILE_LINE_ARGS,
|
||||
R"(" Âñδ ωλèñ \"'ƨ ářè ïñ ƭλè ƨƭřïñϱ, áℓôñϱ ωïƭλ # \"")"sv,
|
||||
R"( Âñδ ωλèñ "'ƨ ářè ïñ ƭλè ƨƭřïñϱ, áℓôñϱ ωïƭλ # ")"sv);
|
||||
parse_expected_value(
|
||||
FILE_LINE_ARGS,
|
||||
parse_expected_value(FILE_LINE_ARGS,
|
||||
R"("Ýôú δôñ'ƭ ƭλïñƙ ƨô₥è úƨèř ωôñ'ƭ δô ƭλáƭ?")"sv,
|
||||
R"(Ýôú δôñ'ƭ ƭλïñƙ ƨô₥è úƨèř ωôñ'ƭ δô ƭλáƭ?)"sv);
|
||||
#endif // UNICODE_LITERALS_OK
|
||||
#endif // UNICODE_LITERALS_OK
|
||||
|
||||
parse_expected_value(
|
||||
FILE_LINE_ARGS,
|
||||
R"("\"\u03B1\u03B2\u03B3\"")"sv,
|
||||
"\"\u03B1\u03B2\u03B3\""sv);
|
||||
parse_expected_value(FILE_LINE_ARGS, R"("\"\u03B1\u03B2\u03B3\"")"sv, "\"\u03B1\u03B2\u03B3\""sv);
|
||||
|
||||
// toml/pull/709 (\xHH unicode scalars)
|
||||
#if TOML_LANG_UNRELEASED
|
||||
parse_expected_value(
|
||||
FILE_LINE_ARGS,
|
||||
// toml/pull/709 (\xHH unicode scalars)
|
||||
#if TOML_LANG_UNRELEASED
|
||||
parse_expected_value(FILE_LINE_ARGS,
|
||||
R"("\x00\x10\x20\x30\x40\x50\x60\x70\x80\x90\x11\xFF\xEE")"sv,
|
||||
"\u0000\u0010\u0020\u0030\u0040\u0050\u0060\u0070\u0080\u0090\u0011\u00FF\u00EE"sv);
|
||||
#else
|
||||
#else
|
||||
parsing_should_fail(FILE_LINE_ARGS, R"(str = "\x00\x10\x20\x30\x40\x50\x60\x70\x80\x90\x11\xFF\xEE")"sv);
|
||||
#endif
|
||||
#endif
|
||||
|
||||
// check 8-digit \U scalars with insufficient digits
|
||||
parsing_should_fail(FILE_LINE_ARGS,R"(str = "\U1234567")"sv);
|
||||
parsing_should_fail(FILE_LINE_ARGS,R"(str = "\U123456")"sv);
|
||||
parsing_should_fail(FILE_LINE_ARGS,R"(str = "\U12345")"sv);
|
||||
parsing_should_fail(FILE_LINE_ARGS,R"(str = "\U1234")"sv);
|
||||
parsing_should_fail(FILE_LINE_ARGS,R"(str = "\U123")"sv);
|
||||
parsing_should_fail(FILE_LINE_ARGS,R"(str = "\U12")"sv);
|
||||
parsing_should_fail(FILE_LINE_ARGS,R"(str = "\U1")"sv);
|
||||
parsing_should_fail(FILE_LINE_ARGS, R"(str = "\U1234567")"sv);
|
||||
parsing_should_fail(FILE_LINE_ARGS, R"(str = "\U123456")"sv);
|
||||
parsing_should_fail(FILE_LINE_ARGS, R"(str = "\U12345")"sv);
|
||||
parsing_should_fail(FILE_LINE_ARGS, R"(str = "\U1234")"sv);
|
||||
parsing_should_fail(FILE_LINE_ARGS, R"(str = "\U123")"sv);
|
||||
parsing_should_fail(FILE_LINE_ARGS, R"(str = "\U12")"sv);
|
||||
parsing_should_fail(FILE_LINE_ARGS, R"(str = "\U1")"sv);
|
||||
|
||||
// check 4-digit \u scalars with insufficient digits
|
||||
parsing_should_fail(FILE_LINE_ARGS,R"(str = "\u123")"sv);
|
||||
parsing_should_fail(FILE_LINE_ARGS,R"(str = "\u12")"sv);
|
||||
parsing_should_fail(FILE_LINE_ARGS,R"(str = "\u1")"sv);
|
||||
parsing_should_fail(FILE_LINE_ARGS, R"(str = "\u123")"sv);
|
||||
parsing_should_fail(FILE_LINE_ARGS, R"(str = "\u12")"sv);
|
||||
parsing_should_fail(FILE_LINE_ARGS, R"(str = "\u1")"sv);
|
||||
|
||||
// check 2-digit \x scalars with insufficient digits
|
||||
parsing_should_fail(FILE_LINE_ARGS, R"(str = "\x1")"sv);
|
||||
|
@ -10,21 +10,19 @@ TEST_CASE("parsing - tables")
|
||||
// these are the examples from https://toml.io/en/v1.0.0#table
|
||||
|
||||
// "Tables are defined by headers, with square brackets on a line by themselves."
|
||||
parsing_should_succeed(
|
||||
FILE_LINE_ARGS, "[table]"sv,
|
||||
parsing_should_succeed(FILE_LINE_ARGS,
|
||||
"[table]"sv,
|
||||
[](table&& tbl)
|
||||
{
|
||||
REQUIRE(tbl["table"].as_table());
|
||||
CHECK(tbl["table"].as_table()->empty());
|
||||
CHECK(tbl["table"].as_table()->size() == 0u);
|
||||
}
|
||||
);
|
||||
});
|
||||
parsing_should_fail(FILE_LINE_ARGS, "[]"sv);
|
||||
|
||||
// "Under that, and until the next header or EOF, are the key/values of that table.
|
||||
// Key/value pairs within tables are not guaranteed to be in any specific order."
|
||||
parsing_should_succeed(
|
||||
FILE_LINE_ARGS,
|
||||
parsing_should_succeed(FILE_LINE_ARGS,
|
||||
R"(
|
||||
[table-1]
|
||||
key1 = "some string"
|
||||
@ -45,12 +43,10 @@ TEST_CASE("parsing - tables")
|
||||
CHECK(tbl["table-2"].as_table()->size() == 2u);
|
||||
CHECK(tbl["table-2"]["key1"] == "another string"sv);
|
||||
CHECK(tbl["table-2"]["key2"] == 456);
|
||||
}
|
||||
);
|
||||
});
|
||||
|
||||
// "Naming rules for tables are the same as for keys." (i.e. can be quoted)
|
||||
parsing_should_succeed(
|
||||
FILE_LINE_ARGS,
|
||||
parsing_should_succeed(FILE_LINE_ARGS,
|
||||
R"(
|
||||
[dog."tater.man"]
|
||||
type.name = "pug"
|
||||
@ -63,12 +59,10 @@ TEST_CASE("parsing - tables")
|
||||
REQUIRE(tbl["dog"]["tater.man"].as_table());
|
||||
CHECK(tbl["dog"]["tater.man"].as_table()->size() == 1u);
|
||||
CHECK(tbl["dog"]["tater.man"]["type"]["name"] == "pug"sv);
|
||||
}
|
||||
);
|
||||
});
|
||||
|
||||
// "Whitespace around the key is ignored. However, best practice is to not use any extraneous whitespace."
|
||||
parsing_should_succeed(
|
||||
FILE_LINE_ARGS,
|
||||
parsing_should_succeed(FILE_LINE_ARGS,
|
||||
R"(
|
||||
[a.b.c] # this is best practice
|
||||
[ d.e.f ] # same as [d.e.f]
|
||||
@ -92,12 +86,10 @@ TEST_CASE("parsing - tables")
|
||||
CHECK(tbl["j"].as_table());
|
||||
CHECK(tbl["j"]["k"].as_table());
|
||||
CHECK(tbl["j"]["k"]["l"].as_table());
|
||||
}
|
||||
);
|
||||
});
|
||||
|
||||
// "You don't need to specify all the super-tables if you don't want to. TOML knows how to do it for you."
|
||||
parsing_should_succeed(
|
||||
FILE_LINE_ARGS,
|
||||
parsing_should_succeed(FILE_LINE_ARGS,
|
||||
R"(
|
||||
# [x] you
|
||||
# [x.y] don't
|
||||
@ -112,8 +104,7 @@ TEST_CASE("parsing - tables")
|
||||
CHECK(tbl["x"]["y"].as_table());
|
||||
CHECK(tbl["x"]["y"]["z"].as_table());
|
||||
CHECK(tbl["x"]["y"]["z"]["w"].as_table());
|
||||
}
|
||||
);
|
||||
});
|
||||
|
||||
// "Like keys, you cannot define a table more than once. Doing so is invalid."
|
||||
parsing_should_fail(FILE_LINE_ARGS, R"(
|
||||
@ -136,8 +127,7 @@ TEST_CASE("parsing - tables")
|
||||
)"sv);
|
||||
|
||||
// "Defining tables out-of-order is discouraged."
|
||||
parsing_should_succeed(
|
||||
FILE_LINE_ARGS,
|
||||
parsing_should_succeed(FILE_LINE_ARGS,
|
||||
R"(
|
||||
# VALID BUT DISCOURAGED
|
||||
[fruit.apple]
|
||||
@ -150,10 +140,8 @@ TEST_CASE("parsing - tables")
|
||||
CHECK(tbl["fruit"]["apple"].as_table());
|
||||
CHECK(tbl["animal"].as_table());
|
||||
CHECK(tbl["fruit"]["orange"].as_table());
|
||||
}
|
||||
);
|
||||
parsing_should_succeed(
|
||||
FILE_LINE_ARGS,
|
||||
});
|
||||
parsing_should_succeed(FILE_LINE_ARGS,
|
||||
R"(
|
||||
# RECOMMENDED
|
||||
[fruit.apple]
|
||||
@ -166,13 +154,11 @@ TEST_CASE("parsing - tables")
|
||||
CHECK(tbl["fruit"]["apple"].as_table());
|
||||
CHECK(tbl["fruit"]["orange"].as_table());
|
||||
CHECK(tbl["animal"].as_table());
|
||||
}
|
||||
);
|
||||
});
|
||||
|
||||
// "The top-level table, also called the root table, starts at the beginning of the document
|
||||
// and ends just before the first table header (or EOF)."
|
||||
parsing_should_succeed(
|
||||
FILE_LINE_ARGS,
|
||||
parsing_should_succeed(FILE_LINE_ARGS,
|
||||
R"(
|
||||
# Top-level table begins.
|
||||
name = "Fido"
|
||||
@ -195,13 +181,11 @@ TEST_CASE("parsing - tables")
|
||||
|
||||
static constexpr auto member_since = toml::date{ 1999, 8, 4 };
|
||||
CHECK(*tbl["owner"]["member_since"].as_date() == member_since);
|
||||
}
|
||||
);
|
||||
});
|
||||
|
||||
// "Dotted keys create and define a table for each key part before the last one,
|
||||
// provided that such tables were not previously created."
|
||||
parsing_should_succeed(
|
||||
FILE_LINE_ARGS,
|
||||
parsing_should_succeed(FILE_LINE_ARGS,
|
||||
R"(
|
||||
fruit.apple.color = "red"
|
||||
# Defines a table named fruit
|
||||
@ -221,8 +205,7 @@ TEST_CASE("parsing - tables")
|
||||
CHECK(tbl["fruit"]["apple"]["taste"].as_table());
|
||||
CHECK(tbl["fruit"]["apple"]["taste"]["sweet"].as_boolean());
|
||||
CHECK(*tbl["fruit"]["apple"]["taste"]["sweet"].as_boolean() == true);
|
||||
}
|
||||
);
|
||||
});
|
||||
|
||||
// "Since tables cannot be defined more than once, redefining such tables using a [table] header is not allowed."
|
||||
parsing_should_fail(FILE_LINE_ARGS, R"(
|
||||
@ -257,8 +240,7 @@ TEST_CASE("parsing - tables")
|
||||
)"sv);
|
||||
|
||||
// "The [table] form can, however, be used to define sub-tables within tables defined via dotted keys."
|
||||
parsing_should_succeed(
|
||||
FILE_LINE_ARGS,
|
||||
parsing_should_succeed(FILE_LINE_ARGS,
|
||||
R"(
|
||||
[fruit]
|
||||
apple.color = "red"
|
||||
@ -277,8 +259,7 @@ TEST_CASE("parsing - tables")
|
||||
CHECK(tbl["fruit"]["apple"]["texture"].as_table());
|
||||
CHECK(tbl["fruit"]["apple"]["texture"]["smooth"].as_boolean());
|
||||
CHECK(*tbl["fruit"]["apple"]["texture"]["smooth"].as_boolean() == true);
|
||||
}
|
||||
);
|
||||
});
|
||||
parsing_should_fail(FILE_LINE_ARGS, R"(
|
||||
[fruit]
|
||||
apple.color = "red"
|
||||
@ -293,8 +274,7 @@ TEST_CASE("parsing - tables")
|
||||
|
||||
// same as above but the table order is reversed.
|
||||
// see: https://github.com/toml-lang/toml/issues/769
|
||||
parsing_should_succeed(
|
||||
FILE_LINE_ARGS,
|
||||
parsing_should_succeed(FILE_LINE_ARGS,
|
||||
R"(
|
||||
[fruit.apple.texture]
|
||||
smooth = true
|
||||
@ -313,16 +293,14 @@ TEST_CASE("parsing - tables")
|
||||
CHECK(tbl["fruit"]["apple"]["texture"].as_table());
|
||||
CHECK(tbl["fruit"]["apple"]["texture"]["smooth"].as_boolean());
|
||||
CHECK(*tbl["fruit"]["apple"]["texture"]["smooth"].as_boolean() == true);
|
||||
}
|
||||
);
|
||||
});
|
||||
}
|
||||
|
||||
TEST_CASE("parsing - inline tables")
|
||||
{
|
||||
// these are the examples from https://toml.io/en/v1.0.0#inline-table
|
||||
|
||||
parsing_should_succeed(
|
||||
FILE_LINE_ARGS,
|
||||
parsing_should_succeed(FILE_LINE_ARGS,
|
||||
R"(
|
||||
name = { first = "Tom", last = "Preston-Werner" }
|
||||
point = { x = 1, y = 2 }
|
||||
@ -348,8 +326,7 @@ TEST_CASE("parsing - inline tables")
|
||||
REQUIRE(tbl["animal"]["type"].as_table());
|
||||
CHECK(tbl["animal"]["type"].as_table()->size() == 1u);
|
||||
CHECK(tbl["animal"]["type"]["name"] == "pug"sv);
|
||||
}
|
||||
);
|
||||
});
|
||||
|
||||
// "Inline tables are fully self-contained and define all keys and sub-tables within them.
|
||||
// Keys and sub-tables cannot be added outside the braces."
|
||||
@ -367,8 +344,7 @@ TEST_CASE("parsing - inline tables")
|
||||
)"sv);
|
||||
|
||||
// "newlines are allowed between the curly braces [if] they are valid within a value."
|
||||
parsing_should_succeed(
|
||||
FILE_LINE_ARGS,
|
||||
parsing_should_succeed(FILE_LINE_ARGS,
|
||||
R"(
|
||||
test = { val1 = "foo", val2 = [
|
||||
1, 2,
|
||||
@ -386,70 +362,64 @@ test = { val1 = "foo", val2 = [
|
||||
CHECK(tbl["test"]["val2"][1] == 2);
|
||||
CHECK(tbl["test"]["val2"][2] == 3);
|
||||
CHECK(tbl["test"]["val3"] == "bar"sv);
|
||||
}
|
||||
);
|
||||
});
|
||||
|
||||
// toml/issues/516 (newlines/trailing commas in inline tables)
|
||||
#if TOML_LANG_UNRELEASED
|
||||
// toml/issues/516 (newlines/trailing commas in inline tables)
|
||||
#if TOML_LANG_UNRELEASED
|
||||
{
|
||||
parsing_should_succeed(
|
||||
FILE_LINE_ARGS,
|
||||
parsing_should_succeed(FILE_LINE_ARGS,
|
||||
R"(
|
||||
name = {
|
||||
name = {
|
||||
first = "Tom",
|
||||
last = "Preston-Werner",
|
||||
}
|
||||
)"sv,
|
||||
}
|
||||
)"sv,
|
||||
[](table&& tbl)
|
||||
{
|
||||
REQUIRE(tbl["name"].as_table());
|
||||
CHECK(tbl["name"].as_table()->size() == 2u);
|
||||
CHECK(tbl["name"]["first"] == "Tom"sv);
|
||||
CHECK(tbl["name"]["last"] == "Preston-Werner"sv);
|
||||
});
|
||||
}
|
||||
);
|
||||
|
||||
}
|
||||
#else
|
||||
#else
|
||||
{
|
||||
// "A terminating comma (also called trailing comma) is not permitted after the last key/value pair in an inline table."
|
||||
// "A terminating comma (also called trailing comma) is not permitted after the last key/value pair in an inline
|
||||
// table."
|
||||
parsing_should_fail(FILE_LINE_ARGS, R"(name = { first = "Tom", last = "Preston-Werner", })"sv);
|
||||
|
||||
// "No newlines are allowed between the curly braces unless they are valid within a value."
|
||||
parsing_should_fail(FILE_LINE_ARGS, R"(
|
||||
name = {
|
||||
name = {
|
||||
first = "Tom",
|
||||
last = "Preston-Werner"
|
||||
}
|
||||
)"sv);
|
||||
|
||||
}
|
||||
#endif
|
||||
|
||||
)"sv);
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
TEST_CASE("parsing - arrays-of-tables")
|
||||
{
|
||||
parsing_should_succeed(
|
||||
FILE_LINE_ARGS,
|
||||
parsing_should_succeed(FILE_LINE_ARGS,
|
||||
R"(
|
||||
points = [ { x = 1, y = 2, z = 3 },
|
||||
points = [ { x = 1, y = 2, z = 3 },
|
||||
{ x = 7, y = 8, z = 9 },
|
||||
{ x = 2, y = 4, z = 8 } ]
|
||||
|
||||
[[products]]
|
||||
name = "Hammer"
|
||||
sku = 738594937
|
||||
[[products]]
|
||||
name = "Hammer"
|
||||
sku = 738594937
|
||||
|
||||
[[products]]
|
||||
[[products]]
|
||||
|
||||
[[products]]
|
||||
name = "Nail"
|
||||
sku = 284758393
|
||||
[[products]]
|
||||
name = "Nail"
|
||||
sku = 284758393
|
||||
|
||||
color = "gray"
|
||||
color = "gray"
|
||||
|
||||
[[fruit]]
|
||||
[[fruit]]
|
||||
name = "apple"
|
||||
|
||||
[fruit.physical] # subtable
|
||||
@ -462,13 +432,13 @@ color = "gray"
|
||||
[[fruit.variety]]
|
||||
name = "granny smith"
|
||||
|
||||
[[fruit]]
|
||||
[[fruit]]
|
||||
name = "banana"
|
||||
|
||||
[[fruit.variety]]
|
||||
name = "plantain"
|
||||
|
||||
)"sv,
|
||||
)"sv,
|
||||
[](table&& tbl)
|
||||
{
|
||||
REQUIRE(tbl["points"].as<array>());
|
||||
@ -504,7 +474,6 @@ color = "gray"
|
||||
CHECK(tbl["products"][2]["sku"] == 284758393);
|
||||
CHECK(tbl["products"][2]["color"] == "gray"sv);
|
||||
|
||||
|
||||
REQUIRE(tbl["fruit"].as<array>());
|
||||
CHECK(tbl["fruit"].as<array>()->size() == 2u);
|
||||
CHECK(tbl["fruit"].as<array>()->is_homogeneous());
|
||||
@ -535,8 +504,7 @@ color = "gray"
|
||||
CHECK(tbl["fruit"][1]["variety"].as<array>()->is_homogeneous());
|
||||
CHECK(tbl["fruit"][1]["variety"].as<array>()->is_array_of_tables());
|
||||
CHECK(tbl["fruit"][1]["variety"][0]["name"] == "plantain"sv);
|
||||
}
|
||||
);
|
||||
});
|
||||
|
||||
parsing_should_fail(FILE_LINE_ARGS, R"(
|
||||
# INVALID TOML DOC
|
||||
|
114
tests/settings.h
114
tests/settings.h
@ -2,33 +2,32 @@
|
||||
// Copyright (c) Mark Gillard <mark.gillard@outlook.com.au>
|
||||
// See https://github.com/marzer/tomlplusplus/blob/master/LICENSE for the full license text.
|
||||
// SPDX-License-Identifier: MIT
|
||||
|
||||
#pragma once
|
||||
|
||||
// toml++ config
|
||||
#define TOML_UNDEF_MACROS 0
|
||||
#ifndef TOML_HEADER_ONLY
|
||||
#define TOML_HEADER_ONLY 0
|
||||
#define TOML_HEADER_ONLY 0
|
||||
#endif
|
||||
#ifndef USE_SINGLE_HEADER
|
||||
#define USE_SINGLE_HEADER 0
|
||||
#define USE_SINGLE_HEADER 0
|
||||
#endif
|
||||
#if defined(LEAK_TESTS) && LEAK_TESTS
|
||||
#define TOML_CONFIG_HEADER "leakproof.h"
|
||||
#define TOML_CONFIG_HEADER "leakproof.h"
|
||||
#else
|
||||
#undef LEAK_TESTS
|
||||
#define LEAK_TESTS 0
|
||||
#undef LEAK_TESTS
|
||||
#define LEAK_TESTS 0
|
||||
#endif
|
||||
|
||||
// use tl::optional?
|
||||
#if defined(USE_TARTANLLAMA_OPTIONAL) && USE_TARTANLLAMA_OPTIONAL
|
||||
#define TOML_OPTIONAL_TYPE tl::optional
|
||||
#define TOML_OPTIONAL_TYPE tl::optional
|
||||
#else
|
||||
#undef USE_TARTANLLAMA_OPTIONAL
|
||||
#define USE_TARTANLLAMA_OPTIONAL 0
|
||||
#undef USE_TARTANLLAMA_OPTIONAL
|
||||
#define USE_TARTANLLAMA_OPTIONAL 0
|
||||
#endif
|
||||
|
||||
//catch2 config
|
||||
// catch2 config
|
||||
#define CATCH_CONFIG_CPP11_TO_STRING
|
||||
#define CATCH_CONFIG_CPP17_OPTIONAL
|
||||
#define CATCH_CONFIG_CPP17_STRING_VIEW
|
||||
@ -38,65 +37,64 @@
|
||||
#define CATCH_CONFIG_DISABLE_MATCHERS
|
||||
#define CATCH_CONFIG_NO_NOMINMAX
|
||||
|
||||
//windows.h config (included transitively by catch2 on windows)
|
||||
// windows.h config (included transitively by catch2 on windows)
|
||||
#ifdef _WIN32
|
||||
#define WIN32_LEAN_AND_MEAN
|
||||
#define VC_EXTRALEAN
|
||||
#define NOATOM // - Atom Manager routines
|
||||
#define NOBITMAP
|
||||
#define NOCLIPBOARD // - Clipboard routines
|
||||
#define NOCOLOR // - Screen colors
|
||||
#define NOCOMM // - COMM driver routines
|
||||
#define NOCTLMGR // - Control and Dialog routines
|
||||
#define NODEFERWINDOWPOS // - DeferWindowPos routines
|
||||
#define NODRAWTEXT // - DrawText() and DT_*
|
||||
#define NOGDI // - All GDI defines and routines
|
||||
#define NOGDICAPMASKS // - CC_*, LC_*, PC_*, CP_*, TC_*, RC_
|
||||
#define NOHELP // - Help engine interface.
|
||||
#define NOICONS // - IDI_*
|
||||
#define NOKANJI // - Kanji support stuff.
|
||||
#define NOKEYSTATES // - MK_*
|
||||
#define NOKERNEL // - All KERNEL defines and routines
|
||||
#define NOMB // - MB_* and MessageBox()
|
||||
#define NOMCX // - Modem Configuration Extensions
|
||||
#define NOMENUS // - MF_*
|
||||
#define NOMEMMGR // - GMEM_*, LMEM_*, GHND, LHND, associated routines
|
||||
#define NOMETAFILE // - typedef METAFILEPICT
|
||||
//#define NOMINMAX // - Macros min(a,b) and max(a,b)
|
||||
#define NOMSG // - typedef MSG and associated routines
|
||||
//#define NONLS // - All NLS defines and routines
|
||||
#define NOOPENFILE // - OpenFile(), OemToAnsi, AnsiToOem, and OF_*
|
||||
#define NOPROFILER // - Profiler interface.
|
||||
#define NORASTEROPS // - Binary and Tertiary raster ops
|
||||
#define NOSCROLL // - SB_* and scrolling routines
|
||||
#define NOSERVICE // - All Service Controller routines, SERVICE_ equates, etc.
|
||||
#define NOSHOWWINDOW // - SW_*
|
||||
#define NOSOUND // - Sound driver routines
|
||||
#define NOSYSCOMMANDS // - SC_*
|
||||
#define NOSYSMETRICS // - SM_*
|
||||
#define NOTEXTMETRIC // - typedef TEXTMETRIC and associated routines
|
||||
#define NOUSER // - All USER defines and routines
|
||||
#define NOVIRTUALKEYCODES // - VK_*
|
||||
#define NOWH // - SetWindowsHook and WH_*
|
||||
#define NOWINOFFSETS // - GWL_*, GCL_*, associated routines
|
||||
#define NOWINMESSAGES // - WM_*, EM_*, LB_*, CB_*
|
||||
#define NOWINSTYLES // - WS_*, CS_*, ES_*, LBS_*, SBS_*, CBS_*
|
||||
#define WIN32_LEAN_AND_MEAN
|
||||
#define VC_EXTRALEAN
|
||||
#define NOATOM // Atom Manager routines
|
||||
#define NOBITMAP //
|
||||
#define NOCLIPBOARD // Clipboard routines
|
||||
#define NOCOLOR // Screen colors
|
||||
#define NOCOMM // COMM driver routines
|
||||
#define NOCTLMGR // Control and Dialog routines
|
||||
#define NODEFERWINDOWPOS // DeferWindowPos routines
|
||||
#define NODRAWTEXT // DrawText() and DT_*
|
||||
#define NOGDI // All GDI defines and routines
|
||||
#define NOGDICAPMASKS // CC_*, LC_*, PC_*, CP_*, TC_*, RC_
|
||||
#define NOHELP // Help engine interface.
|
||||
#define NOICONS // IDI_*
|
||||
#define NOKANJI // Kanji support stuff.
|
||||
#define NOKEYSTATES // MK_*
|
||||
#define NOKERNEL // All KERNEL defines and routines
|
||||
#define NOMB // MB_* and MessageBox()
|
||||
#define NOMCX // Modem Configuration Extensions
|
||||
#define NOMENUS // MF_*
|
||||
#define NOMEMMGR // GMEM_*, LMEM_*, GHND, LHND, associated routines
|
||||
#define NOMETAFILE // typedef METAFILEPICT
|
||||
#define NOMSG // typedef MSG and associated routines
|
||||
#define NOOPENFILE // OpenFile(), OemToAnsi, AnsiToOem, and OF_*
|
||||
#define NOPROFILER // Profiler interface.
|
||||
#define NORASTEROPS // Binary and Tertiary raster ops
|
||||
#define NOSCROLL // SB_* and scrolling routines
|
||||
#define NOSERVICE // All Service Controller routines, SERVICE_ equates, etc.
|
||||
#define NOSHOWWINDOW // SW_*
|
||||
#define NOSOUND // Sound driver routines
|
||||
#define NOSYSCOMMANDS // SC_*
|
||||
#define NOSYSMETRICS // SM_*
|
||||
#define NOTEXTMETRIC // typedef TEXTMETRIC and associated routines
|
||||
#define NOUSER // All USER defines and routines
|
||||
#define NOVIRTUALKEYCODES // VK_*
|
||||
#define NOWH // SetWindowsHook and WH_*
|
||||
#define NOWINOFFSETS // GWL_*, GCL_*, associated routines
|
||||
#define NOWINMESSAGES // WM_*, EM_*, LB_*, CB_*
|
||||
#define NOWINSTYLES // WS_*, CS_*, ES_*, LBS_*, SBS_*, CBS_*
|
||||
//#define NOMINMAX // Macros min(a,b) and max(a,b)
|
||||
//#define NONLS // All NLS defines and routines
|
||||
#endif
|
||||
|
||||
// test harness stuff
|
||||
#ifndef SHOULD_HAVE_FP16
|
||||
#define SHOULD_HAVE_FP16 0
|
||||
#define SHOULD_HAVE_FP16 0
|
||||
#endif
|
||||
#ifndef SHOULD_HAVE_FLOAT16
|
||||
#define SHOULD_HAVE_FLOAT16 0
|
||||
#define SHOULD_HAVE_FLOAT16 0
|
||||
#endif
|
||||
#ifndef SHOULD_HAVE_FLOAT128
|
||||
#define SHOULD_HAVE_FLOAT128 0
|
||||
#define SHOULD_HAVE_FLOAT128 0
|
||||
#endif
|
||||
#ifndef SHOULD_HAVE_INT128
|
||||
#define SHOULD_HAVE_INT128 0
|
||||
#define SHOULD_HAVE_INT128 0
|
||||
#endif
|
||||
#ifndef SHOULD_HAVE_EXCEPTIONS
|
||||
#define SHOULD_HAVE_EXCEPTIONS 1
|
||||
#define SHOULD_HAVE_EXCEPTIONS 1
|
||||
#endif
|
||||
|
||||
|
@ -5,14 +5,14 @@
|
||||
|
||||
#include "tests.h"
|
||||
|
||||
bool parsing_should_succeed(
|
||||
std::string_view test_file,
|
||||
bool parsing_should_succeed(std::string_view test_file,
|
||||
uint32_t test_line,
|
||||
std::string_view toml_str,
|
||||
pss_func&& func,
|
||||
std::string_view source_path)
|
||||
{
|
||||
INFO("["sv << test_file << ", line "sv << test_line << "] "sv << "parsing_should_succeed(\""sv << toml_str << "\")"sv)
|
||||
INFO("["sv << test_file << ", line "sv << test_line << "] "sv
|
||||
<< "parsing_should_succeed(\""sv << toml_str << "\")"sv)
|
||||
|
||||
constexpr auto validate_table = [](table&& tabl, std::string_view path) -> table&&
|
||||
{
|
||||
@ -29,7 +29,7 @@ bool parsing_should_succeed(
|
||||
return std::move(tabl);
|
||||
};
|
||||
|
||||
#if TOML_EXCEPTIONS
|
||||
#if TOML_EXCEPTIONS
|
||||
|
||||
try
|
||||
{
|
||||
@ -52,15 +52,12 @@ bool parsing_should_succeed(
|
||||
}
|
||||
catch (const parse_error& err)
|
||||
{
|
||||
FORCE_FAIL(
|
||||
"Parse error on line "sv << err.source().begin.line
|
||||
<< ", column "sv << err.source().begin.column
|
||||
<< ":\n"sv << err.description()
|
||||
);
|
||||
FORCE_FAIL("Parse error on line "sv << err.source().begin.line << ", column "sv << err.source().begin.column
|
||||
<< ":\n"sv << err.description());
|
||||
return false;
|
||||
}
|
||||
|
||||
#else
|
||||
#else
|
||||
|
||||
{
|
||||
INFO("Parsing string directly"sv)
|
||||
@ -74,11 +71,9 @@ bool parsing_should_succeed(
|
||||
}
|
||||
else
|
||||
{
|
||||
FORCE_FAIL(
|
||||
"Parse error on line "sv << result.error().source().begin.line
|
||||
<< ", column "sv << result.error().source().begin.column
|
||||
<< ":\n"sv << result.error().description()
|
||||
);
|
||||
FORCE_FAIL("Parse error on line "sv << result.error().source().begin.line << ", column "sv
|
||||
<< result.error().source().begin.column << ":\n"sv
|
||||
<< result.error().description());
|
||||
}
|
||||
}
|
||||
|
||||
@ -96,29 +91,27 @@ bool parsing_should_succeed(
|
||||
}
|
||||
else
|
||||
{
|
||||
FORCE_FAIL(
|
||||
"Parse error on line "sv << result.error().source().begin.line
|
||||
<< ", column "sv << result.error().source().begin.column
|
||||
<< ":\n"sv << result.error().description()
|
||||
);
|
||||
FORCE_FAIL("Parse error on line "sv << result.error().source().begin.line << ", column "sv
|
||||
<< result.error().source().begin.column << ":\n"sv
|
||||
<< result.error().description());
|
||||
}
|
||||
}
|
||||
|
||||
#endif
|
||||
#endif
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
bool parsing_should_fail(
|
||||
std::string_view test_file,
|
||||
bool parsing_should_fail(std::string_view test_file,
|
||||
uint32_t test_line,
|
||||
std::string_view toml_str,
|
||||
source_index expected_failure_line,
|
||||
source_index expected_failure_column)
|
||||
{
|
||||
INFO("["sv << test_file << ", line "sv << test_line << "] "sv << "parsing_should_fail(\""sv << toml_str << "\")"sv)
|
||||
INFO("["sv << test_file << ", line "sv << test_line << "] "sv
|
||||
<< "parsing_should_fail(\""sv << toml_str << "\")"sv)
|
||||
|
||||
#if TOML_EXCEPTIONS
|
||||
#if TOML_EXCEPTIONS
|
||||
|
||||
static constexpr auto run_tests = [](source_index ex_line, source_index ex_col, auto&& fn)
|
||||
{
|
||||
@ -130,17 +123,15 @@ bool parsing_should_fail(
|
||||
{
|
||||
if (ex_line != static_cast<source_index>(-1) && err.source().begin.line != ex_line)
|
||||
{
|
||||
FORCE_FAIL("Expected parse_error at line "sv << ex_line
|
||||
<< ", actually occured at line "sv << err.source().begin.line
|
||||
);
|
||||
FORCE_FAIL("Expected parse_error at line "sv << ex_line << ", actually occured at line "sv
|
||||
<< err.source().begin.line);
|
||||
return false;
|
||||
}
|
||||
|
||||
if (ex_col != static_cast<source_index>(-1) && err.source().begin.column != ex_col)
|
||||
{
|
||||
FORCE_FAIL("Expected parse_error at column "sv << ex_col
|
||||
<< ", actually occured at column "sv << err.source().begin.column
|
||||
);
|
||||
FORCE_FAIL("Expected parse_error at column "sv << ex_col << ", actually occured at column "sv
|
||||
<< err.source().begin.column);
|
||||
return false;
|
||||
}
|
||||
|
||||
@ -162,11 +153,13 @@ bool parsing_should_fail(
|
||||
return false;
|
||||
};
|
||||
|
||||
auto result = run_tests(expected_failure_line, expected_failure_column, [=]()
|
||||
{
|
||||
[[maybe_unused]] auto res = toml::parse(toml_str);
|
||||
});
|
||||
result = result && run_tests(expected_failure_line, expected_failure_column, [=]()
|
||||
auto result = run_tests(expected_failure_line,
|
||||
expected_failure_column,
|
||||
[=]() { [[maybe_unused]] auto res = toml::parse(toml_str); });
|
||||
result = result
|
||||
&& run_tests(expected_failure_line,
|
||||
expected_failure_column,
|
||||
[=]()
|
||||
{
|
||||
std::stringstream ss;
|
||||
ss.write(toml_str.data(), static_cast<std::streamsize>(toml_str.length()));
|
||||
@ -174,7 +167,7 @@ bool parsing_should_fail(
|
||||
});
|
||||
return result;
|
||||
|
||||
#else
|
||||
#else
|
||||
|
||||
static constexpr auto run_tests = [](source_index ex_line, source_index ex_col, auto&& fn)
|
||||
{
|
||||
@ -182,16 +175,14 @@ bool parsing_should_fail(
|
||||
{
|
||||
if (ex_line != static_cast<source_index>(-1) && result.error().source().begin.line != ex_line)
|
||||
{
|
||||
FORCE_FAIL("Expected parse_error at line "sv << ex_line
|
||||
<< ", actually occured at line "sv << result.error().source().begin.line
|
||||
);
|
||||
FORCE_FAIL("Expected parse_error at line "sv << ex_line << ", actually occured at line "sv
|
||||
<< result.error().source().begin.line);
|
||||
}
|
||||
|
||||
if (ex_col != static_cast<source_index>(-1) && result.error().source().begin.column != ex_col)
|
||||
{
|
||||
FORCE_FAIL("Expected parse_error at column "sv << ex_col
|
||||
<< ", actually occured at column "sv << result.error().source().begin.column
|
||||
);
|
||||
FORCE_FAIL("Expected parse_error at column "sv << ex_col << ", actually occured at column "sv
|
||||
<< result.error().source().begin.column);
|
||||
}
|
||||
|
||||
SUCCEED("parse_error generated OK"sv);
|
||||
@ -202,14 +193,16 @@ bool parsing_should_fail(
|
||||
};
|
||||
|
||||
return run_tests(expected_failure_line, expected_failure_column, [=]() { return toml::parse(toml_str); })
|
||||
&& run_tests(expected_failure_line, expected_failure_column, [=]()
|
||||
&& run_tests(expected_failure_line,
|
||||
expected_failure_column,
|
||||
[=]()
|
||||
{
|
||||
std::stringstream ss;
|
||||
ss.write(toml_str.data(), static_cast<std::streamsize>(toml_str.length()));
|
||||
return toml::parse(ss);
|
||||
});
|
||||
|
||||
#endif
|
||||
#endif
|
||||
}
|
||||
|
||||
template bool parse_expected_value(std::string_view, uint32_t, std::string_view, const int&);
|
||||
@ -227,8 +220,8 @@ namespace Catch
|
||||
{
|
||||
template struct StringMaker<node_view<node>>;
|
||||
template struct StringMaker<node_view<const node>>;
|
||||
template ReusableStringStream& ReusableStringStream::operator << (toml::node_view<toml::node> const&);
|
||||
template ReusableStringStream& ReusableStringStream::operator << (toml::node_view<const toml::node> const&);
|
||||
template ReusableStringStream& ReusableStringStream::operator<<(toml::node_view<toml::node> const&);
|
||||
template ReusableStringStream& ReusableStringStream::operator<<(toml::node_view<const toml::node> const&);
|
||||
namespace Detail
|
||||
{
|
||||
template std::string stringify(const node_view<node>&);
|
||||
|
@ -7,63 +7,73 @@
|
||||
#include "settings.h"
|
||||
|
||||
#if USE_TARTANLLAMA_OPTIONAL
|
||||
#include "tloptional.h"
|
||||
#include "lib_tloptional.h"
|
||||
#endif
|
||||
|
||||
#if USE_SINGLE_HEADER
|
||||
#include "../toml.hpp"
|
||||
#include "../toml.hpp"
|
||||
#else
|
||||
#include "../include/toml++/toml.h"
|
||||
#include "../include/toml++/toml.h"
|
||||
#endif
|
||||
#if defined(TOML_FP16) ^ SHOULD_HAVE_FP16
|
||||
#error TOML_FP16 was not deduced correctly
|
||||
#error TOML_FP16 was not deduced correctly
|
||||
#endif
|
||||
#if defined(TOML_FLOAT16) ^ SHOULD_HAVE_FLOAT16
|
||||
#error TOML_FLOAT16 was not deduced correctly
|
||||
#error TOML_FLOAT16 was not deduced correctly
|
||||
#endif
|
||||
#if defined(TOML_FLOAT128) ^ SHOULD_HAVE_FLOAT128
|
||||
#error TOML_FLOAT128 was not deduced correctly
|
||||
#error TOML_FLOAT128 was not deduced correctly
|
||||
#endif
|
||||
#if defined(TOML_INT128) ^ SHOULD_HAVE_INT128
|
||||
#error TOML_INT128 was not deduced correctly
|
||||
#error TOML_INT128 was not deduced correctly
|
||||
#endif
|
||||
#if defined(TOML_INT128) ^ defined(TOML_UINT128)
|
||||
#error TOML_INT128 and TOML_UINT128 must both be defined, or neither be defined
|
||||
#error TOML_INT128 and TOML_UINT128 must both be defined, or neither be defined
|
||||
#endif
|
||||
#if TOML_COMPILER_EXCEPTIONS != SHOULD_HAVE_EXCEPTIONS
|
||||
#error TOML_COMPILER_EXCEPTIONS was not deduced correctly
|
||||
#error TOML_COMPILER_EXCEPTIONS was not deduced correctly
|
||||
#endif
|
||||
#if TOML_COMPILER_EXCEPTIONS != TOML_EXCEPTIONS
|
||||
#error TOML_EXCEPTIONS does not match TOML_COMPILER_EXCEPTIONS (default behaviour should be to match)
|
||||
#error TOML_EXCEPTIONS does not match TOML_COMPILER_EXCEPTIONS (default behaviour should be to match)
|
||||
#endif
|
||||
#if (defined(_WIN32) && !TOML_WINDOWS_COMPAT) || (!defined(_WIN32) && TOML_WINDOWS_COMPAT)
|
||||
#error TOML_WINDOWS_COMPAT does not match _WIN32 (default behaviour should be to match)
|
||||
#error TOML_WINDOWS_COMPAT does not match _WIN32 (default behaviour should be to match)
|
||||
#endif
|
||||
|
||||
#if TOML_ICC
|
||||
#define UNICODE_LITERALS_OK 0
|
||||
#define UNICODE_LITERALS_OK 0
|
||||
#else
|
||||
#define UNICODE_LITERALS_OK 1
|
||||
#define UNICODE_LITERALS_OK 1
|
||||
#endif
|
||||
|
||||
TOML_DISABLE_SPAM_WARNINGS;
|
||||
TOML_DISABLE_ARITHMETIC_WARNINGS;
|
||||
|
||||
TOML_DISABLE_WARNINGS;
|
||||
#include "catch2.h"
|
||||
#include "lib_catch2.h"
|
||||
#include <sstream>
|
||||
namespace toml {}
|
||||
namespace toml
|
||||
{
|
||||
}
|
||||
using namespace Catch::literals;
|
||||
using namespace toml;
|
||||
TOML_ENABLE_WARNINGS;
|
||||
|
||||
TOML_NODISCARD
|
||||
TOML_ATTR(const)
|
||||
TOML_ALWAYS_INLINE
|
||||
constexpr size_t operator"" _sz(unsigned long long n) noexcept
|
||||
{
|
||||
return static_cast<size_t>(n);
|
||||
}
|
||||
|
||||
#define FILE_LINE_ARGS std::string_view{ __FILE__ }, __LINE__
|
||||
#define BOM_PREFIX "\xEF\xBB\xBF"
|
||||
|
||||
#if TOML_EXCEPTIONS
|
||||
#define FORCE_FAIL(...) FAIL(__VA_ARGS__)
|
||||
#define FORCE_FAIL(...) FAIL(__VA_ARGS__)
|
||||
#else
|
||||
#define FORCE_FAIL(...) \
|
||||
#define FORCE_FAIL(...) \
|
||||
do \
|
||||
{ \
|
||||
FAIL(__VA_ARGS__); \
|
||||
@ -74,8 +84,8 @@ TOML_ENABLE_WARNINGS;
|
||||
#endif
|
||||
|
||||
#define CHECK_SYMMETRIC_RELOP(lhs, op, rhs, result) \
|
||||
CHECK(((lhs) op (rhs)) == (result)); \
|
||||
CHECK(((rhs) op (lhs)) == (result))
|
||||
CHECK(((lhs)op(rhs)) == (result)); \
|
||||
CHECK(((rhs)op(lhs)) == (result))
|
||||
|
||||
#define CHECK_SYMMETRIC_EQUAL(lhs, rhs) \
|
||||
CHECK_SYMMETRIC_RELOP(lhs, ==, rhs, true); \
|
||||
@ -99,17 +109,13 @@ class function_view<R(P...)> final
|
||||
mutable eraser_func_type* eraser = {};
|
||||
|
||||
public:
|
||||
|
||||
function_view() noexcept = default;
|
||||
|
||||
template <typename T>
|
||||
function_view(T&& x) noexcept
|
||||
: ptr_{ reinterpret_cast<void*>(std::addressof(x)) }
|
||||
function_view(T&& x) noexcept : ptr_{ reinterpret_cast<void*>(std::addressof(x)) }
|
||||
{
|
||||
eraser = [](void* ptr, P&&... xs) -> R
|
||||
{
|
||||
return (*reinterpret_cast<std::add_pointer_t<std::remove_reference_t<T>>>(ptr))(std::forward<P>(xs)...);
|
||||
};
|
||||
{ return (*reinterpret_cast<std::add_pointer_t<std::remove_reference_t<T>>>(ptr))(std::forward<P>(xs)...); };
|
||||
}
|
||||
|
||||
decltype(auto) operator()(P&&... xs) const
|
||||
@ -117,33 +123,35 @@ class function_view<R(P...)> final
|
||||
return eraser(ptr_, std::forward<P>(xs)...);
|
||||
}
|
||||
|
||||
[[nodiscard]] operator bool() const noexcept { return !!ptr_; }
|
||||
TOML_NODISCARD
|
||||
operator bool() const noexcept
|
||||
{
|
||||
return !!ptr_;
|
||||
}
|
||||
};
|
||||
|
||||
using pss_func = function_view<void(toml::table&&)>;
|
||||
|
||||
bool parsing_should_succeed(
|
||||
std::string_view test_file,
|
||||
bool parsing_should_succeed(std::string_view test_file,
|
||||
uint32_t test_line,
|
||||
std::string_view toml_str,
|
||||
pss_func&& func = {},
|
||||
std::string_view source_path = {});
|
||||
|
||||
bool parsing_should_fail(
|
||||
std::string_view test_file,
|
||||
bool parsing_should_fail(std::string_view test_file,
|
||||
uint32_t test_line,
|
||||
std::string_view toml_str,
|
||||
source_index expected_failure_line = static_cast<source_index>(-1),
|
||||
source_index expected_failure_column = static_cast<source_index>(-1));
|
||||
|
||||
template <typename T>
|
||||
inline bool parse_expected_value(
|
||||
std::string_view test_file,
|
||||
inline bool parse_expected_value(std::string_view test_file,
|
||||
uint32_t test_line,
|
||||
std::string_view value_str,
|
||||
const T& expected)
|
||||
{
|
||||
INFO("["sv << test_file << ", line "sv << test_line << "] "sv << "parse_expected_value(\""sv << value_str << "\")"sv)
|
||||
INFO("["sv << test_file << ", line "sv << test_line << "] "sv
|
||||
<< "parse_expected_value(\""sv << value_str << "\")"sv)
|
||||
|
||||
std::string val;
|
||||
static constexpr auto key = "val = "sv;
|
||||
@ -196,7 +204,8 @@ inline bool parse_expected_value(
|
||||
using value_type = impl::native_type_of<impl::remove_cvref_t<T>>;
|
||||
value<value_type> val_parsed;
|
||||
{
|
||||
INFO("["sv << test_file << ", line "sv << test_line << "] "sv << "parse_expected_value: Checking initial parse"sv)
|
||||
INFO("["sv << test_file << ", line "sv << test_line << "] "sv
|
||||
<< "parse_expected_value: Checking initial parse"sv)
|
||||
|
||||
bool stolen_value = false; // parsing_should_succeed invokes the functor more than once
|
||||
const auto result = parsing_should_succeed(
|
||||
@ -313,8 +322,7 @@ inline bool parse_expected_value(
|
||||
val_parsed = std::move(*nv.as<value_type>());
|
||||
stolen_value = true;
|
||||
}
|
||||
}
|
||||
);
|
||||
});
|
||||
|
||||
if (!result)
|
||||
return false;
|
||||
@ -322,7 +330,8 @@ inline bool parse_expected_value(
|
||||
|
||||
// check round-tripping
|
||||
{
|
||||
INFO("["sv << test_file << ", line "sv << test_line << "] "sv << "parse_expected_value: Checking round-trip"sv)
|
||||
INFO("["sv << test_file << ", line "sv << test_line << "] "sv
|
||||
<< "parse_expected_value: Checking round-trip"sv)
|
||||
{
|
||||
std::string str;
|
||||
{
|
||||
@ -333,8 +342,8 @@ inline bool parse_expected_value(
|
||||
}
|
||||
|
||||
bool value_ok = true;
|
||||
const auto parse_ok = parsing_should_succeed(
|
||||
test_file,
|
||||
const auto parse_ok =
|
||||
parsing_should_succeed(test_file,
|
||||
test_line,
|
||||
std::string_view{ str },
|
||||
[&](table&& tbl)
|
||||
@ -350,8 +359,7 @@ inline bool parse_expected_value(
|
||||
value_ok = false;
|
||||
FORCE_FAIL("Value was not the same after round-tripping"sv);
|
||||
}
|
||||
}
|
||||
);
|
||||
});
|
||||
|
||||
if (!parse_ok || value_ok)
|
||||
return false;
|
||||
@ -377,8 +385,8 @@ namespace Catch
|
||||
{
|
||||
extern template struct StringMaker<node_view<node>>;
|
||||
extern template struct StringMaker<node_view<const node>>;
|
||||
extern template ReusableStringStream& ReusableStringStream::operator << (node_view<node> const&);
|
||||
extern template ReusableStringStream& ReusableStringStream::operator << (node_view<const node> const&);
|
||||
extern template ReusableStringStream& ReusableStringStream::operator<<(node_view<node> const&);
|
||||
extern template ReusableStringStream& ReusableStringStream::operator<<(node_view<const node> const&);
|
||||
namespace Detail
|
||||
{
|
||||
extern template std::string stringify(const node_view<node>&);
|
||||
|
@ -6,24 +6,16 @@
|
||||
#include "tests.h"
|
||||
using namespace toml::impl;
|
||||
|
||||
using func_type = bool(char32_t)noexcept;
|
||||
inline constexpr func_type* funcs[] =
|
||||
{
|
||||
using func_type = bool(char32_t) noexcept;
|
||||
inline constexpr func_type* funcs[] = {
|
||||
// these must be mutually-exclusive
|
||||
|
||||
impl::is_ascii_letter,
|
||||
impl::is_ascii_whitespace,
|
||||
impl::is_ascii_line_break<true>,
|
||||
impl::is_decimal_digit,
|
||||
impl::is_string_delimiter,
|
||||
impl::is_non_ascii_whitespace,
|
||||
impl::is_non_ascii_line_break,
|
||||
impl::is_unicode_surrogate,
|
||||
#if TOML_LANG_UNRELEASED
|
||||
impl::is_non_ascii_letter,
|
||||
impl::is_non_ascii_number,
|
||||
impl::is_combining_mark,
|
||||
#endif
|
||||
impl::is_ascii_letter, impl::is_ascii_whitespace, impl::is_ascii_line_break<true>,
|
||||
impl::is_decimal_digit, impl::is_string_delimiter, impl::is_non_ascii_whitespace,
|
||||
impl::is_non_ascii_line_break, impl::is_unicode_surrogate,
|
||||
#if TOML_LANG_UNRELEASED
|
||||
impl::is_non_ascii_letter, impl::is_non_ascii_number, impl::is_combining_mark,
|
||||
#endif
|
||||
};
|
||||
|
||||
template <typename T>
|
||||
@ -60,9 +52,7 @@ struct codepoint_range
|
||||
|
||||
template <typename T>
|
||||
TOML_NODISCARD_CTOR
|
||||
constexpr codepoint_range(T first_) noexcept
|
||||
: first{ static_cast<char32_t>(first_) },
|
||||
last{ first }
|
||||
constexpr codepoint_range(T first_) noexcept : first{ static_cast<char32_t>(first_) }, last{ first }
|
||||
{}
|
||||
};
|
||||
|
||||
@ -104,9 +94,9 @@ TEST_CASE("unicode - is_ascii_whitespace")
|
||||
{
|
||||
static constexpr auto fn = is_ascii_whitespace;
|
||||
REQUIRE(not_in(fn, { U'\0', U'\u0008' }));
|
||||
REQUIRE(in_only(fn, U'\t' ));
|
||||
REQUIRE(in_only(fn, U'\t'));
|
||||
REQUIRE(not_in(fn, { U'\n', U'\u001F' }));
|
||||
REQUIRE(in_only(fn, U' ' ));
|
||||
REQUIRE(in_only(fn, U' '));
|
||||
REQUIRE(not_in(fn, { U'!', unimax }));
|
||||
}
|
||||
|
||||
@ -172,9 +162,9 @@ TEST_CASE("unicode - is_string_delimiter")
|
||||
{
|
||||
static constexpr auto fn = is_string_delimiter;
|
||||
REQUIRE(not_in(fn, { U'\0', U'!' }));
|
||||
REQUIRE(in_only(fn, U'"' ));
|
||||
REQUIRE(in_only(fn, U'"'));
|
||||
REQUIRE(not_in(fn, { U'#', U'&' }));
|
||||
REQUIRE(in_only(fn, U'\'' ));
|
||||
REQUIRE(in_only(fn, U'\''));
|
||||
REQUIRE(not_in(fn, { U'(', unimax }));
|
||||
}
|
||||
|
||||
@ -182,17 +172,17 @@ TEST_CASE("unicode - is_non_ascii_whitespace")
|
||||
{
|
||||
static constexpr auto fn = is_non_ascii_whitespace;
|
||||
REQUIRE(not_in(fn, { U'\0', U'\u009F' }));
|
||||
REQUIRE(in_only(fn, U'\u00A0' ));
|
||||
REQUIRE(in_only(fn, U'\u00A0'));
|
||||
REQUIRE(not_in(fn, { U'\u00A1', U'\u167F' }));
|
||||
REQUIRE(in_only(fn, U'\u1680' ));
|
||||
REQUIRE(in_only(fn, U'\u1680'));
|
||||
REQUIRE(not_in(fn, { U'\u1681', U'\u1FFF' }));
|
||||
REQUIRE(in_only(fn, { U'\u2000', U'\u200A' }));
|
||||
REQUIRE(not_in(fn, { U'\u200B', U'\u202E' }));
|
||||
REQUIRE(in_only(fn, U'\u202F' ));
|
||||
REQUIRE(in_only(fn, U'\u202F'));
|
||||
REQUIRE(not_in(fn, { U'\u2030', U'\u205E' }));
|
||||
REQUIRE(in_only(fn, U'\u205F' ));
|
||||
REQUIRE(in_only(fn, U'\u205F'));
|
||||
REQUIRE(not_in(fn, { U'\u2060', U'\u2FFF' }));
|
||||
REQUIRE(in_only(fn, U'\u3000' ));
|
||||
REQUIRE(in_only(fn, U'\u3000'));
|
||||
REQUIRE(not_in(fn, { U'\u3001', unimax }));
|
||||
}
|
||||
|
||||
@ -200,7 +190,7 @@ TEST_CASE("unicode - is_non_ascii_line_break")
|
||||
{
|
||||
static constexpr auto fn = is_non_ascii_line_break;
|
||||
REQUIRE(not_in(fn, { U'\0', U'\u0084' }));
|
||||
REQUIRE(in_only(fn, U'\u0085' ));
|
||||
REQUIRE(in_only(fn, U'\u0085'));
|
||||
REQUIRE(not_in(fn, { U'\u0086', U'\u2027' }));
|
||||
REQUIRE(in_only(fn, { U'\u2028', U'\u2029' }));
|
||||
REQUIRE(not_in(fn, { U'\u202A', unimax }));
|
||||
|
@ -13,17 +13,12 @@ TEST_CASE("user feedback")
|
||||
{
|
||||
toml::table t1;
|
||||
t1.insert_or_assign("bar1", toml::array{ 1, 2, 3 });
|
||||
CHECK(t1 == toml::table{{
|
||||
{ "bar1"sv, toml::array{ 1, 2, 3 } }
|
||||
}});
|
||||
CHECK(t1 == toml::table{ { { "bar1"sv, toml::array{ 1, 2, 3 } } } });
|
||||
|
||||
t1.insert_or_assign("foo1", *t1.get("bar1"));
|
||||
CHECK(t1 == toml::table{{
|
||||
{ "bar1"sv, toml::array{ 1, 2, 3 } },
|
||||
{ "foo1"sv, toml::array{ 1, 2, 3 } }
|
||||
}});
|
||||
CHECK(t1 == toml::table{ { { "bar1"sv, toml::array{ 1, 2, 3 } }, { "foo1"sv, toml::array{ 1, 2, 3 } } } });
|
||||
|
||||
//t1["foo1"] = t1["bar1"]; // does nothing, should this fail to compile?
|
||||
// t1["foo1"] = t1["bar1"]; // does nothing, should this fail to compile?
|
||||
// - yes -
|
||||
|
||||
//*t1["foo1"].node() = *t1["bar1"].node(); // compile failure; copying node_view would be a bad thing
|
||||
@ -31,59 +26,51 @@ TEST_CASE("user feedback")
|
||||
|
||||
toml::array* array1 = t1["foo1"].node()->as_array();
|
||||
array1->push_back(4);
|
||||
CHECK(t1 == toml::table{{
|
||||
{ "bar1"sv, toml::array{ 1, 2, 3 } },
|
||||
{ "foo1"sv, toml::array{ 1, 2, 3, 4 } }
|
||||
}});
|
||||
CHECK(t1 == toml::table{ { { "bar1"sv, toml::array{ 1, 2, 3 } }, { "foo1"sv, toml::array{ 1, 2, 3, 4 } } } });
|
||||
|
||||
t1.insert_or_assign("foo3", t1["foo1"]);
|
||||
CHECK(t1 == toml::table{{
|
||||
{ "bar1"sv, toml::array{ 1, 2, 3 } },
|
||||
CHECK(t1
|
||||
== toml::table{ { { "bar1"sv, toml::array{ 1, 2, 3 } },
|
||||
{ "foo1"sv, toml::array{ 1, 2, 3, 4 } },
|
||||
{ "foo3"sv, toml::array{ 1, 2, 3, 4 } }
|
||||
}});
|
||||
{ "foo3"sv, toml::array{ 1, 2, 3, 4 } } } });
|
||||
|
||||
t1.insert_or_assign("foo2", *t1["foo1"].node());
|
||||
CHECK(t1 == toml::table{{
|
||||
{ "bar1"sv, toml::array{ 1, 2, 3 } },
|
||||
CHECK(t1
|
||||
== toml::table{ { { "bar1"sv, toml::array{ 1, 2, 3 } },
|
||||
{ "foo1"sv, toml::array{ 1, 2, 3, 4 } },
|
||||
{ "foo2"sv, toml::array{ 1, 2, 3, 4 } },
|
||||
{ "foo3"sv, toml::array{ 1, 2, 3, 4 } }
|
||||
}});
|
||||
{ "foo3"sv, toml::array{ 1, 2, 3, 4 } } } });
|
||||
|
||||
toml::array* array2 = t1["foo2"].node()->as_array();
|
||||
array2->push_back("wrench");
|
||||
CHECK(t1 == toml::table{{
|
||||
{ "bar1"sv, toml::array{ 1, 2, 3 } },
|
||||
CHECK(t1
|
||||
== toml::table{ { { "bar1"sv, toml::array{ 1, 2, 3 } },
|
||||
{ "foo1"sv, toml::array{ 1, 2, 3, 4 } },
|
||||
{ "foo2"sv, toml::array{ 1, 2, 3, 4, "wrench" } },
|
||||
{ "foo3"sv, toml::array{ 1, 2, 3, 4 } }
|
||||
}});
|
||||
{ "foo3"sv, toml::array{ 1, 2, 3, 4 } } } });
|
||||
|
||||
toml::table t2 = t1;
|
||||
CHECK(t2 == t1);
|
||||
CHECK(&t2 != &t1);
|
||||
|
||||
//t2.emplace("bar", toml::array{6, 7}); // fails to compile? not sure what I did wrong
|
||||
// t2.emplace("bar", toml::array{6, 7}); // fails to compile? not sure what I did wrong
|
||||
// - it should be this: -
|
||||
t2.emplace<toml::array>("bar", 6, 7);
|
||||
CHECK(t2 == toml::table{{
|
||||
{ "bar"sv, toml::array{ 6, 7 } },
|
||||
CHECK(t2
|
||||
== toml::table{ { { "bar"sv, toml::array{ 6, 7 } },
|
||||
{ "bar1"sv, toml::array{ 1, 2, 3 } },
|
||||
{ "foo1"sv, toml::array{ 1, 2, 3, 4 } },
|
||||
{ "foo2"sv, toml::array{ 1, 2, 3, 4, "wrench" } },
|
||||
{ "foo3"sv, toml::array{ 1, 2, 3, 4 } }
|
||||
}});
|
||||
{ "foo3"sv, toml::array{ 1, 2, 3, 4 } } } });
|
||||
|
||||
t2.insert_or_assign("bar2", toml::array{ 6, 7 });
|
||||
CHECK(t2 == toml::table{{
|
||||
{ "bar"sv, toml::array{ 6, 7 } },
|
||||
CHECK(t2
|
||||
== toml::table{ { { "bar"sv, toml::array{ 6, 7 } },
|
||||
{ "bar1"sv, toml::array{ 1, 2, 3 } },
|
||||
{ "bar2"sv, toml::array{ 6, 7 } },
|
||||
{ "foo1"sv, toml::array{ 1, 2, 3, 4 } },
|
||||
{ "foo2"sv, toml::array{ 1, 2, 3, 4, "wrench" } },
|
||||
{ "foo3"sv, toml::array{ 1, 2, 3, 4 } }
|
||||
}});
|
||||
{ "foo3"sv, toml::array{ 1, 2, 3, 4 } } } });
|
||||
}
|
||||
|
||||
SECTION("github/issues/65") // https://github.com/marzer/tomlplusplus/issues/65
|
||||
@ -98,23 +85,26 @@ TEST_CASE("user feedback")
|
||||
parsing_should_fail(FILE_LINE_ARGS, "#\xf1\x63");
|
||||
parsing_should_fail(FILE_LINE_ARGS, "1= 0x6cA#+\xf1");
|
||||
parsing_should_fail(FILE_LINE_ARGS, "p=06:06:06#\x0b\xff");
|
||||
parsing_should_fail(FILE_LINE_ARGS, "''''d' 't' '+o\x0c\x0c\x0c\x0c\x0c\x0c\x0c\x0c\x0c\x0c\x0c\x0c"
|
||||
parsing_should_fail(
|
||||
FILE_LINE_ARGS,
|
||||
"''''d' 't' '+o\x0c\x0c\x0c\x0c\x0c\x0c\x0c\x0c\x0c\x0c\x0c\x0c"
|
||||
"\x0c\x0c\x0c\x0c\x0c\r\x0c\x0c\x0c\x0c\x0c\x0c\x0c\x0c\x0c\x0c\x0c\x0c\x0c\x0c\x0c\x0c\x0c\x0c"
|
||||
"\x0c\x0c\x0c\x0c\x0c\x0c\x0c\x0c\x0c\x0c\x0c\x0c\x0c\x0c\x0c\x0c\x0c\x0c\x0c\x0c\x0c\x0c\x0c"
|
||||
"\x0c\x0c\x0c\x0c\x0c\x0c\x0cop1\x0c\x0c\x0c\x0c\x0c\x0c\x0c\x0c\x0c\x0c\x0c\x0c\x0c\x0c\x0c\x0c"
|
||||
"\x0c\x0c\x0c\x0c\x0c\x0c\x0c\x0c\x0c\x0c\x0c\x0c\x0c\x0c\x0c\x0c\x0c\x0c\x0c\x0c\x0c\x0c\x0c\x0c"
|
||||
"\x0c\x0c\x0c\x0c\x0c\x0c\x0c\x0c\x0c\x0c' 'ml'\n\n%\x87"
|
||||
);
|
||||
parsing_should_fail(FILE_LINE_ARGS,
|
||||
R"(t =[ 9, 2, 1,"r", 9999999999999999999999999999999999999999999999999999999999999995.0 ])"
|
||||
);
|
||||
"\x0c\x0c\x0c\x0c\x0c\x0c\x0c\x0c\x0c\x0c' 'ml'\n\n%\x87");
|
||||
parsing_should_fail(
|
||||
FILE_LINE_ARGS,
|
||||
R"(t =[ 9, 2, 1,"r", 9999999999999999999999999999999999999999999999999999999999999995.0 ])");
|
||||
}
|
||||
|
||||
SECTION("github/issues/67") // https://github.com/marzer/tomlplusplus/issues/67
|
||||
{
|
||||
const auto data = R"(array=["v1", "v2", "v3"])"sv;
|
||||
|
||||
parsing_should_succeed(FILE_LINE_ARGS, data, [](auto&& table)
|
||||
parsing_should_succeed(FILE_LINE_ARGS,
|
||||
data,
|
||||
[](auto&& table)
|
||||
{
|
||||
auto arr = table["array"].as_array();
|
||||
for (auto it = arr->cbegin(); it != arr->cend();)
|
||||
@ -129,7 +119,9 @@ TEST_CASE("user feedback")
|
||||
SECTION("github/issues/68") // https://github.com/marzer/tomlplusplus/issues/68
|
||||
{
|
||||
const auto data = R"(array=["v1", "v2", "v3"])"sv;
|
||||
parsing_should_succeed(FILE_LINE_ARGS, data, [](auto&& table)
|
||||
parsing_should_succeed(FILE_LINE_ARGS,
|
||||
data,
|
||||
[](auto&& table)
|
||||
{
|
||||
std::stringstream ss;
|
||||
ss << table;
|
||||
@ -151,7 +143,9 @@ TEST_CASE("user feedback")
|
||||
[[c]] # array-of-tables with a single, empty table element
|
||||
)"sv;
|
||||
|
||||
parsing_should_succeed(FILE_LINE_ARGS, data, [](auto&& table)
|
||||
parsing_should_succeed(FILE_LINE_ARGS,
|
||||
data,
|
||||
[](auto&& table)
|
||||
{
|
||||
std::stringstream ss;
|
||||
ss << table;
|
||||
@ -178,22 +172,24 @@ b = []
|
||||
|
||||
SECTION("github/issues/112") // https://github.com/marzer/tomlplusplus/issues/112
|
||||
{
|
||||
parsing_should_fail(FILE_LINE_ARGS, R"(
|
||||
parsing_should_fail(FILE_LINE_ARGS,
|
||||
R"(
|
||||
[a.b.c.d]
|
||||
u = 6
|
||||
[a]
|
||||
b.t = 8
|
||||
[a.b] # should cause redefinition error here
|
||||
u = 0
|
||||
)", 6);
|
||||
)",
|
||||
6);
|
||||
|
||||
parsing_should_fail(FILE_LINE_ARGS, R"(
|
||||
parsing_should_fail(FILE_LINE_ARGS,
|
||||
R"(
|
||||
[a]
|
||||
b.t = 8
|
||||
[a.b] # should cause redefinition error here
|
||||
u = 0
|
||||
)", 4);
|
||||
)",
|
||||
4);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
@ -9,17 +9,19 @@ TEST_CASE("using iterators")
|
||||
constexpr auto data = R"(array=[1,"Foo",true]
|
||||
string="Bar"
|
||||
number=5)"sv;
|
||||
parsing_should_succeed(FILE_LINE_ARGS, data, [](auto&& table)
|
||||
parsing_should_succeed(
|
||||
FILE_LINE_ARGS,
|
||||
data,
|
||||
[](auto&& table)
|
||||
{
|
||||
const auto table_begin = table.begin();
|
||||
const auto table_end = table.end();
|
||||
|
||||
auto count_table_lambda = [table_begin, table_end](node_type type) noexcept
|
||||
{
|
||||
return std::count_if(table_begin, table_end, [type](const auto& pair) noexcept
|
||||
{
|
||||
return pair.second.type() == type;
|
||||
});
|
||||
return std::count_if(table_begin,
|
||||
table_end,
|
||||
[type](const auto& pair) noexcept { return pair.second.type() == type; });
|
||||
};
|
||||
|
||||
CHECK(std::distance(table_begin, table_end) == 3);
|
||||
@ -28,22 +30,18 @@ number=5)"sv;
|
||||
CHECK(count_table_lambda(node_type::string) == 1);
|
||||
CHECK(std::next(table_begin, 3) == table_end);
|
||||
|
||||
const auto array_iter = std::find_if(table_begin, table_end, [](const auto& pair) noexcept
|
||||
{
|
||||
return pair.second.is_array();
|
||||
});
|
||||
const auto array_iter =
|
||||
std::find_if(table_begin, table_end, [](const auto& pair) noexcept { return pair.second.is_array(); });
|
||||
|
||||
REQUIRE(array_iter != table_end);
|
||||
const auto& array = array_iter->second.as_array();
|
||||
const auto array_begin = array->begin();
|
||||
const auto array_end = array->end();
|
||||
|
||||
auto count_array_lambda = [array_begin, array_end](node_type type) noexcept
|
||||
{
|
||||
return std::count_if(array_begin, array_end, [type](const auto& node) noexcept
|
||||
{
|
||||
return node.type() == type;
|
||||
});
|
||||
auto count_array_lambda = [array_begin, array_end](node_type type) noexcept {
|
||||
return std::count_if(array_begin,
|
||||
array_end,
|
||||
[type](const auto& node) noexcept { return node.type() == type; });
|
||||
};
|
||||
|
||||
CHECK(std::distance(array_begin, array_end) == 3);
|
||||
|
@ -108,11 +108,11 @@
|
||||
<Natvis Include="..\..\toml++.natvis" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ClInclude Include="..\catch2.h" />
|
||||
<ClInclude Include="..\leakproof.h" />
|
||||
<ClInclude Include="..\lib_catch2.h" />
|
||||
<ClInclude Include="..\lib_tloptional.h" />
|
||||
<ClInclude Include="..\settings.h" />
|
||||
<ClInclude Include="..\tests.h" />
|
||||
<ClInclude Include="..\tloptional.h" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<None Include="..\cpp.hint" />
|
||||
|
@ -108,11 +108,11 @@
|
||||
<Natvis Include="..\..\toml++.natvis" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ClInclude Include="..\catch2.h" />
|
||||
<ClInclude Include="..\leakproof.h" />
|
||||
<ClInclude Include="..\lib_catch2.h" />
|
||||
<ClInclude Include="..\lib_tloptional.h" />
|
||||
<ClInclude Include="..\settings.h" />
|
||||
<ClInclude Include="..\tests.h" />
|
||||
<ClInclude Include="..\tloptional.h" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<None Include="..\cpp.hint" />
|
||||
|
@ -108,11 +108,11 @@
|
||||
<Natvis Include="..\..\toml++.natvis" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ClInclude Include="..\catch2.h" />
|
||||
<ClInclude Include="..\leakproof.h" />
|
||||
<ClInclude Include="..\lib_catch2.h" />
|
||||
<ClInclude Include="..\lib_tloptional.h" />
|
||||
<ClInclude Include="..\settings.h" />
|
||||
<ClInclude Include="..\tests.h" />
|
||||
<ClInclude Include="..\tloptional.h" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<None Include="..\cpp.hint" />
|
||||
|
@ -108,11 +108,11 @@
|
||||
<Natvis Include="..\..\toml++.natvis" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ClInclude Include="..\catch2.h" />
|
||||
<ClInclude Include="..\leakproof.h" />
|
||||
<ClInclude Include="..\lib_catch2.h" />
|
||||
<ClInclude Include="..\lib_tloptional.h" />
|
||||
<ClInclude Include="..\settings.h" />
|
||||
<ClInclude Include="..\tests.h" />
|
||||
<ClInclude Include="..\tloptional.h" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<None Include="..\cpp.hint" />
|
||||
|
@ -108,11 +108,11 @@
|
||||
<Natvis Include="..\..\toml++.natvis" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ClInclude Include="..\catch2.h" />
|
||||
<ClInclude Include="..\leakproof.h" />
|
||||
<ClInclude Include="..\lib_catch2.h" />
|
||||
<ClInclude Include="..\lib_tloptional.h" />
|
||||
<ClInclude Include="..\settings.h" />
|
||||
<ClInclude Include="..\tests.h" />
|
||||
<ClInclude Include="..\tloptional.h" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<None Include="..\cpp.hint" />
|
||||
|
@ -108,11 +108,11 @@
|
||||
<Natvis Include="..\..\toml++.natvis" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ClInclude Include="..\catch2.h" />
|
||||
<ClInclude Include="..\leakproof.h" />
|
||||
<ClInclude Include="..\lib_catch2.h" />
|
||||
<ClInclude Include="..\lib_tloptional.h" />
|
||||
<ClInclude Include="..\settings.h" />
|
||||
<ClInclude Include="..\tests.h" />
|
||||
<ClInclude Include="..\tloptional.h" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<None Include="..\cpp.hint" />
|
||||
|
@ -108,11 +108,11 @@
|
||||
<Natvis Include="..\..\toml++.natvis" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ClInclude Include="..\catch2.h" />
|
||||
<ClInclude Include="..\leakproof.h" />
|
||||
<ClInclude Include="..\lib_catch2.h" />
|
||||
<ClInclude Include="..\lib_tloptional.h" />
|
||||
<ClInclude Include="..\settings.h" />
|
||||
<ClInclude Include="..\tests.h" />
|
||||
<ClInclude Include="..\tloptional.h" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<None Include="..\cpp.hint" />
|
||||
|
@ -108,11 +108,11 @@
|
||||
<Natvis Include="..\..\toml++.natvis" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ClInclude Include="..\catch2.h" />
|
||||
<ClInclude Include="..\leakproof.h" />
|
||||
<ClInclude Include="..\lib_catch2.h" />
|
||||
<ClInclude Include="..\lib_tloptional.h" />
|
||||
<ClInclude Include="..\settings.h" />
|
||||
<ClInclude Include="..\tests.h" />
|
||||
<ClInclude Include="..\tloptional.h" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<None Include="..\cpp.hint" />
|
||||
|
@ -108,11 +108,11 @@
|
||||
<Natvis Include="..\..\toml++.natvis" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ClInclude Include="..\catch2.h" />
|
||||
<ClInclude Include="..\leakproof.h" />
|
||||
<ClInclude Include="..\lib_catch2.h" />
|
||||
<ClInclude Include="..\lib_tloptional.h" />
|
||||
<ClInclude Include="..\settings.h" />
|
||||
<ClInclude Include="..\tests.h" />
|
||||
<ClInclude Include="..\tloptional.h" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<None Include="..\cpp.hint" />
|
||||
|
@ -108,11 +108,11 @@
|
||||
<Natvis Include="..\..\toml++.natvis" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ClInclude Include="..\catch2.h" />
|
||||
<ClInclude Include="..\leakproof.h" />
|
||||
<ClInclude Include="..\lib_catch2.h" />
|
||||
<ClInclude Include="..\lib_tloptional.h" />
|
||||
<ClInclude Include="..\settings.h" />
|
||||
<ClInclude Include="..\tests.h" />
|
||||
<ClInclude Include="..\tloptional.h" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<None Include="..\cpp.hint" />
|
||||
|
@ -108,11 +108,11 @@
|
||||
<Natvis Include="..\..\toml++.natvis" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ClInclude Include="..\catch2.h" />
|
||||
<ClInclude Include="..\leakproof.h" />
|
||||
<ClInclude Include="..\lib_catch2.h" />
|
||||
<ClInclude Include="..\lib_tloptional.h" />
|
||||
<ClInclude Include="..\settings.h" />
|
||||
<ClInclude Include="..\tests.h" />
|
||||
<ClInclude Include="..\tloptional.h" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<None Include="..\cpp.hint" />
|
||||
|
@ -108,11 +108,11 @@
|
||||
<Natvis Include="..\..\toml++.natvis" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ClInclude Include="..\catch2.h" />
|
||||
<ClInclude Include="..\leakproof.h" />
|
||||
<ClInclude Include="..\lib_catch2.h" />
|
||||
<ClInclude Include="..\lib_tloptional.h" />
|
||||
<ClInclude Include="..\settings.h" />
|
||||
<ClInclude Include="..\tests.h" />
|
||||
<ClInclude Include="..\tloptional.h" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<None Include="..\cpp.hint" />
|
||||
|
@ -108,11 +108,11 @@
|
||||
<Natvis Include="..\..\toml++.natvis" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ClInclude Include="..\catch2.h" />
|
||||
<ClInclude Include="..\leakproof.h" />
|
||||
<ClInclude Include="..\lib_catch2.h" />
|
||||
<ClInclude Include="..\lib_tloptional.h" />
|
||||
<ClInclude Include="..\settings.h" />
|
||||
<ClInclude Include="..\tests.h" />
|
||||
<ClInclude Include="..\tloptional.h" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<None Include="..\cpp.hint" />
|
||||
|
@ -108,11 +108,11 @@
|
||||
<Natvis Include="..\..\toml++.natvis" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ClInclude Include="..\catch2.h" />
|
||||
<ClInclude Include="..\leakproof.h" />
|
||||
<ClInclude Include="..\lib_catch2.h" />
|
||||
<ClInclude Include="..\lib_tloptional.h" />
|
||||
<ClInclude Include="..\settings.h" />
|
||||
<ClInclude Include="..\tests.h" />
|
||||
<ClInclude Include="..\tloptional.h" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<None Include="..\cpp.hint" />
|
||||
|
@ -108,11 +108,11 @@
|
||||
<Natvis Include="..\..\toml++.natvis" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ClInclude Include="..\catch2.h" />
|
||||
<ClInclude Include="..\leakproof.h" />
|
||||
<ClInclude Include="..\lib_catch2.h" />
|
||||
<ClInclude Include="..\lib_tloptional.h" />
|
||||
<ClInclude Include="..\settings.h" />
|
||||
<ClInclude Include="..\tests.h" />
|
||||
<ClInclude Include="..\tloptional.h" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<None Include="..\cpp.hint" />
|
||||
|
@ -108,11 +108,11 @@
|
||||
<Natvis Include="..\..\toml++.natvis" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ClInclude Include="..\catch2.h" />
|
||||
<ClInclude Include="..\leakproof.h" />
|
||||
<ClInclude Include="..\lib_catch2.h" />
|
||||
<ClInclude Include="..\lib_tloptional.h" />
|
||||
<ClInclude Include="..\settings.h" />
|
||||
<ClInclude Include="..\tests.h" />
|
||||
<ClInclude Include="..\tloptional.h" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<None Include="..\cpp.hint" />
|
||||
|
@ -108,11 +108,11 @@
|
||||
<Natvis Include="..\..\toml++.natvis" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ClInclude Include="..\catch2.h" />
|
||||
<ClInclude Include="..\leakproof.h" />
|
||||
<ClInclude Include="..\lib_catch2.h" />
|
||||
<ClInclude Include="..\lib_tloptional.h" />
|
||||
<ClInclude Include="..\settings.h" />
|
||||
<ClInclude Include="..\tests.h" />
|
||||
<ClInclude Include="..\tloptional.h" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<None Include="..\cpp.hint" />
|
||||
|
@ -108,11 +108,11 @@
|
||||
<Natvis Include="..\..\toml++.natvis" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ClInclude Include="..\catch2.h" />
|
||||
<ClInclude Include="..\leakproof.h" />
|
||||
<ClInclude Include="..\lib_catch2.h" />
|
||||
<ClInclude Include="..\lib_tloptional.h" />
|
||||
<ClInclude Include="..\settings.h" />
|
||||
<ClInclude Include="..\tests.h" />
|
||||
<ClInclude Include="..\tloptional.h" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<None Include="..\cpp.hint" />
|
||||
|
@ -108,11 +108,11 @@
|
||||
<Natvis Include="..\..\toml++.natvis" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ClInclude Include="..\catch2.h" />
|
||||
<ClInclude Include="..\leakproof.h" />
|
||||
<ClInclude Include="..\lib_catch2.h" />
|
||||
<ClInclude Include="..\lib_tloptional.h" />
|
||||
<ClInclude Include="..\settings.h" />
|
||||
<ClInclude Include="..\tests.h" />
|
||||
<ClInclude Include="..\tloptional.h" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<None Include="..\cpp.hint" />
|
||||
|
@ -108,11 +108,11 @@
|
||||
<Natvis Include="..\..\toml++.natvis" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ClInclude Include="..\catch2.h" />
|
||||
<ClInclude Include="..\leakproof.h" />
|
||||
<ClInclude Include="..\lib_catch2.h" />
|
||||
<ClInclude Include="..\lib_tloptional.h" />
|
||||
<ClInclude Include="..\settings.h" />
|
||||
<ClInclude Include="..\tests.h" />
|
||||
<ClInclude Include="..\tloptional.h" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<None Include="..\cpp.hint" />
|
||||
|
@ -108,11 +108,11 @@
|
||||
<Natvis Include="..\..\toml++.natvis" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ClInclude Include="..\catch2.h" />
|
||||
<ClInclude Include="..\leakproof.h" />
|
||||
<ClInclude Include="..\lib_catch2.h" />
|
||||
<ClInclude Include="..\lib_tloptional.h" />
|
||||
<ClInclude Include="..\settings.h" />
|
||||
<ClInclude Include="..\tests.h" />
|
||||
<ClInclude Include="..\tloptional.h" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<None Include="..\cpp.hint" />
|
||||
|
@ -108,11 +108,11 @@
|
||||
<Natvis Include="..\..\toml++.natvis" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ClInclude Include="..\catch2.h" />
|
||||
<ClInclude Include="..\leakproof.h" />
|
||||
<ClInclude Include="..\lib_catch2.h" />
|
||||
<ClInclude Include="..\lib_tloptional.h" />
|
||||
<ClInclude Include="..\settings.h" />
|
||||
<ClInclude Include="..\tests.h" />
|
||||
<ClInclude Include="..\tloptional.h" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<None Include="..\cpp.hint" />
|
||||
|
@ -108,11 +108,11 @@
|
||||
<Natvis Include="..\..\toml++.natvis" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ClInclude Include="..\catch2.h" />
|
||||
<ClInclude Include="..\leakproof.h" />
|
||||
<ClInclude Include="..\lib_catch2.h" />
|
||||
<ClInclude Include="..\lib_tloptional.h" />
|
||||
<ClInclude Include="..\settings.h" />
|
||||
<ClInclude Include="..\tests.h" />
|
||||
<ClInclude Include="..\tloptional.h" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<None Include="..\cpp.hint" />
|
||||
|
@ -108,11 +108,11 @@
|
||||
<Natvis Include="..\..\toml++.natvis" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ClInclude Include="..\catch2.h" />
|
||||
<ClInclude Include="..\leakproof.h" />
|
||||
<ClInclude Include="..\lib_catch2.h" />
|
||||
<ClInclude Include="..\lib_tloptional.h" />
|
||||
<ClInclude Include="..\settings.h" />
|
||||
<ClInclude Include="..\tests.h" />
|
||||
<ClInclude Include="..\tloptional.h" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<None Include="..\cpp.hint" />
|
||||
|
@ -108,11 +108,11 @@
|
||||
<Natvis Include="..\..\toml++.natvis" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ClInclude Include="..\catch2.h" />
|
||||
<ClInclude Include="..\leakproof.h" />
|
||||
<ClInclude Include="..\lib_catch2.h" />
|
||||
<ClInclude Include="..\lib_tloptional.h" />
|
||||
<ClInclude Include="..\settings.h" />
|
||||
<ClInclude Include="..\tests.h" />
|
||||
<ClInclude Include="..\tloptional.h" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<None Include="..\cpp.hint" />
|
||||
|
@ -108,11 +108,11 @@
|
||||
<Natvis Include="..\..\toml++.natvis" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ClInclude Include="..\catch2.h" />
|
||||
<ClInclude Include="..\leakproof.h" />
|
||||
<ClInclude Include="..\lib_catch2.h" />
|
||||
<ClInclude Include="..\lib_tloptional.h" />
|
||||
<ClInclude Include="..\settings.h" />
|
||||
<ClInclude Include="..\tests.h" />
|
||||
<ClInclude Include="..\tloptional.h" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<None Include="..\cpp.hint" />
|
||||
|
@ -108,11 +108,11 @@
|
||||
<Natvis Include="..\..\toml++.natvis" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ClInclude Include="..\catch2.h" />
|
||||
<ClInclude Include="..\leakproof.h" />
|
||||
<ClInclude Include="..\lib_catch2.h" />
|
||||
<ClInclude Include="..\lib_tloptional.h" />
|
||||
<ClInclude Include="..\settings.h" />
|
||||
<ClInclude Include="..\tests.h" />
|
||||
<ClInclude Include="..\tloptional.h" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<None Include="..\cpp.hint" />
|
||||
|
@ -108,11 +108,11 @@
|
||||
<Natvis Include="..\..\toml++.natvis" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ClInclude Include="..\catch2.h" />
|
||||
<ClInclude Include="..\leakproof.h" />
|
||||
<ClInclude Include="..\lib_catch2.h" />
|
||||
<ClInclude Include="..\lib_tloptional.h" />
|
||||
<ClInclude Include="..\settings.h" />
|
||||
<ClInclude Include="..\tests.h" />
|
||||
<ClInclude Include="..\tloptional.h" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<None Include="..\cpp.hint" />
|
||||
|
@ -108,11 +108,11 @@
|
||||
<Natvis Include="..\..\toml++.natvis" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ClInclude Include="..\catch2.h" />
|
||||
<ClInclude Include="..\leakproof.h" />
|
||||
<ClInclude Include="..\lib_catch2.h" />
|
||||
<ClInclude Include="..\lib_tloptional.h" />
|
||||
<ClInclude Include="..\settings.h" />
|
||||
<ClInclude Include="..\tests.h" />
|
||||
<ClInclude Include="..\tloptional.h" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<None Include="..\cpp.hint" />
|
||||
|
@ -108,11 +108,11 @@
|
||||
<Natvis Include="..\..\toml++.natvis" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ClInclude Include="..\catch2.h" />
|
||||
<ClInclude Include="..\leakproof.h" />
|
||||
<ClInclude Include="..\lib_catch2.h" />
|
||||
<ClInclude Include="..\lib_tloptional.h" />
|
||||
<ClInclude Include="..\settings.h" />
|
||||
<ClInclude Include="..\tests.h" />
|
||||
<ClInclude Include="..\tloptional.h" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<None Include="..\cpp.hint" />
|
||||
|
@ -108,11 +108,11 @@
|
||||
<Natvis Include="..\..\toml++.natvis" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ClInclude Include="..\catch2.h" />
|
||||
<ClInclude Include="..\leakproof.h" />
|
||||
<ClInclude Include="..\lib_catch2.h" />
|
||||
<ClInclude Include="..\lib_tloptional.h" />
|
||||
<ClInclude Include="..\settings.h" />
|
||||
<ClInclude Include="..\tests.h" />
|
||||
<ClInclude Include="..\tloptional.h" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<None Include="..\cpp.hint" />
|
||||
|
@ -108,11 +108,11 @@
|
||||
<Natvis Include="..\..\toml++.natvis" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ClInclude Include="..\catch2.h" />
|
||||
<ClInclude Include="..\leakproof.h" />
|
||||
<ClInclude Include="..\lib_catch2.h" />
|
||||
<ClInclude Include="..\lib_tloptional.h" />
|
||||
<ClInclude Include="..\settings.h" />
|
||||
<ClInclude Include="..\tests.h" />
|
||||
<ClInclude Include="..\tloptional.h" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<None Include="..\cpp.hint" />
|
||||
|
@ -24,9 +24,9 @@ TEST_CASE("windows compat")
|
||||
)"sv;
|
||||
|
||||
auto res = toml::parse(toml_text, L"kek.toml");
|
||||
#if !TOML_EXCEPTIONS
|
||||
#if !TOML_EXCEPTIONS
|
||||
REQUIRE(res.succeeded());
|
||||
#endif
|
||||
#endif
|
||||
toml::table& tbl = res;
|
||||
|
||||
// source paths
|
||||
|
239
toml.hpp
239
toml.hpp
@ -546,13 +546,6 @@
|
||||
#define TOML_UNREACHABLE TOML_ASSERT(false)
|
||||
#endif
|
||||
|
||||
#if defined(__cpp_consteval) && __cpp_consteval >= 201811 && !defined(_MSC_VER)
|
||||
// https://developercommunity.visualstudio.com/t/Erroneous-C7595-error-with-consteval-in/1404234
|
||||
#define TOML_CONSTEVAL consteval
|
||||
#else
|
||||
#define TOML_CONSTEVAL constexpr
|
||||
#endif
|
||||
|
||||
#ifdef __has_cpp_attribute
|
||||
#define TOML_HAS_ATTR(...) __has_cpp_attribute(__VA_ARGS__)
|
||||
#else
|
||||
@ -766,7 +759,9 @@
|
||||
#define TOML_EXTERNAL_LINKAGE inline
|
||||
#define TOML_INTERNAL_LINKAGE inline
|
||||
#else
|
||||
#define TOML_ANON_NAMESPACE_START static_assert(TOML_IMPLEMENTATION); using namespace toml; namespace
|
||||
#define TOML_ANON_NAMESPACE_START static_assert(TOML_IMPLEMENTATION); \
|
||||
using namespace toml; \
|
||||
namespace
|
||||
#define TOML_ANON_NAMESPACE_END static_assert(true)
|
||||
#define TOML_ANON_NAMESPACE
|
||||
#define TOML_EXTERNAL_LINKAGE
|
||||
@ -1024,15 +1019,6 @@ TOML_NAMESPACE_START
|
||||
class parse_result;
|
||||
#endif
|
||||
TOML_ABI_NAMESPACE_END; // TOML_EXCEPTIONS
|
||||
|
||||
TOML_NODISCARD
|
||||
TOML_ATTR(const)
|
||||
TOML_ALWAYS_INLINE
|
||||
TOML_CONSTEVAL
|
||||
size_t operator"" _sz(unsigned long long n) noexcept
|
||||
{
|
||||
return static_cast<size_t>(n);
|
||||
}
|
||||
}
|
||||
TOML_NAMESPACE_END;
|
||||
|
||||
@ -4736,14 +4722,13 @@ TOML_NAMESPACE_START
|
||||
TOML_API
|
||||
array& operator=(array&& rhs) noexcept;
|
||||
|
||||
TOML_CONSTRAINED_TEMPLATE((sizeof...(ElemTypes) > 0_sz
|
||||
|| !std::is_same_v<impl::remove_cvref_t<ElemType>, array>),
|
||||
TOML_CONSTRAINED_TEMPLATE((sizeof...(ElemTypes) > 0 || !std::is_same_v<impl::remove_cvref_t<ElemType>, array>),
|
||||
typename ElemType,
|
||||
typename... ElemTypes)
|
||||
TOML_NODISCARD_CTOR
|
||||
explicit array(ElemType&& val, ElemTypes&&... vals)
|
||||
{
|
||||
elements.reserve(sizeof...(ElemTypes) + 1_sz);
|
||||
elements.reserve(sizeof...(ElemTypes) + 1u);
|
||||
emplace_back_if_not_empty_view(static_cast<ElemType&&>(val));
|
||||
if constexpr (sizeof...(ElemTypes) > 0)
|
||||
{
|
||||
@ -4949,7 +4934,7 @@ TOML_NAMESPACE_START
|
||||
const auto start_idx = static_cast<size_t>(pos.raw_ - elements.cbegin());
|
||||
preinsertion_resize(start_idx, count);
|
||||
size_t i = start_idx;
|
||||
for (size_t e = start_idx + count - 1_sz; i < e; i++)
|
||||
for (size_t e = start_idx + count - 1u; i < e; i++)
|
||||
elements[i].reset(impl::make_node(val));
|
||||
|
||||
elements[i].reset(impl::make_node(static_cast<ElemType&&>(val)));
|
||||
@ -5119,7 +5104,7 @@ TOML_NAMESPACE_START
|
||||
|
||||
if (lhs.size() != rhs.size())
|
||||
return false;
|
||||
if (rhs.size() == 0_sz)
|
||||
if (rhs.size() == 0u)
|
||||
return true;
|
||||
|
||||
size_t i{};
|
||||
@ -5501,12 +5486,15 @@ TOML_NAMESPACE_START
|
||||
}
|
||||
|
||||
TOML_NODISCARD
|
||||
TOML_API
|
||||
bool is_homogeneous(node_type ntype) const noexcept final;
|
||||
|
||||
TOML_NODISCARD
|
||||
TOML_API
|
||||
bool is_homogeneous(node_type ntype, node*& first_nonmatch) noexcept final;
|
||||
|
||||
TOML_NODISCARD
|
||||
TOML_API
|
||||
bool is_homogeneous(node_type ntype, const node*& first_nonmatch) const noexcept final;
|
||||
|
||||
template <typename ElemType = void>
|
||||
@ -7528,7 +7516,7 @@ TOML_NAMESPACE_START
|
||||
std::vector<std::string> key_path_;
|
||||
bool pending_table_separator_ = false;
|
||||
|
||||
static constexpr size_t line_wrap_cols = 120_sz;
|
||||
static constexpr size_t line_wrap_cols = 120;
|
||||
|
||||
TOML_NODISCARD
|
||||
TOML_API
|
||||
@ -8057,26 +8045,26 @@ TOML_IMPL_NAMESPACE_START
|
||||
TOML_EXTERNAL_LINKAGE
|
||||
void print_to_stream(std::ostream & stream, const toml::date& val)
|
||||
{
|
||||
print_integer_leftpad_zeros(stream, val.year, 4_sz);
|
||||
print_integer_leftpad_zeros(stream, val.year, 4u);
|
||||
stream.put('-');
|
||||
print_integer_leftpad_zeros(stream, val.month, 2_sz);
|
||||
print_integer_leftpad_zeros(stream, val.month, 2u);
|
||||
stream.put('-');
|
||||
print_integer_leftpad_zeros(stream, val.day, 2_sz);
|
||||
print_integer_leftpad_zeros(stream, val.day, 2u);
|
||||
}
|
||||
|
||||
TOML_EXTERNAL_LINKAGE
|
||||
void print_to_stream(std::ostream & stream, const toml::time& val)
|
||||
{
|
||||
print_integer_leftpad_zeros(stream, val.hour, 2_sz);
|
||||
print_integer_leftpad_zeros(stream, val.hour, 2u);
|
||||
stream.put(':');
|
||||
print_integer_leftpad_zeros(stream, val.minute, 2_sz);
|
||||
print_integer_leftpad_zeros(stream, val.minute, 2u);
|
||||
stream.put(':');
|
||||
print_integer_leftpad_zeros(stream, val.second, 2_sz);
|
||||
print_integer_leftpad_zeros(stream, val.second, 2u);
|
||||
if (val.nanosecond && val.nanosecond <= 999999999u)
|
||||
{
|
||||
stream.put('.');
|
||||
auto ns = val.nanosecond;
|
||||
size_t digits = 9_sz;
|
||||
size_t digits = 9u;
|
||||
while (ns % 10u == 0u)
|
||||
{
|
||||
ns /= 10u;
|
||||
@ -8106,13 +8094,13 @@ TOML_IMPL_NAMESPACE_START
|
||||
const auto hours = mins / 60;
|
||||
if (hours)
|
||||
{
|
||||
print_integer_leftpad_zeros(stream, static_cast<unsigned int>(hours), 2_sz);
|
||||
print_integer_leftpad_zeros(stream, static_cast<unsigned int>(hours), 2u);
|
||||
mins -= hours * 60;
|
||||
}
|
||||
else
|
||||
print_to_stream(stream, "00"sv);
|
||||
stream.put(':');
|
||||
print_integer_leftpad_zeros(stream, static_cast<unsigned int>(mins), 2_sz);
|
||||
print_integer_leftpad_zeros(stream, static_cast<unsigned int>(mins), 2u);
|
||||
}
|
||||
|
||||
TOML_EXTERNAL_LINKAGE
|
||||
@ -8476,14 +8464,14 @@ TOML_NAMESPACE_START
|
||||
void array::preinsertion_resize(size_t idx, size_t count) noexcept
|
||||
{
|
||||
TOML_ASSERT(idx <= elements.size());
|
||||
TOML_ASSERT(count >= 1_sz);
|
||||
TOML_ASSERT(count >= 1u);
|
||||
const auto old_size = elements.size();
|
||||
const auto new_size = old_size + count;
|
||||
const auto inserting_at_end = idx == old_size;
|
||||
elements.resize(new_size);
|
||||
if (!inserting_at_end)
|
||||
{
|
||||
for (size_t left = old_size, right = new_size - 1_sz; left-- > idx; right--)
|
||||
for (size_t left = old_size, right = new_size - 1u; left-- > idx; right--)
|
||||
elements[right] = std::move(elements[left]);
|
||||
}
|
||||
}
|
||||
@ -8547,7 +8535,7 @@ TOML_NAMESPACE_START
|
||||
for (size_t i = 0, e = elements.size(); i < e; i++)
|
||||
{
|
||||
auto arr = elements[i]->as_array();
|
||||
leaves += arr ? arr->total_leaf_count() : 1_sz;
|
||||
leaves += arr ? arr->total_leaf_count() : size_t{ 1 };
|
||||
}
|
||||
return leaves;
|
||||
}
|
||||
@ -8577,14 +8565,14 @@ TOML_NAMESPACE_START
|
||||
|
||||
bool requires_flattening = false;
|
||||
size_t size_after_flattening = elements.size();
|
||||
for (size_t i = elements.size(); i-- > 0_sz;)
|
||||
for (size_t i = elements.size(); i-- > 0u;)
|
||||
{
|
||||
auto arr = elements[i]->as_array();
|
||||
if (!arr)
|
||||
continue;
|
||||
size_after_flattening--; // discount the array itself
|
||||
const auto leaf_count = arr->total_leaf_count();
|
||||
if (leaf_count > 0_sz)
|
||||
if (leaf_count > 0u)
|
||||
{
|
||||
requires_flattening = true;
|
||||
size_after_flattening += leaf_count;
|
||||
@ -8610,8 +8598,8 @@ TOML_NAMESPACE_START
|
||||
|
||||
std::unique_ptr<node> arr_storage = std::move(elements[i]);
|
||||
const auto leaf_count = arr->total_leaf_count();
|
||||
if (leaf_count > 1_sz)
|
||||
preinsertion_resize(i + 1_sz, leaf_count - 1_sz);
|
||||
if (leaf_count > 1u)
|
||||
preinsertion_resize(i + 1u, leaf_count - 1u);
|
||||
flatten_child(std::move(*arr), i); // increments i
|
||||
}
|
||||
|
||||
@ -8814,7 +8802,7 @@ TOML_ANON_NAMESPACE_START
|
||||
template <typename Char>
|
||||
class utf8_byte_stream<std::basic_string_view<Char>>
|
||||
{
|
||||
static_assert(sizeof(Char) == 1_sz);
|
||||
static_assert(sizeof(Char) == 1);
|
||||
|
||||
private:
|
||||
std::basic_string_view<Char> source_;
|
||||
@ -8828,20 +8816,20 @@ TOML_ANON_NAMESPACE_START
|
||||
// trim trailing nulls
|
||||
const size_t initial_len = source_.length();
|
||||
size_t actual_len = initial_len;
|
||||
for (size_t i = actual_len; i-- > 0_sz;)
|
||||
for (size_t i = actual_len; i-- > 0u;)
|
||||
{
|
||||
if (source_[i] != Char{}) // not '\0'
|
||||
{
|
||||
actual_len = i + 1_sz;
|
||||
actual_len = i + 1u;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (initial_len != actual_len)
|
||||
source_ = source_.substr(0_sz, actual_len);
|
||||
source_ = source_.substr(0u, actual_len);
|
||||
|
||||
// skip bom
|
||||
if (actual_len >= 3_sz && memcmp(utf8_byte_order_mark.data(), source_.data(), 3_sz) == 0)
|
||||
position_ += 3_sz;
|
||||
if (actual_len >= 3u && memcmp(utf8_byte_order_mark.data(), source_.data(), 3u) == 0)
|
||||
position_ += 3u;
|
||||
}
|
||||
|
||||
TOML_NODISCARD
|
||||
@ -8877,7 +8865,7 @@ TOML_ANON_NAMESPACE_START
|
||||
template <typename Char>
|
||||
class utf8_byte_stream<std::basic_istream<Char>>
|
||||
{
|
||||
static_assert(sizeof(Char) == 1_sz);
|
||||
static_assert(sizeof(Char) == 1);
|
||||
|
||||
private:
|
||||
std::basic_istream<Char>* source_;
|
||||
@ -8893,7 +8881,7 @@ TOML_ANON_NAMESPACE_START
|
||||
const auto initial_pos = source_->tellg();
|
||||
Char bom[3];
|
||||
source_->read(bom, 3);
|
||||
if (source_->bad() || (source_->gcount() == 3 && memcmp(utf8_byte_order_mark.data(), bom, 3_sz) == 0))
|
||||
if (source_->bad() || (source_->gcount() == 3 && memcmp(utf8_byte_order_mark.data(), bom, 3u) == 0))
|
||||
return;
|
||||
|
||||
source_->clear();
|
||||
@ -8941,7 +8929,7 @@ TOML_ANON_NAMESPACE_START
|
||||
TOML_NODISCARD
|
||||
std::string_view as_view() const noexcept
|
||||
{
|
||||
return bytes[3] ? std::string_view{ bytes, 4_sz } : std::string_view{ bytes };
|
||||
return bytes[3] ? std::string_view{ bytes, 4u } : std::string_view{ bytes };
|
||||
}
|
||||
|
||||
TOML_NODISCARD
|
||||
@ -9032,7 +9020,7 @@ TOML_ANON_NAMESPACE_START
|
||||
{
|
||||
TOML_ERROR_CHECK;
|
||||
|
||||
auto& prev = codepoints_[(cp_idx_ - 1_sz) % 2_sz];
|
||||
auto& prev = codepoints_[(cp_idx_ - 1u) % 2u];
|
||||
|
||||
if (stream_.eof())
|
||||
return nullptr;
|
||||
@ -9096,7 +9084,7 @@ TOML_ANON_NAMESPACE_START
|
||||
|
||||
TOML_ERROR_CHECK;
|
||||
|
||||
auto& current = codepoints_[cp_idx_ % 2_sz];
|
||||
auto& current = codepoints_[cp_idx_ % 2u];
|
||||
current.bytes[current_byte_count_++] = static_cast<char>(next_byte);
|
||||
if (decoder_.has_code_point())
|
||||
{
|
||||
@ -9725,7 +9713,7 @@ TOML_IMPL_NAMESPACE_START
|
||||
TOML_NEVER_INLINE
|
||||
void set_error_at(source_position pos, const T&... reason) const TOML_MAY_THROW
|
||||
{
|
||||
static_assert(sizeof...(T) > 0_sz);
|
||||
static_assert(sizeof...(T) > 0);
|
||||
#if !TOML_EXCEPTIONS
|
||||
if (err)
|
||||
return;
|
||||
@ -9750,7 +9738,7 @@ TOML_IMPL_NAMESPACE_START
|
||||
set_error_at(current_position(1), reason...);
|
||||
}
|
||||
|
||||
void go_back(size_t count = 1_sz) noexcept
|
||||
void go_back(size_t count = 1) noexcept
|
||||
{
|
||||
return_if_error();
|
||||
assert_or_assume(count);
|
||||
@ -9793,7 +9781,7 @@ TOML_IMPL_NAMESPACE_START
|
||||
recording_buffer.append(cp->as_view());
|
||||
}
|
||||
|
||||
void stop_recording(size_t pop_bytes = 0_sz) noexcept
|
||||
void stop_recording(size_t pop_bytes = 0) noexcept
|
||||
{
|
||||
return_if_error();
|
||||
|
||||
@ -9802,7 +9790,7 @@ TOML_IMPL_NAMESPACE_START
|
||||
{
|
||||
if (pop_bytes >= recording_buffer.length())
|
||||
recording_buffer.clear();
|
||||
else if (pop_bytes == 1_sz)
|
||||
else if (pop_bytes == 1u)
|
||||
recording_buffer.pop_back();
|
||||
else
|
||||
recording_buffer.erase(recording_buffer.begin()
|
||||
@ -10081,7 +10069,7 @@ TOML_IMPL_NAMESPACE_START
|
||||
if (multi_line)
|
||||
{
|
||||
size_t lookaheads = {};
|
||||
size_t consecutive_delimiters = 1_sz;
|
||||
size_t consecutive_delimiters = 1;
|
||||
do
|
||||
{
|
||||
advance_and_return_if_error({});
|
||||
@ -10091,30 +10079,30 @@ TOML_IMPL_NAMESPACE_START
|
||||
else
|
||||
break;
|
||||
}
|
||||
while (lookaheads < 4_sz);
|
||||
while (lookaheads < 4u);
|
||||
|
||||
switch (consecutive_delimiters)
|
||||
{
|
||||
// """ " (one quote somewhere in a ML string)
|
||||
case 1_sz:
|
||||
case 1:
|
||||
str += '"';
|
||||
skipping_whitespace = false;
|
||||
continue;
|
||||
|
||||
// """ "" (two quotes somewhere in a ML string)
|
||||
case 2_sz:
|
||||
case 2:
|
||||
str.append("\"\""sv);
|
||||
skipping_whitespace = false;
|
||||
continue;
|
||||
|
||||
// """ """ (the end of the string)
|
||||
case 3_sz: return str;
|
||||
case 3: return str;
|
||||
|
||||
// """ """" (one at the end of the string)
|
||||
case 4_sz: str += '"'; return str;
|
||||
case 4: str += '"'; return str;
|
||||
|
||||
// """ """"" (two quotes at the end of the string)
|
||||
case 5_sz:
|
||||
case 5:
|
||||
str.append("\"\""sv);
|
||||
advance_and_return_if_error({}); // skip the last '"'
|
||||
return str;
|
||||
@ -10210,7 +10198,7 @@ TOML_IMPL_NAMESPACE_START
|
||||
if (multi_line)
|
||||
{
|
||||
size_t lookaheads = {};
|
||||
size_t consecutive_delimiters = 1_sz;
|
||||
size_t consecutive_delimiters = 1;
|
||||
do
|
||||
{
|
||||
advance_and_return_if_error({});
|
||||
@ -10220,24 +10208,24 @@ TOML_IMPL_NAMESPACE_START
|
||||
else
|
||||
break;
|
||||
}
|
||||
while (lookaheads < 4_sz);
|
||||
while (lookaheads < 4u);
|
||||
|
||||
switch (consecutive_delimiters)
|
||||
{
|
||||
// ''' ' (one quote somewhere in a ML string)
|
||||
case 1_sz: str += '\''; continue;
|
||||
case 1: str += '\''; continue;
|
||||
|
||||
// ''' '' (two quotes somewhere in a ML string)
|
||||
case 2_sz: str.append("''"sv); continue;
|
||||
case 2: str.append("''"sv); continue;
|
||||
|
||||
// ''' ''' (the end of the string)
|
||||
case 3_sz: return str;
|
||||
case 3: return str;
|
||||
|
||||
// ''' '''' (one at the end of the string)
|
||||
case 4_sz: str += '\''; return str;
|
||||
case 4: str += '\''; return str;
|
||||
|
||||
// ''' ''''' (two quotes at the end of the string)
|
||||
case 5_sz:
|
||||
case 5:
|
||||
str.append("''"sv);
|
||||
advance_and_return_if_error({}); // skip the last '
|
||||
return str;
|
||||
@ -10320,7 +10308,7 @@ TOML_IMPL_NAMESPACE_START
|
||||
{
|
||||
// step back two characters so that the current
|
||||
// character is the string delimiter
|
||||
go_back(2_sz);
|
||||
go_back(2u);
|
||||
|
||||
return { first == U'\'' ? parse_literal_string(false) : parse_basic_string(false), false };
|
||||
}
|
||||
@ -10630,7 +10618,7 @@ TOML_IMPL_NAMESPACE_START
|
||||
set_error_and_return_default("expected exponent digit or sign, saw '"sv, to_sv(*cp), "'"sv);
|
||||
|
||||
// 0x.p-0 (mantissa is just '.')
|
||||
else if (fragments[0].length == 0_sz && fragments[1].length == 0_sz)
|
||||
else if (fragments[0].length == 0u && fragments[1].length == 0u)
|
||||
set_error_and_return_default("expected hexadecimal digit, saw '"sv, to_sv(*cp), "'"sv);
|
||||
|
||||
else
|
||||
@ -10665,7 +10653,7 @@ TOML_IMPL_NAMESPACE_START
|
||||
}
|
||||
|
||||
// sanity-check ending state
|
||||
if (current_fragment != fragments + 2 || current_fragment->length == 0_sz)
|
||||
if (current_fragment != fragments + 2 || current_fragment->length == 0u)
|
||||
{
|
||||
set_error_and_return_if_eof({});
|
||||
set_error_and_return_default("missing exponent"sv);
|
||||
@ -10696,7 +10684,7 @@ TOML_IMPL_NAMESPACE_START
|
||||
|
||||
// calculate value
|
||||
auto place = 1u;
|
||||
for (size_t i = 0; i < f.length - 1_sz; i++)
|
||||
for (size_t i = 0; i < f.length - 1u; i++)
|
||||
place *= base;
|
||||
uint32_t val{};
|
||||
while (place)
|
||||
@ -10810,7 +10798,7 @@ TOML_IMPL_NAMESPACE_START
|
||||
}
|
||||
|
||||
// single digits can be converted trivially
|
||||
if (length == 1_sz)
|
||||
if (length == 1u)
|
||||
{
|
||||
if constexpr (base == 16)
|
||||
return static_cast<int64_t>(hex_to_dec(chars[0]));
|
||||
@ -10860,7 +10848,7 @@ TOML_IMPL_NAMESPACE_START
|
||||
|
||||
// "YYYY"
|
||||
uint32_t digits[4];
|
||||
if (!consume_digit_sequence(digits, 4_sz))
|
||||
if (!consume_digit_sequence(digits, 4u))
|
||||
set_error_and_return_default("expected 4-digit year, saw '"sv, to_sv(cp), "'"sv);
|
||||
const auto year = digits[3] + digits[2] * 10u + digits[1] * 100u + digits[0] * 1000u;
|
||||
const auto is_leap_year = (year % 4u == 0u) && ((year % 100u != 0u) || (year % 400u == 0u));
|
||||
@ -10872,7 +10860,7 @@ TOML_IMPL_NAMESPACE_START
|
||||
advance_and_return_if_error_or_eof({});
|
||||
|
||||
// "MM"
|
||||
if (!consume_digit_sequence(digits, 2_sz))
|
||||
if (!consume_digit_sequence(digits, 2u))
|
||||
set_error_and_return_default("expected 2-digit month, saw '"sv, to_sv(cp), "'"sv);
|
||||
const auto month = digits[1] + digits[0] * 10u;
|
||||
if (month == 0u || month > 12u)
|
||||
@ -10889,7 +10877,7 @@ TOML_IMPL_NAMESPACE_START
|
||||
advance_and_return_if_error_or_eof({});
|
||||
|
||||
// "DD"
|
||||
if (!consume_digit_sequence(digits, 2_sz))
|
||||
if (!consume_digit_sequence(digits, 2u))
|
||||
set_error_and_return_default("expected 2-digit day, saw '"sv, to_sv(cp), "'"sv);
|
||||
const auto day = digits[1] + digits[0] * 10u;
|
||||
if (day == 0u || day > max_days_in_month)
|
||||
@ -10912,11 +10900,11 @@ TOML_IMPL_NAMESPACE_START
|
||||
assert_or_assume(is_decimal_digit(*cp));
|
||||
push_parse_scope("time"sv);
|
||||
|
||||
static constexpr auto max_digits = 9_sz;
|
||||
static constexpr size_t max_digits = 9;
|
||||
uint32_t digits[max_digits];
|
||||
|
||||
// "HH"
|
||||
if (!consume_digit_sequence(digits, 2_sz))
|
||||
if (!consume_digit_sequence(digits, 2u))
|
||||
set_error_and_return_default("expected 2-digit hour, saw '"sv, to_sv(cp), "'"sv);
|
||||
const auto hour = digits[1] + digits[0] * 10u;
|
||||
if (hour > 23u)
|
||||
@ -10930,7 +10918,7 @@ TOML_IMPL_NAMESPACE_START
|
||||
advance_and_return_if_error_or_eof({});
|
||||
|
||||
// "MM"
|
||||
if (!consume_digit_sequence(digits, 2_sz))
|
||||
if (!consume_digit_sequence(digits, 2u))
|
||||
set_error_and_return_default("expected 2-digit minute, saw '"sv, to_sv(cp), "'"sv);
|
||||
const auto minute = digits[1] + digits[0] * 10u;
|
||||
if (minute > 59u)
|
||||
@ -10954,7 +10942,7 @@ TOML_IMPL_NAMESPACE_START
|
||||
advance_and_return_if_error_or_eof({});
|
||||
|
||||
// "SS"
|
||||
if (!consume_digit_sequence(digits, 2_sz))
|
||||
if (!consume_digit_sequence(digits, 2u))
|
||||
set_error_and_return_default("expected 2-digit second, saw '"sv, to_sv(cp), "'"sv);
|
||||
const auto second = digits[1] + digits[0] * 10u;
|
||||
if (second > 59u)
|
||||
@ -10970,7 +10958,7 @@ TOML_IMPL_NAMESPACE_START
|
||||
advance_and_return_if_error_or_eof({});
|
||||
|
||||
// "FFFFFFFFF"
|
||||
auto digit_count = consume_variable_length_digit_sequence(digits, max_digits);
|
||||
size_t digit_count = consume_variable_length_digit_sequence(digits, max_digits);
|
||||
if (!digit_count)
|
||||
{
|
||||
set_error_and_return_if_eof({});
|
||||
@ -10987,7 +10975,7 @@ TOML_IMPL_NAMESPACE_START
|
||||
|
||||
uint32_t value = 0u;
|
||||
uint32_t place = 1u;
|
||||
for (auto i = digit_count; i-- > 0_sz;)
|
||||
for (auto i = digit_count; i-- > 0u;)
|
||||
{
|
||||
value += digits[i] * place;
|
||||
place *= 10u;
|
||||
@ -11039,7 +11027,7 @@ TOML_IMPL_NAMESPACE_START
|
||||
|
||||
// "HH"
|
||||
int digits[2];
|
||||
if (!consume_digit_sequence(digits, 2_sz))
|
||||
if (!consume_digit_sequence(digits, 2u))
|
||||
set_error_and_return_default("expected 2-digit hour, saw '"sv, to_sv(cp), "'"sv);
|
||||
const auto hour = digits[1] + digits[0] * 10;
|
||||
if (hour > 23)
|
||||
@ -11053,7 +11041,7 @@ TOML_IMPL_NAMESPACE_START
|
||||
advance_and_return_if_error_or_eof({});
|
||||
|
||||
// "MM"
|
||||
if (!consume_digit_sequence(digits, 2_sz))
|
||||
if (!consume_digit_sequence(digits, 2u))
|
||||
set_error_and_return_default("expected 2-digit minute, saw '"sv, to_sv(cp), "'"sv);
|
||||
const auto minute = digits[1] + digits[0] * 10;
|
||||
if (minute > 59)
|
||||
@ -11223,19 +11211,19 @@ TOML_IMPL_NAMESPACE_START
|
||||
switch (static_cast<char32_t>(c | 32u))
|
||||
{
|
||||
case U'b':
|
||||
if (char_count == 2_sz && has_any(begins_zero))
|
||||
if (char_count == 2u && has_any(begins_zero))
|
||||
add_trait(has_b);
|
||||
break;
|
||||
|
||||
case U'e':
|
||||
if (char_count > 1_sz
|
||||
if (char_count > 1u
|
||||
&& has_none(has_b | has_o | has_p | has_t | has_x | has_z | has_colon)
|
||||
&& (has_none(has_plus | has_minus) || has_any(begins_sign)))
|
||||
add_trait(has_e);
|
||||
break;
|
||||
|
||||
case U'o':
|
||||
if (char_count == 2_sz && has_any(begins_zero))
|
||||
if (char_count == 2u && has_any(begins_zero))
|
||||
add_trait(has_o);
|
||||
break;
|
||||
|
||||
@ -11245,8 +11233,8 @@ TOML_IMPL_NAMESPACE_START
|
||||
break;
|
||||
|
||||
case U'x':
|
||||
if ((char_count == 2_sz && has_any(begins_zero))
|
||||
|| (char_count == 3_sz && has_any(begins_sign) && chars[1] == U'0'))
|
||||
if ((char_count == 2u && has_any(begins_zero))
|
||||
|| (char_count == 3u && has_any(begins_sign) && chars[1] == U'0'))
|
||||
add_trait(has_x);
|
||||
break;
|
||||
|
||||
@ -11278,7 +11266,7 @@ TOML_IMPL_NAMESPACE_START
|
||||
return_if_error({});
|
||||
|
||||
// force further scanning if this could have been a date-time with a space instead of a T
|
||||
if (char_count == 10_sz && traits == (bdigit_msk | has_minus) && chars[4] == U'-' && chars[7] == U'-'
|
||||
if (char_count == 10u && traits == (bdigit_msk | has_minus) && chars[4] == U'-' && chars[7] == U'-'
|
||||
&& !is_eof() && *cp == U' ')
|
||||
{
|
||||
const auto pre_advance_count = advance_count;
|
||||
@ -11291,7 +11279,7 @@ TOML_IMPL_NAMESPACE_START
|
||||
go_back(advance_count - pre_advance_count);
|
||||
advance_count = pre_advance_count;
|
||||
traits = pre_scan_traits;
|
||||
char_count = 10_sz;
|
||||
char_count = 10u;
|
||||
};
|
||||
|
||||
advance_and_return_if_error({});
|
||||
@ -11309,19 +11297,19 @@ TOML_IMPL_NAMESPACE_START
|
||||
scan();
|
||||
return_if_error({});
|
||||
|
||||
if (char_count == 12_sz)
|
||||
if (char_count == 12u)
|
||||
backpedal();
|
||||
}
|
||||
}
|
||||
|
||||
// set the reader back to where we started
|
||||
go_back(advance_count);
|
||||
if (char_count < utf8_buffered_reader::max_history_length - 1_sz)
|
||||
if (char_count < utf8_buffered_reader::max_history_length - 1u)
|
||||
chars[char_count] = U'\0';
|
||||
|
||||
// if after scanning ahead we still only have one value character,
|
||||
// the only valid value type is an integer.
|
||||
if (char_count == 1_sz)
|
||||
if (char_count == 1u)
|
||||
{
|
||||
if (has_any(begins_zero | begins_digit))
|
||||
{
|
||||
@ -11338,7 +11326,7 @@ TOML_IMPL_NAMESPACE_START
|
||||
|
||||
// now things that can be identified from two or more characters
|
||||
return_if_error({});
|
||||
assert_or_assume(char_count >= 2_sz);
|
||||
assert_or_assume(char_count >= 2u);
|
||||
|
||||
// do some 'fuzzy matching' where there's no ambiguity, since that allows the specific
|
||||
// typed parse functions to take over and show better diagnostics if there's an issue
|
||||
@ -11364,7 +11352,7 @@ TOML_IMPL_NAMESPACE_START
|
||||
else if (has_any(begins_sign))
|
||||
{
|
||||
// single-digit signed integers
|
||||
if (char_count == 2_sz && has_any(has_digits))
|
||||
if (char_count == 2u && has_any(has_digits))
|
||||
{
|
||||
val = new value{ static_cast<int64_t>(chars[1] - U'0') * (chars[0] == U'-' ? -1LL : 1LL) };
|
||||
advance(); // skip the sign
|
||||
@ -11670,7 +11658,7 @@ TOML_IMPL_NAMESPACE_START
|
||||
// get the key
|
||||
start_recording();
|
||||
auto key = parse_key();
|
||||
stop_recording(1_sz);
|
||||
stop_recording(1u);
|
||||
|
||||
// skip past any whitespace that followed the key
|
||||
consume_leading_whitespace();
|
||||
@ -11736,7 +11724,7 @@ TOML_IMPL_NAMESPACE_START
|
||||
// get the actual key
|
||||
start_recording();
|
||||
key = parse_key();
|
||||
stop_recording(1_sz);
|
||||
stop_recording(1u);
|
||||
return_if_error({});
|
||||
|
||||
// skip past any whitespace that followed the key
|
||||
@ -11765,7 +11753,7 @@ TOML_IMPL_NAMESPACE_START
|
||||
|
||||
// check if each parent is a table/table array, or can be created implicitly as a table.
|
||||
auto parent = &root;
|
||||
for (size_t i = 0; i < key.segments.size() - 1_sz; i++)
|
||||
for (size_t i = 0; i < key.segments.size() - 1u; i++)
|
||||
{
|
||||
auto child = parent->get(key.segments[i]);
|
||||
if (!child)
|
||||
@ -11893,13 +11881,13 @@ TOML_IMPL_NAMESPACE_START
|
||||
auto kvp = parse_key_value_pair();
|
||||
return_if_error();
|
||||
|
||||
TOML_ASSERT(kvp.key.segments.size() >= 1_sz);
|
||||
TOML_ASSERT(kvp.key.segments.size() >= 1u);
|
||||
|
||||
// if it's a dotted kvp we need to spawn the sub-tables if necessary,
|
||||
// and set the target table to the second-to-last one in the chain
|
||||
if (kvp.key.segments.size() > 1_sz)
|
||||
if (kvp.key.segments.size() > 1u)
|
||||
{
|
||||
for (size_t i = 0; i < kvp.key.segments.size() - 1_sz; i++)
|
||||
for (size_t i = 0; i < kvp.key.segments.size() - 1u; i++)
|
||||
{
|
||||
auto child = tab->get(kvp.key.segments[i]);
|
||||
if (!child)
|
||||
@ -12279,7 +12267,7 @@ TOML_ANON_NAMESPACE_START
|
||||
|
||||
// open file with a custom-sized stack buffer
|
||||
std::ifstream file;
|
||||
char file_buffer[sizeof(void*) * 1024_sz];
|
||||
char file_buffer[sizeof(void*) * 1024u];
|
||||
file.rdbuf()->pubsetbuf(file_buffer, sizeof(file_buffer));
|
||||
file.open(file_path_str, std::ifstream::in | std::ifstream::binary | std::ifstream::ate);
|
||||
if (!file.is_open())
|
||||
@ -12657,7 +12645,7 @@ TOML_NAMESPACE_START
|
||||
if (requires_quotes)
|
||||
{
|
||||
std::string s;
|
||||
s.reserve(str.length() + 2_sz);
|
||||
s.reserve(str.length() + 2u);
|
||||
s += '"';
|
||||
for (auto c : str)
|
||||
{
|
||||
@ -12687,11 +12675,11 @@ TOML_NAMESPACE_START
|
||||
{
|
||||
auto& n = *reinterpret_cast<const table*>(&node);
|
||||
if (n.empty())
|
||||
return 2_sz; // "{}"
|
||||
size_t weight = 3_sz; // "{ }"
|
||||
return 2u; // "{}"
|
||||
size_t weight = 3u; // "{ }"
|
||||
for (auto&& [k, v] : n)
|
||||
{
|
||||
weight += k.length() + count_inline_columns(v) + 2_sz; // + ", "
|
||||
weight += k.length() + count_inline_columns(v) + 2u; // + ", "
|
||||
if (weight >= line_wrap_cols)
|
||||
break;
|
||||
}
|
||||
@ -12702,11 +12690,11 @@ TOML_NAMESPACE_START
|
||||
{
|
||||
auto& n = *reinterpret_cast<const array*>(&node);
|
||||
if (n.empty())
|
||||
return 2_sz; // "[]"
|
||||
size_t weight = 3_sz; // "[ ]"
|
||||
return 2u; // "[]"
|
||||
size_t weight = 3u; // "[ ]"
|
||||
for (auto& elem : n)
|
||||
{
|
||||
weight += count_inline_columns(elem) + 2_sz; // + ", "
|
||||
weight += count_inline_columns(elem) + 2u; // + ", "
|
||||
if (weight >= line_wrap_cols)
|
||||
break;
|
||||
}
|
||||
@ -12716,7 +12704,7 @@ TOML_NAMESPACE_START
|
||||
case node_type::string:
|
||||
{
|
||||
auto& n = *reinterpret_cast<const value<std::string>*>(&node);
|
||||
return n.get().length() + 2_sz; // + ""
|
||||
return n.get().length() + 2u; // + ""
|
||||
}
|
||||
|
||||
case node_type::integer:
|
||||
@ -12724,14 +12712,14 @@ TOML_NAMESPACE_START
|
||||
auto& n = *reinterpret_cast<const value<int64_t>*>(&node);
|
||||
auto v = n.get();
|
||||
if (!v)
|
||||
return 1_sz;
|
||||
return 1u;
|
||||
size_t weight = {};
|
||||
if (v < 0)
|
||||
{
|
||||
weight += 1;
|
||||
weight += 1u;
|
||||
v *= -1;
|
||||
}
|
||||
return weight + static_cast<size_t>(log10(static_cast<double>(v))) + 1_sz;
|
||||
return weight + static_cast<size_t>(log10(static_cast<double>(v))) + 1u;
|
||||
}
|
||||
|
||||
case node_type::floating_point:
|
||||
@ -12739,21 +12727,21 @@ TOML_NAMESPACE_START
|
||||
auto& n = *reinterpret_cast<const value<double>*>(&node);
|
||||
auto v = n.get();
|
||||
if (v == 0.0)
|
||||
return 3_sz; // "0.0"
|
||||
size_t weight = 2_sz; // ".0"
|
||||
return 3u; // "0.0"
|
||||
size_t weight = 2u; // ".0"
|
||||
if (v < 0.0)
|
||||
{
|
||||
weight += 1;
|
||||
weight += 1u;
|
||||
v *= -1.0;
|
||||
}
|
||||
return weight + static_cast<size_t>(log10(v)) + 1_sz;
|
||||
return weight + static_cast<size_t>(log10(v)) + 1u;
|
||||
break;
|
||||
}
|
||||
|
||||
case node_type::boolean: return 5_sz;
|
||||
case node_type::boolean: return 5u;
|
||||
case node_type::date: [[fallthrough]];
|
||||
case node_type::time: return 10_sz;
|
||||
case node_type::date_time: return 30_sz;
|
||||
case node_type::time: return 10u;
|
||||
case node_type::date_time: return 30u;
|
||||
case node_type::none: TOML_UNREACHABLE;
|
||||
default: TOML_UNREACHABLE;
|
||||
}
|
||||
@ -12879,7 +12867,7 @@ TOML_NAMESPACE_START
|
||||
|
||||
for (size_t i = 0; i < arr.size(); i++)
|
||||
{
|
||||
if (i > 0_sz)
|
||||
if (i > 0u)
|
||||
{
|
||||
impl::print_to_stream(base::stream(), ',');
|
||||
if (!multiline)
|
||||
@ -12921,7 +12909,7 @@ TOML_NAMESPACE_START
|
||||
static constexpr auto is_non_inline_array_of_tables = [](auto&& nde) noexcept
|
||||
{
|
||||
auto arr = nde.as_array();
|
||||
return arr && arr->is_array_of_tables() && !arr->template get_as<table>(0_sz)->is_inline();
|
||||
return arr && arr->is_array_of_tables() && !arr->template get_as<table>(0u)->is_inline();
|
||||
};
|
||||
|
||||
// values, arrays, and inline tables/table arrays
|
||||
@ -12984,7 +12972,7 @@ TOML_NAMESPACE_START
|
||||
}
|
||||
}
|
||||
bool skip_self = false;
|
||||
if (child_value_count == 0_sz && (child_table_count > 0_sz || child_table_array_count > 0_sz))
|
||||
if (child_value_count == 0u && (child_table_count > 0u || child_table_array_count > 0u))
|
||||
skip_self = true;
|
||||
|
||||
key_path_.push_back(make_key_segment(k));
|
||||
@ -13121,7 +13109,7 @@ TOML_NAMESPACE_START
|
||||
base::increase_indent();
|
||||
for (size_t i = 0; i < arr.size(); i++)
|
||||
{
|
||||
if (i > 0_sz)
|
||||
if (i > 0u)
|
||||
impl::print_to_stream(base::stream(), ',');
|
||||
base::print_newline(true);
|
||||
base::print_indent();
|
||||
@ -13186,7 +13174,6 @@ TOML_POP_WARNINGS;
|
||||
#undef TOML_COMPILER_EXCEPTIONS
|
||||
#undef TOML_CONCAT
|
||||
#undef TOML_CONCAT_1
|
||||
#undef TOML_CONSTEVAL
|
||||
#undef TOML_CONSTRAINED_TEMPLATE
|
||||
#undef TOML_CPP
|
||||
#undef TOML_DISABLE_ARITHMETIC_WARNINGS
|
||||
|
@ -10,6 +10,7 @@ REM ----------------------------------------------------------------------------
|
||||
CALL :RunClangFormatOnDirectories ^
|
||||
include\toml++ ^
|
||||
include\toml++\impl ^
|
||||
tests ^
|
||||
examples
|
||||
|
||||
GOTO FINISH
|
||||
|
@ -412,16 +412,17 @@ def write_test_file(name, all_tests):
|
||||
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.')
|
||||
write('// Copyright (c) Mark Gillard <mark.gillard@outlook.com.au>')
|
||||
write('// See https://github.com/marzer/tomlplusplus/blob/master/LICENSE for the full license text.')
|
||||
write('// SPDX-License-Identifier: MIT')
|
||||
write('//-----')
|
||||
write('// this file was generated by generate_conformance_tests.py - do not modify it directly')
|
||||
write('')
|
||||
write('#include "tests.h"')
|
||||
write('using namespace toml::impl;')
|
||||
write('')
|
||||
write(r'// This file is a part of toml++ and is subject to the the terms of the MIT license.')
|
||||
write(r'// Copyright (c) Mark Gillard <mark.gillard@outlook.com.au>')
|
||||
write(r'// See https://github.com/marzer/tomlplusplus/blob/master/LICENSE for the full license text.')
|
||||
write(r'// SPDX-License-Identifier: MIT')
|
||||
write(r'//-----')
|
||||
write(r'// this file was generated by generate_conformance_tests.py - do not modify it directly')
|
||||
write(r'// clang-format off')
|
||||
write(r'')
|
||||
write(r'#include "tests.h"')
|
||||
write(r'using namespace toml::impl;')
|
||||
write(r'')
|
||||
|
||||
# test data
|
||||
write('TOML_DISABLE_WARNINGS; // unused variable spam')
|
||||
|
@ -151,11 +151,11 @@ def main():
|
||||
<Natvis Include="..\..\toml++.natvis" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ClInclude Include="..\catch2.h" />
|
||||
<ClInclude Include="..\leakproof.h" />
|
||||
<ClInclude Include="..\lib_catch2.h" />
|
||||
<ClInclude Include="..\lib_tloptional.h" />
|
||||
<ClInclude Include="..\settings.h" />
|
||||
<ClInclude Include="..\tests.h" />
|
||||
<ClInclude Include="..\tloptional.h" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<None Include="..\cpp.hint" />
|
||||
|
Loading…
Reference in New Issue
Block a user