mirror of
https://github.com/ToruNiina/toml11.git
synced 2024-11-23 04:40:06 +00:00
test: add test of find_or with conversion
This commit is contained in:
parent
15b68a89c6
commit
c9543d8d9e
@ -358,3 +358,36 @@ BOOST_AUTO_TEST_CASE(test_find_or_string)
|
|||||||
BOOST_TEST("bazqux" == toml::find_or(v2, "key", lit));
|
BOOST_TEST("bazqux" == toml::find_or(v2, "key", lit));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
BOOST_AUTO_TEST_CASE(test_find_or_map)
|
||||||
|
{
|
||||||
|
using map_type = std::map<std::string, std::string>;
|
||||||
|
{
|
||||||
|
const toml::value v1{
|
||||||
|
{"key", {{"key", "value"}}}
|
||||||
|
};
|
||||||
|
|
||||||
|
const auto key = toml::find_or(v1, "key", map_type{});
|
||||||
|
const auto key2 = toml::find_or(v1, "key2", map_type{});
|
||||||
|
|
||||||
|
BOOST_TEST(!key.empty());
|
||||||
|
BOOST_TEST(key2.empty());
|
||||||
|
|
||||||
|
BOOST_TEST(key.size() == 1u);
|
||||||
|
BOOST_TEST(key.at("key") == "value");
|
||||||
|
}
|
||||||
|
{
|
||||||
|
const toml::value v1{
|
||||||
|
{"key", {{"key", "value"}}}
|
||||||
|
};
|
||||||
|
|
||||||
|
const auto key = toml::find_or<map_type>(v1, "key", map_type{});
|
||||||
|
const auto key2 = toml::find_or<map_type>(v1, "key2", map_type{});
|
||||||
|
|
||||||
|
BOOST_TEST(!key.empty());
|
||||||
|
BOOST_TEST(key2.empty());
|
||||||
|
|
||||||
|
BOOST_TEST(key.size() == 1u);
|
||||||
|
BOOST_TEST(key.at("key") == "value");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user