From c205c762fefc0266547f16f0f67fab9ac38010c6 Mon Sep 17 00:00:00 2001 From: ToruNiina Date: Wed, 16 Sep 2020 21:25:04 +0900 Subject: [PATCH] test: remove needless `u8`s from ascii characters --- tests/test_comments.cpp | 50 +++++++++++++++++----------------- tests/test_lex_key_comment.cpp | 7 ++--- tests/test_lex_string.cpp | 10 ++----- tests/test_parse_unicode.cpp | 33 ---------------------- tests/test_windows.cpp | 2 +- 5 files changed, 31 insertions(+), 71 deletions(-) diff --git a/tests/test_comments.cpp b/tests/test_comments.cpp index 797c39d..5ae1e0d 100644 --- a/tests/test_comments.cpp +++ b/tests/test_comments.cpp @@ -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. diff --git a/tests/test_lex_key_comment.cpp b/tests/test_lex_key_comment.cpp index be4b176..0921bd6 100644 --- a/tests/test_lex_key_comment.cpp +++ b/tests/test_lex_key_comment.cpp @@ -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\"'"); } diff --git a/tests/test_lex_string.cpp b/tests/test_lex_string.cpp index dadfcde..643ab31 100644 --- a/tests/test_lex_string.cpp +++ b/tests/test_lex_string.cpp @@ -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 - #\"", diff --git a/tests/test_parse_unicode.cpp b/tests/test_parse_unicode.cpp index dbfe601..e3797a6 100644 --- a/tests/test_parse_unicode.cpp +++ b/tests/test_parse_unicode.cpp @@ -9,7 +9,6 @@ #include #include -#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>(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(data, "the"); - BOOST_TEST(toml::get(the.at("test_string")) == - std::string(u8"Ýôú'ℓℓ λáƭè ₥è áƒƭèř ƭλïƨ - #")); - - const auto hard = toml::get(the.at("hard")); - const std::vector expected_the_hard_test_array{"] ", " # "}; - BOOST_CHECK(toml::get>(hard.at("test_array")) == - expected_the_hard_test_array); - const std::vector expected_the_hard_test_array2{ - std::string(u8"Tèƨƭ #11 ]ƥřôƲèδ ƭλáƭ"), - std::string(u8"Éжƥèřï₥èñƭ #9 ωáƨ á ƨúççèƨƨ")}; - BOOST_CHECK(toml::get>(hard.at("test_array2")) == - expected_the_hard_test_array2); - BOOST_TEST(toml::get(hard.at("another_test_string")) == - std::string(u8"§á₥è ƭλïñϱ, βúƭ ωïƭλ á ƨƭřïñϱ #")); - BOOST_TEST(toml::get(hard.at("harder_test_string")) == - std::string(u8" Âñδ ωλèñ \"'ƨ ářè ïñ ƭλè ƨƭřïñϱ, áℓôñϱ ωïƭλ # \"")); - - const auto bit = toml::get(hard.at(std::string(u8"βïƭ#"))); - BOOST_TEST(toml::get(bit.at(std::string(u8"ωλáƭ?"))) == - std::string(u8"Ýôú δôñ'ƭ ƭλïñƙ ƨô₥è úƨèř ωôñ'ƭ δô ƭλáƭ?")); - const std::vector expected_multi_line_array{"]"}; - BOOST_CHECK(toml::get>(bit.at("multi_line_array")) == - expected_multi_line_array); - -} -#endif diff --git a/tests/test_windows.cpp b/tests/test_windows.cpp index 158c115..b178a26 100644 --- a/tests/test_windows.cpp +++ b/tests/test_windows.cpp @@ -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(data, "windows") << std::endl; return 0;