mirror of
https://github.com/ToruNiina/toml11.git
synced 2025-01-09 17:10:10 +00:00
test: add test for comment duplication
This commit is contained in:
parent
f283a257d2
commit
290dca3d67
@ -138,6 +138,43 @@ BOOST_AUTO_TEST_CASE(test_comment_both)
|
||||
}
|
||||
}
|
||||
|
||||
BOOST_AUTO_TEST_CASE(test_comments_on_implicit_values)
|
||||
{
|
||||
{
|
||||
const std::string file = R"(
|
||||
# comment for the first element of array-of-tables.
|
||||
[[array-of-tables]]
|
||||
foo = "bar"
|
||||
)";
|
||||
std::istringstream iss(file);
|
||||
const auto v = toml::parse<toml::preserve_comments>(iss);
|
||||
|
||||
const auto aot = toml::find(v, "array-of-tables");
|
||||
const auto elm = aot.at(0);
|
||||
BOOST_TEST(aot.comments().empty());
|
||||
BOOST_TEST(elm.comments().size() == 1);
|
||||
BOOST_TEST(elm.comments().front() == " comment for the first element of array-of-tables.");
|
||||
}
|
||||
{
|
||||
const std::string file = R"(
|
||||
# comment for the array itself
|
||||
array-of-tables = [
|
||||
# comment for the first element of array-of-tables.
|
||||
{foo = "bar"}
|
||||
]
|
||||
)";
|
||||
std::istringstream iss(file);
|
||||
const auto v = toml::parse<toml::preserve_comments>(iss);
|
||||
|
||||
const auto aot = toml::find(v, "array-of-tables");
|
||||
const auto elm = aot.at(0);
|
||||
BOOST_TEST(aot.comments().size() == 1);
|
||||
BOOST_TEST(aot.comments().front() == " comment for the array itself");
|
||||
BOOST_TEST(elm.comments().size() == 1);
|
||||
BOOST_TEST(elm.comments().front() == " comment for the first element of array-of-tables.");
|
||||
}
|
||||
}
|
||||
|
||||
BOOST_AUTO_TEST_CASE(test_discard_comment)
|
||||
{
|
||||
const std::string file = R"(
|
||||
|
Loading…
Reference in New Issue
Block a user