Add operator== to SummaryState

This commit is contained in:
Joakim Hove
2020-11-21 09:33:33 +01:00
parent 8f65921753
commit 25beb52f68
3 changed files with 16 additions and 43 deletions
+2 -43
View File
@@ -3523,59 +3523,18 @@ BOOST_AUTO_TEST_CASE(SummaryState_TOTAL) {
BOOST_CHECK_EQUAL(st.get_elapsed(), 200);
}
namespace {
bool equal(const SummaryState& st1 , const SummaryState& st2) {
if (st1.size() != st2.size())
return false;
{
const auto& wells2 = st2.wells();
if (wells2.size() != st1.wells().size())
return false;
for (const auto& well : st1.wells()) {
auto f = std::find(wells2.begin(), wells2.end(), well);
if (f == wells2.end())
return false;
}
}
{
const auto& groups2 = st2.groups();
if (groups2.size() != st1.groups().size())
return false;
for (const auto& group : st1.groups()) {
auto f = std::find(groups2.begin(), groups2.end(), group);
if (f == groups2.end())
return false;
}
}
for (const auto& value_pair : st1) {
const std::string& key = value_pair.first;
double value = value_pair.second;
if (value != st2.get(key))
return false;
}
return st1.get_elapsed() == st2.get_elapsed();
}
void test_serialize(const SummaryState& st) {
SummaryState st2(std::chrono::system_clock::now());
auto serial = st.serialize();
st2.deserialize(serial);
BOOST_CHECK( equal(st, st2));
BOOST_CHECK( st == st2 );
st2.update_elapsed(1234567.09);
st2.update("FOPT", 200);
st2.deserialize(serial);
BOOST_CHECK( equal(st, st2));
BOOST_CHECK(st == st2);
}
} // Anonymous namespace
BOOST_AUTO_TEST_CASE(serialize_sumary_state) {
SummaryState st(std::chrono::system_clock::now());