test: check preserve_comment keep it read

This commit is contained in:
ToruNiina
2019-06-18 01:25:43 +09:00
parent fb5834caab
commit 159283fdad

View File

@@ -193,6 +193,34 @@ BOOST_AUTO_TEST_CASE(test_hard_example)
BOOST_CHECK(toml::find<std::vector<std::string>>(bit, "multi_line_array") ==
expected_multi_line_array);
}
BOOST_AUTO_TEST_CASE(test_hard_example_comment)
{
const auto data = toml::parse<toml::preserve_comments>("toml/tests/hard_example.toml");
const auto the = toml::find(data, "the");
BOOST_CHECK_EQUAL(toml::find<std::string>(the, "test_string"),
"You'll hate me after this - #");
const auto hard = toml::find(the, "hard");
const std::vector<std::string> expected_the_hard_test_array{"] ", " # "};
BOOST_CHECK(toml::find<std::vector<std::string>>(hard, "test_array") ==
expected_the_hard_test_array);
const std::vector<std::string> expected_the_hard_test_array2{
"Test #11 ]proved that", "Experiment #9 was a success"};
BOOST_CHECK(toml::find<std::vector<std::string>>(hard, "test_array2") ==
expected_the_hard_test_array2);
BOOST_CHECK_EQUAL(toml::find<std::string>(hard, "another_test_string"),
" Same thing, but with a string #");
BOOST_CHECK_EQUAL(toml::find<std::string>(hard, "harder_test_string"),
" And when \"'s are in the string, along with # \"");
const auto bit = toml::find(hard, "bit#");
BOOST_CHECK_EQUAL(toml::find<std::string>(bit, "what?"),
"You don't think some user won't do that?");
const std::vector<std::string> expected_multi_line_array{"]"};
BOOST_CHECK(toml::find<std::vector<std::string>>(bit, "multi_line_array") ==
expected_multi_line_array);
}
BOOST_AUTO_TEST_CASE(test_example_preserve_comment)
{