mirror of
https://github.com/ToruNiina/toml11.git
synced 2024-11-21 20:10:05 +00:00
test: remove needless u8
s from ascii characters
This commit is contained in:
parent
a32cd6cb61
commit
c205c762fe
@ -11,7 +11,7 @@
|
||||
BOOST_AUTO_TEST_CASE(test_comment_before)
|
||||
{
|
||||
{
|
||||
const std::string file = u8R"(
|
||||
const std::string file = R"(
|
||||
# comment for a.
|
||||
a = 42
|
||||
# comment for b.
|
||||
@ -24,12 +24,12 @@ BOOST_AUTO_TEST_CASE(test_comment_before)
|
||||
const auto& b = toml::find(v, "b");
|
||||
|
||||
BOOST_TEST(a.comments().size() == 1u);
|
||||
BOOST_TEST(a.comments().front() == u8" comment for a.");
|
||||
BOOST_TEST(a.comments().front() == " comment for a.");
|
||||
BOOST_TEST(b.comments().size() == 1u);
|
||||
BOOST_TEST(b.comments().front() == u8" comment for b.");
|
||||
BOOST_TEST(b.comments().front() == " comment for b.");
|
||||
}
|
||||
{
|
||||
const std::string file = u8R"(
|
||||
const std::string file = R"(
|
||||
# comment for a.
|
||||
# another comment for a.
|
||||
a = 42
|
||||
@ -45,18 +45,18 @@ BOOST_AUTO_TEST_CASE(test_comment_before)
|
||||
const auto& b = toml::find(v, "b");
|
||||
|
||||
BOOST_TEST(a.comments().size() == 2u);
|
||||
BOOST_TEST(a.comments().front() == u8" comment for a.");
|
||||
BOOST_TEST(a.comments().back() == u8" another comment for a.");
|
||||
BOOST_TEST(a.comments().front() == " comment for a.");
|
||||
BOOST_TEST(a.comments().back() == " another comment for a.");
|
||||
BOOST_TEST(b.comments().size() == 2u);
|
||||
BOOST_TEST(b.comments().front() == u8" comment for b.");
|
||||
BOOST_TEST(b.comments().back() == u8" also comment for b.");
|
||||
BOOST_TEST(b.comments().front() == " comment for b.");
|
||||
BOOST_TEST(b.comments().back() == " also comment for b.");
|
||||
}
|
||||
}
|
||||
|
||||
BOOST_AUTO_TEST_CASE(test_comment_inline)
|
||||
{
|
||||
{
|
||||
const std::string file = u8R"(
|
||||
const std::string file = R"(
|
||||
a = 42 # comment for a.
|
||||
b = "baz" # comment for b.
|
||||
)";
|
||||
@ -68,12 +68,12 @@ BOOST_AUTO_TEST_CASE(test_comment_inline)
|
||||
const auto& b = toml::find(v, "b");
|
||||
|
||||
BOOST_TEST(a.comments().size() == 1u);
|
||||
BOOST_TEST(a.comments().front() == u8" comment for a.");
|
||||
BOOST_TEST(a.comments().front() == " comment for a.");
|
||||
BOOST_TEST(b.comments().size() == 1u);
|
||||
BOOST_TEST(b.comments().front() == u8" comment for b.");
|
||||
BOOST_TEST(b.comments().front() == " comment for b.");
|
||||
}
|
||||
{
|
||||
const std::string file = u8R"(
|
||||
const std::string file = R"(
|
||||
a = [
|
||||
42,
|
||||
] # comment for a.
|
||||
@ -90,18 +90,18 @@ BOOST_AUTO_TEST_CASE(test_comment_inline)
|
||||
const auto& b0 = b.as_array().at(0);
|
||||
|
||||
BOOST_TEST(a.comments().size() == 1u);
|
||||
BOOST_TEST(a.comments().front() == u8" comment for a.");
|
||||
BOOST_TEST(a.comments().front() == " comment for a.");
|
||||
BOOST_TEST(b.comments().size() == 1u);
|
||||
BOOST_TEST(b.comments().front() == u8" this is a comment for b.");
|
||||
BOOST_TEST(b.comments().front() == " this is a comment for b.");
|
||||
BOOST_TEST(b0.comments().size() == 1u);
|
||||
BOOST_TEST(b0.comments().front() == u8" this is not a comment for b, but \"bar\"");
|
||||
BOOST_TEST(b0.comments().front() == " this is not a comment for b, but \"bar\"");
|
||||
}
|
||||
}
|
||||
|
||||
BOOST_AUTO_TEST_CASE(test_comment_both)
|
||||
{
|
||||
{
|
||||
const std::string file = u8R"(
|
||||
const std::string file = R"(
|
||||
# comment for a.
|
||||
a = 42 # inline comment for a.
|
||||
# comment for b.
|
||||
@ -122,25 +122,25 @@ BOOST_AUTO_TEST_CASE(test_comment_both)
|
||||
const auto& c0 = c.as_array().at(0);
|
||||
|
||||
BOOST_TEST(a.comments().size() == 2u);
|
||||
BOOST_TEST(a.comments().front() == u8" comment for a.");
|
||||
BOOST_TEST(a.comments().back() == u8" inline comment for a.");
|
||||
BOOST_TEST(a.comments().front() == " comment for a.");
|
||||
BOOST_TEST(a.comments().back() == " inline comment for a.");
|
||||
BOOST_TEST(b.comments().size() == 2u);
|
||||
BOOST_TEST(b.comments().front() == u8" comment for b.");
|
||||
BOOST_TEST(b.comments().back() == u8" inline comment for b.");
|
||||
BOOST_TEST(b.comments().front() == " comment for b.");
|
||||
BOOST_TEST(b.comments().back() == " inline comment for b.");
|
||||
|
||||
BOOST_TEST(c.comments().size() == 2u);
|
||||
BOOST_TEST(c.comments().front() == u8" comment for c.");
|
||||
BOOST_TEST(c.comments().back() == u8" another comment for c.");
|
||||
BOOST_TEST(c.comments().front() == " comment for c.");
|
||||
BOOST_TEST(c.comments().back() == " another comment for c.");
|
||||
|
||||
BOOST_TEST(c0.comments().size() == 2u);
|
||||
BOOST_TEST(c0.comments().front() == u8" comment for the first element.");
|
||||
BOOST_TEST(c0.comments().back() == u8" this also.");
|
||||
BOOST_TEST(c0.comments().front() == " comment for the first element.");
|
||||
BOOST_TEST(c0.comments().back() == " this also.");
|
||||
}
|
||||
}
|
||||
|
||||
BOOST_AUTO_TEST_CASE(test_discard_comment)
|
||||
{
|
||||
const std::string file = u8R"(
|
||||
const std::string file = R"(
|
||||
# comment for a.
|
||||
a = 42 # inline comment for a.
|
||||
# comment for b.
|
||||
|
@ -18,12 +18,11 @@ BOOST_AUTO_TEST_CASE(test_quoted_key)
|
||||
{
|
||||
TOML11_TEST_LEX_ACCEPT(lex_key, "\"127.0.0.1\"", "\"127.0.0.1\"");
|
||||
TOML11_TEST_LEX_ACCEPT(lex_key, "\"character encoding\"", "\"character encoding\"");
|
||||
#if defined(_MSC_VER) || defined(__INTEL_COMPILER)
|
||||
|
||||
// UTF-8 codepoint of characters that looks like "key" written upside down
|
||||
TOML11_TEST_LEX_ACCEPT(lex_key, "\"\xCA\x8E\xC7\x9D\xCA\x9E\"",
|
||||
"\"\xCA\x8E\xC7\x9D\xCA\x9E\"");
|
||||
#else
|
||||
TOML11_TEST_LEX_ACCEPT(lex_key, u8"\"ʎǝʞ\"", u8"\"ʎǝʞ\"");
|
||||
#endif
|
||||
|
||||
TOML11_TEST_LEX_ACCEPT(lex_key, "'key2'", "'key2'");
|
||||
TOML11_TEST_LEX_ACCEPT(lex_key, "'quoted \"value\"'", "'quoted \"value\"'");
|
||||
}
|
||||
|
@ -31,15 +31,9 @@ BOOST_AUTO_TEST_CASE(test_basic_string)
|
||||
"\"192.168.1.1\"",
|
||||
"\"192.168.1.1\"");
|
||||
|
||||
#if defined(_MSC_VER) || defined(__INTEL_COMPILER)
|
||||
TOML11_TEST_LEX_ACCEPT(lex_string,
|
||||
"\"\xE4\xB8\xAD\xE5\x9B\xBD\"",
|
||||
"\"\xE4\xB8\xAD\xE5\x9B\xBD\"");
|
||||
#else
|
||||
TOML11_TEST_LEX_ACCEPT(lex_string,
|
||||
u8"\"中国\"",
|
||||
u8"\"中国\"");
|
||||
#endif
|
||||
"\"\xE4\xB8\xAD\xE5\x9B\xBD\"", // UTF-8 string (means "China" in
|
||||
"\"\xE4\xB8\xAD\xE5\x9B\xBD\""); // Chinese characters)
|
||||
|
||||
TOML11_TEST_LEX_ACCEPT(lex_string,
|
||||
"\"You'll hate me after this - #\"",
|
||||
|
@ -9,7 +9,6 @@
|
||||
#include <iostream>
|
||||
#include <fstream>
|
||||
|
||||
#if defined(_MSC_VER) || defined(__INTEL_COMPILER)
|
||||
BOOST_AUTO_TEST_CASE(test_hard_example_unicode)
|
||||
{
|
||||
const auto data = toml::parse("toml/tests/hard_example_unicode.toml");
|
||||
@ -40,35 +39,3 @@ BOOST_AUTO_TEST_CASE(test_hard_example_unicode)
|
||||
BOOST_CHECK(toml::get<std::vector<std::string>>(bit.at("multi_line_array")) ==
|
||||
expected_multi_line_array);
|
||||
}
|
||||
#else
|
||||
BOOST_AUTO_TEST_CASE(test_hard_example_unicode)
|
||||
{
|
||||
const auto data = toml::parse("toml/tests/hard_example_unicode.toml");
|
||||
|
||||
const auto the = toml::find<toml::table>(data, "the");
|
||||
BOOST_TEST(toml::get<std::string>(the.at("test_string")) ==
|
||||
std::string(u8"Ýôú'ℓℓ λáƭè ₥è áƒƭèř ƭλïƨ - #"));
|
||||
|
||||
const auto hard = toml::get<toml::table>(the.at("hard"));
|
||||
const std::vector<std::string> expected_the_hard_test_array{"] ", " # "};
|
||||
BOOST_CHECK(toml::get<std::vector<std::string>>(hard.at("test_array")) ==
|
||||
expected_the_hard_test_array);
|
||||
const std::vector<std::string> expected_the_hard_test_array2{
|
||||
std::string(u8"Tèƨƭ #11 ]ƥřôƲèδ ƭλáƭ"),
|
||||
std::string(u8"Éжƥèřï₥èñƭ #9 ωáƨ á ƨúççèƨƨ")};
|
||||
BOOST_CHECK(toml::get<std::vector<std::string>>(hard.at("test_array2")) ==
|
||||
expected_the_hard_test_array2);
|
||||
BOOST_TEST(toml::get<std::string>(hard.at("another_test_string")) ==
|
||||
std::string(u8"§á₥è ƭλïñϱ, βúƭ ωïƭλ á ƨƭřïñϱ #"));
|
||||
BOOST_TEST(toml::get<std::string>(hard.at("harder_test_string")) ==
|
||||
std::string(u8" Âñδ ωλèñ \"'ƨ ářè ïñ ƭλè ƨƭřïñϱ, áℓôñϱ ωïƭλ # \""));
|
||||
|
||||
const auto bit = toml::get<toml::table>(hard.at(std::string(u8"βïƭ#")));
|
||||
BOOST_TEST(toml::get<std::string>(bit.at(std::string(u8"ωλáƭ?"))) ==
|
||||
std::string(u8"Ýôú δôñ'ƭ ƭλïñƙ ƨô₥è úƨèř ωôñ'ƭ δô ƭλáƭ?"));
|
||||
const std::vector<std::string> expected_multi_line_array{"]"};
|
||||
BOOST_CHECK(toml::get<std::vector<std::string>>(bit.at("multi_line_array")) ==
|
||||
expected_multi_line_array);
|
||||
|
||||
}
|
||||
#endif
|
||||
|
@ -5,7 +5,7 @@
|
||||
int main()
|
||||
{
|
||||
using namespace toml::literals::toml_literals;
|
||||
const auto data = u8R"(windows = "defines min and max as a macro")"_toml;
|
||||
const auto data = R"(windows = "defines min and max as a macro")"_toml;
|
||||
|
||||
std::cout << toml::find<std::string>(data, "windows") << std::endl;
|
||||
return 0;
|
||||
|
Loading…
Reference in New Issue
Block a user