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:
Mark Gillard
2021-10-26 16:49:23 +03:00
parent 7da912c45e
commit dbc078202d
78 changed files with 2165 additions and 2303 deletions

View File

@@ -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>
@@ -52,7 +44,7 @@ struct codepoint_range
TOML_NODISCARD_CTOR
constexpr codepoint_range(T first_, U last_) noexcept
: first{ static_cast<char32_t>(first_) },
last{ static_cast<char32_t>(last_) }
last{ static_cast<char32_t>(last_) }
{
if (last < first)
std::swap(first, last);
@@ -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 }
{}
};
@@ -93,53 +83,53 @@ inline bool not_in(func_type* fptr, codepoint_range range) noexcept
TEST_CASE("unicode - is_ascii_letter")
{
static constexpr auto fn = is_ascii_letter;
REQUIRE(not_in(fn, { U'\0', U'@' }));
REQUIRE(in_only(fn, { U'A', U'Z' }));
REQUIRE(not_in(fn, { U'[', U'`' }));
REQUIRE(in_only(fn, { U'a', U'z' }));
REQUIRE(not_in(fn, { U'{', unimax }));
REQUIRE(not_in(fn, { U'\0', U'@' }));
REQUIRE(in_only(fn, { U'A', U'Z' }));
REQUIRE(not_in(fn, { U'[', U'`' }));
REQUIRE(in_only(fn, { U'a', U'z' }));
REQUIRE(not_in(fn, { U'{', unimax }));
}
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(not_in(fn, { U'\n', U'\u001F' }));
REQUIRE(in_only(fn, U' ' ));
REQUIRE(not_in(fn, { U'!', unimax }));
REQUIRE(not_in(fn, { U'\0', U'\u0008' }));
REQUIRE(in_only(fn, U'\t'));
REQUIRE(not_in(fn, { U'\n', U'\u001F' }));
REQUIRE(in_only(fn, U' '));
REQUIRE(not_in(fn, { U'!', unimax }));
}
TEST_CASE("unicode - is_ascii_line_break")
{
static constexpr auto fn = is_ascii_line_break<true>;
REQUIRE(not_in(fn, { U'\0', U'\t' }));
REQUIRE(in_only(fn, { U'\n', U'\r' }));
REQUIRE(not_in(fn, { U'\u000E', unimax }));
REQUIRE(not_in(fn, { U'\0', U'\t' }));
REQUIRE(in_only(fn, { U'\n', U'\r' }));
REQUIRE(not_in(fn, { U'\u000E', unimax }));
}
TEST_CASE("unicode - is_binary_digit")
{
static constexpr auto fn = is_binary_digit;
REQUIRE(not_in(fn, { U'\0', U'/' }));
REQUIRE(in(fn, { U'0', U'1' }));
REQUIRE(not_in(fn, { U'2', unimax }));
REQUIRE(not_in(fn, { U'\0', U'/' }));
REQUIRE(in(fn, { U'0', U'1' }));
REQUIRE(not_in(fn, { U'2', unimax }));
}
TEST_CASE("unicode - is_octal_digit")
{
static constexpr auto fn = is_octal_digit;
REQUIRE(not_in(fn, { U'\0', U'/' }));
REQUIRE(in(fn, { U'0', U'7' }));
REQUIRE(not_in(fn, { U'8', unimax }));
REQUIRE(not_in(fn, { U'\0', U'/' }));
REQUIRE(in(fn, { U'0', U'7' }));
REQUIRE(not_in(fn, { U'8', unimax }));
}
TEST_CASE("unicode - is_decimal_digit")
{
static constexpr auto fn = is_decimal_digit;
REQUIRE(not_in(fn, { U'\0', U'/' }));
REQUIRE(in(fn, { U'0', U'9' }));
REQUIRE(not_in(fn, { U':', unimax }));
REQUIRE(not_in(fn, { U'\0', U'/' }));
REQUIRE(in(fn, { U'0', U'9' }));
REQUIRE(not_in(fn, { U':', unimax }));
}
TEST_CASE("unicode - hex_to_dec")
@@ -171,45 +161,45 @@ TEST_CASE("unicode - hex_to_dec")
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(not_in(fn, { U'#', U'&' }));
REQUIRE(in_only(fn, U'\'' ));
REQUIRE(not_in(fn, { U'(', unimax }));
REQUIRE(not_in(fn, { U'\0', U'!' }));
REQUIRE(in_only(fn, U'"'));
REQUIRE(not_in(fn, { U'#', U'&' }));
REQUIRE(in_only(fn, U'\''));
REQUIRE(not_in(fn, { U'(', unimax }));
}
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(not_in(fn, { U'\u00A1', U'\u167F' }));
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(not_in(fn, { U'\u2030', U'\u205E' }));
REQUIRE(in_only(fn, U'\u205F' ));
REQUIRE(not_in(fn, { U'\u2060', U'\u2FFF' }));
REQUIRE(in_only(fn, U'\u3000' ));
REQUIRE(not_in(fn, { U'\u3001', unimax }));
REQUIRE(not_in(fn, { U'\0', U'\u009F' }));
REQUIRE(in_only(fn, U'\u00A0'));
REQUIRE(not_in(fn, { U'\u00A1', U'\u167F' }));
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(not_in(fn, { U'\u2030', U'\u205E' }));
REQUIRE(in_only(fn, U'\u205F'));
REQUIRE(not_in(fn, { U'\u2060', U'\u2FFF' }));
REQUIRE(in_only(fn, U'\u3000'));
REQUIRE(not_in(fn, { U'\u3001', unimax }));
}
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(not_in(fn, { U'\u0086', U'\u2027' }));
REQUIRE(in_only(fn, { U'\u2028', U'\u2029' }));
REQUIRE(not_in(fn, { U'\u202A', unimax }));
REQUIRE(not_in(fn, { U'\0', U'\u0084' }));
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 }));
}
TEST_CASE("unicode - is_unicode_surrogate")
{
static constexpr auto fn = is_unicode_surrogate;
REQUIRE(not_in(fn, { U'\0', 0xD7FFu }));
REQUIRE(in_only(fn, { 0xD800u, 0xDFFF }));
REQUIRE(not_in(fn, { 0xE000, unimax }));
REQUIRE(not_in(fn, { U'\0', 0xD7FFu }));
REQUIRE(in_only(fn, { 0xD800u, 0xDFFF }));
REQUIRE(not_in(fn, { 0xE000, unimax }));
}