mirror of
https://github.com/ToruNiina/toml11.git
synced 2025-01-10 09:20:11 +00:00
test: remove default ctor from test code
This commit is contained in:
parent
79594709fe
commit
4d0ed847f9
@ -47,8 +47,6 @@ struct qux
|
||||
|
||||
struct foobar
|
||||
{
|
||||
foobar() = default; // later we use std::vector<foobar>, default ctor is required.
|
||||
|
||||
// via constructor
|
||||
explicit foobar(const toml::value& v)
|
||||
: a(toml::find<int>(v, "a")), b(toml::find<std::string>(v, "b"))
|
||||
@ -137,8 +135,6 @@ struct qux
|
||||
|
||||
struct foobar
|
||||
{
|
||||
foobar() = default; // later we use std::vector<foobar>, default ctor is required.
|
||||
|
||||
template<typename C, template<typename ...> class M, template<typename ...> class A>
|
||||
explicit foobar(const toml::basic_value<C, M, A>& v)
|
||||
: a(toml::find<int>(v, "a")), b(toml::find<std::string>(v, "b"))
|
||||
@ -488,5 +484,64 @@ BOOST_AUTO_TEST_CASE(test_recursive_conversion)
|
||||
BOOST_TEST(foobars.at(2).b == "quux");
|
||||
BOOST_TEST(foobars.at(3).b == "foobar");
|
||||
}
|
||||
|
||||
// via constructor
|
||||
{
|
||||
const toml::value v{
|
||||
{"0", toml::table{{"a", 42}, {"b", "baz"}}},
|
||||
{"1", toml::table{{"a", 43}, {"b", "qux"}}},
|
||||
{"2", toml::table{{"a", 44}, {"b", "quux"}}},
|
||||
{"3", toml::table{{"a", 45}, {"b", "foobar"}}}
|
||||
};
|
||||
|
||||
{
|
||||
const auto foobars = toml::get<std::map<std::string, extlib::foobar>>(v);
|
||||
BOOST_TEST(foobars.size() == 4ul);
|
||||
BOOST_TEST(foobars.at("0").a == 42);
|
||||
BOOST_TEST(foobars.at("1").a == 43);
|
||||
BOOST_TEST(foobars.at("2").a == 44);
|
||||
BOOST_TEST(foobars.at("3").a == 45);
|
||||
|
||||
BOOST_TEST(foobars.at("0").b == "baz");
|
||||
BOOST_TEST(foobars.at("1").b == "qux");
|
||||
BOOST_TEST(foobars.at("2").b == "quux");
|
||||
BOOST_TEST(foobars.at("3").b == "foobar");
|
||||
}
|
||||
{
|
||||
const auto foobars = toml::get<std::map<std::string, extlib2::foobar>>(v);
|
||||
BOOST_TEST(foobars.size() == 4ul);
|
||||
BOOST_TEST(foobars.at("0").a == 42);
|
||||
BOOST_TEST(foobars.at("1").a == 43);
|
||||
BOOST_TEST(foobars.at("2").a == 44);
|
||||
BOOST_TEST(foobars.at("3").a == 45);
|
||||
|
||||
BOOST_TEST(foobars.at("0").b == "baz");
|
||||
BOOST_TEST(foobars.at("1").b == "qux");
|
||||
BOOST_TEST(foobars.at("2").b == "quux");
|
||||
BOOST_TEST(foobars.at("3").b == "foobar");
|
||||
}
|
||||
}
|
||||
{
|
||||
const toml::basic_value<toml::discard_comments, std::map, std::deque>
|
||||
v{
|
||||
{"0", toml::table{{"a", 42}, {"b", "baz"}}},
|
||||
{"1", toml::table{{"a", 43}, {"b", "qux"}}},
|
||||
{"2", toml::table{{"a", 44}, {"b", "quux"}}},
|
||||
{"3", toml::table{{"a", 45}, {"b", "foobar"}}}
|
||||
};
|
||||
|
||||
const auto foobars = toml::get<std::map<std::string, extlib::foobar>>(v);
|
||||
BOOST_TEST(foobars.size() == 4ul);
|
||||
BOOST_TEST(foobars.at("0").a == 42);
|
||||
BOOST_TEST(foobars.at("1").a == 43);
|
||||
BOOST_TEST(foobars.at("2").a == 44);
|
||||
BOOST_TEST(foobars.at("3").a == 45);
|
||||
|
||||
BOOST_TEST(foobars.at("0").b == "baz");
|
||||
BOOST_TEST(foobars.at("1").b == "qux");
|
||||
BOOST_TEST(foobars.at("2").b == "quux");
|
||||
BOOST_TEST(foobars.at("3").b == "foobar");
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user