mirror of
https://github.com/OPM/opm-simulators.git
synced 2025-02-25 18:55:30 -06:00
Support Inserting Bools Into Property Trees
While here, also add a simple unit test that as_vector<T>() returns nullopt for non-existing property nodes.
This commit is contained in:
parent
c8b5732bd6
commit
bc227ab784
@ -126,6 +126,7 @@ template void PropertyTree::put(const std::string& key, const double& value);
|
||||
template void PropertyTree::put(const std::string& key, const float& value);
|
||||
template void PropertyTree::put(const std::string& key, const int& value);
|
||||
template void PropertyTree::put(const std::string& key, const std::size_t& value);
|
||||
template void PropertyTree::put(const std::string& key, const bool& value);
|
||||
|
||||
template std::string PropertyTree::get(const std::string& key) const;
|
||||
template double PropertyTree::get(const std::string& key) const;
|
||||
|
@ -56,6 +56,7 @@ BOOST_AUTO_TEST_CASE(Top_Node_Only)
|
||||
t.put("b", 123.4);
|
||||
t.put("c", std::string { "hello" });
|
||||
t.put("d", 12.34f);
|
||||
t.put("e", true);
|
||||
|
||||
{
|
||||
const auto a = t.get<int>("a");
|
||||
@ -88,6 +89,14 @@ BOOST_AUTO_TEST_CASE(Top_Node_Only)
|
||||
const auto dd = t.get("dd", -1.618f);
|
||||
BOOST_CHECK_CLOSE(dd, -1.618f, 1.0e-6f);
|
||||
}
|
||||
|
||||
{
|
||||
const auto e = t.get<bool>("e");
|
||||
BOOST_CHECK_EQUAL(e, true);
|
||||
|
||||
const auto ee = t.get<bool>("ee", false);
|
||||
BOOST_CHECK_EQUAL(ee, false);
|
||||
}
|
||||
}
|
||||
|
||||
BOOST_AUTO_TEST_CASE(Size_T)
|
||||
@ -278,6 +287,11 @@ BOOST_AUTO_TEST_CASE(Vector)
|
||||
expect.begin(), expect.end());
|
||||
}
|
||||
|
||||
{
|
||||
const auto aa = t.get_child_items_as_vector<int>("aa");
|
||||
BOOST_CHECK_MESSAGE(!aa.has_value(), R"(Node "aa" must NOT exist)");
|
||||
}
|
||||
|
||||
{
|
||||
const auto b = t.get_child_items_as_vector<double>("b");
|
||||
BOOST_REQUIRE_MESSAGE(b.has_value(), R"(Node "b" must exist)");
|
||||
|
Loading…
Reference in New Issue
Block a user