mirror of
https://github.com/OPM/opm-simulators.git
synced 2026-10-25 07:07:42 -05:00
Implement Property Tree Put/Get for std::size_t
This replaces the original specialisations for "bare" size_t from the <stddef.h> header. While here, also reorder the specialisations to match declaration order in the header.
This commit is contained in:
1 parent
9fb46ab420
commit
999f98e281
2 files changed
+26
-9
No files matched your search
@@ -36,9 +36,11 @@
|
||||
|
||||
#include <opm/common/utility/FileSystem.hpp>
|
||||
|
||||
#include <cstddef>
|
||||
#include <filesystem>
|
||||
#include <fstream>
|
||||
#include <ios>
|
||||
#include <limits>
|
||||
#include <stdexcept>
|
||||
#include <string>
|
||||
#include <string_view>
|
||||
@@ -88,6 +90,21 @@ BOOST_AUTO_TEST_CASE(Top_Node_Only)
|
||||
}
|
||||
}
|
||||
|
||||
BOOST_AUTO_TEST_CASE(Size_T)
|
||||
{
|
||||
auto t = Opm::PropertyTree{};
|
||||
|
||||
t.put("s.ramanujan", std::size_t{1729});
|
||||
BOOST_CHECK_EQUAL(t.get<std::size_t>("s.ramanujan"), std::size_t{1729});
|
||||
|
||||
t.put("m", static_cast<std::size_t>(-1));
|
||||
BOOST_CHECK_EQUAL(t.get<std::size_t>("m"), std::numeric_limits<std::size_t>::max());
|
||||
|
||||
// Conversion: int -> std::size_t
|
||||
t.put("n", -1);
|
||||
BOOST_CHECK_EQUAL(t.get<std::size_t>("n"), std::numeric_limits<std::size_t>::max());
|
||||
}
|
||||
|
||||
BOOST_AUTO_TEST_CASE(Missing_Keys)
|
||||
{
|
||||
auto t = Opm::PropertyTree{};
|
||||
|
||||
Reference in new issue
Block a user