Update DAY, MNTH and YEAR fields in SummaryState
This commit is contained in:
@@ -27,6 +27,7 @@
|
||||
#include <exception>
|
||||
#include <stdexcept>
|
||||
#include <unordered_map>
|
||||
#include <ctime>
|
||||
|
||||
#include <ert/ecl/ecl_sum.h>
|
||||
#include <ert/ecl/smspec_node.h>
|
||||
@@ -1550,7 +1551,7 @@ BOOST_AUTO_TEST_CASE(Test_SummaryState) {
|
||||
BOOST_CHECK_EQUAL(std::count(all_wells.begin(), all_wells.end(), "OP2"), 1);
|
||||
BOOST_CHECK_EQUAL(std::count(all_wells.begin(), all_wells.end(), "OP3"), 1);
|
||||
|
||||
BOOST_CHECK_EQUAL(st.size(), 8);
|
||||
BOOST_CHECK_EQUAL(st.size(), 11); // Size = 8 + 3 - where the the three are DAY, MNTH and YEAR
|
||||
|
||||
// The well 'OP_2' which was indirectly added with the
|
||||
// st.update("WWCT:OP_2", 100) call is *not* counted as a well!
|
||||
@@ -3201,4 +3202,30 @@ BOOST_AUTO_TEST_CASE(serialize_sumary_state) {
|
||||
|
||||
}
|
||||
|
||||
|
||||
BOOST_AUTO_TEST_CASE(SummaryState__TIME) {
|
||||
struct tm ts;
|
||||
ts.tm_year = 100;
|
||||
ts.tm_mon = 1;
|
||||
ts.tm_mday = 1;
|
||||
ts.tm_hour = 0;
|
||||
ts.tm_min = 0;
|
||||
ts.tm_sec = 0;
|
||||
auto start_time = timegm(&ts);
|
||||
SummaryState st(std::chrono::system_clock::from_time_t(start_time));
|
||||
BOOST_CHECK_EQUAL(st.get("YEAR"), 2000);
|
||||
BOOST_CHECK_EQUAL(st.get("DAY"), 1);
|
||||
BOOST_CHECK_EQUAL(st.get("MNTH"), 1);
|
||||
|
||||
// Next day
|
||||
st.update_elapsed(100000);
|
||||
BOOST_CHECK_EQUAL(st.get("YEAR"), 2000);
|
||||
BOOST_CHECK_EQUAL(st.get("DAY"), 2);
|
||||
BOOST_CHECK_EQUAL(st.get("MNTH"), 1);
|
||||
|
||||
// Well into 2001
|
||||
st.update_elapsed(400 * 86400);
|
||||
BOOST_CHECK_EQUAL(st.get("YEAR"), 2001);
|
||||
}
|
||||
|
||||
BOOST_AUTO_TEST_SUITE_END()
|
||||
|
||||
Reference in New Issue
Block a user