TimeMap: extend test to check "from deck construction" and the new accessor methods
This commit is contained in:
@@ -203,3 +203,46 @@ BOOST_AUTO_TEST_CASE( addTSTEPFromWrongKeywordThrows ) {
|
||||
Opm::DeckKeywordConstPtr deckKeyword(new Opm::DeckKeyword("NOTTSTEP"));
|
||||
BOOST_CHECK_THROW( timeMap.addFromTSTEPKeyword( deckKeyword ) , std::invalid_argument );
|
||||
}
|
||||
|
||||
BOOST_AUTO_TEST_CASE(TimeStepsCorrect) {
|
||||
const char *deckData =
|
||||
"START\n"
|
||||
" 21 MAY 1981 /\n"
|
||||
"\n"
|
||||
"TSTEP\n"
|
||||
" 1 2 3 4 5 /\n"
|
||||
"\n"
|
||||
"DATES\n"
|
||||
" 1 JAN 1982 /\n"
|
||||
" 1 JAN 1982 13:55:44 /\n"
|
||||
" 3 JAN 1982 14:56:45.123 /\n"
|
||||
"/\n"
|
||||
"\n"
|
||||
"TSTEP\n"
|
||||
" 6 7 /\n";
|
||||
|
||||
Opm::ParserPtr parser(new Opm::Parser(/*addDefault=*/true));
|
||||
Opm::DeckPtr deck = parser->parseString(deckData);
|
||||
Opm::TimeMap tmap(deck);
|
||||
|
||||
BOOST_CHECK_EQUAL(tmap.getStartTime(/*timeStepIdx=*/0),
|
||||
boost::posix_time::ptime(boost::gregorian::date(1981, 5, 21)));
|
||||
BOOST_CHECK_EQUAL(tmap.getTimeStepLength(/*index=*/0), 1*24*60*60);
|
||||
BOOST_CHECK_EQUAL(tmap.getTimeStepLength(/*index=*/1), 2*24*60*60);
|
||||
BOOST_CHECK_EQUAL(tmap.getTimeStepLength(/*index=*/2), 3*24*60*60);
|
||||
BOOST_CHECK_EQUAL(tmap.getTimeStepLength(/*index=*/3), 4*24*60*60);
|
||||
BOOST_CHECK_EQUAL(tmap.getTimeStepLength(/*index=*/4), 5*24*60*60);
|
||||
// timestep 5 is the period between the last step specified using
|
||||
// of the TIMES keyword and the first record of DATES
|
||||
BOOST_CHECK_EQUAL(tmap.getStartTime(/*timeStepIndex=*/6),
|
||||
boost::posix_time::ptime(boost::gregorian::date(1982, 1, 1)));
|
||||
BOOST_CHECK_EQUAL(tmap.getStartTime(/*timeStepIndex=*/7),
|
||||
boost::posix_time::ptime(boost::gregorian::date(1982, 1, 1),
|
||||
boost::posix_time::time_duration(13, 55, 44)));
|
||||
BOOST_CHECK_EQUAL(tmap.getStartTime(/*timeStepIndex=*/8),
|
||||
boost::posix_time::ptime(boost::gregorian::date(1982, 1, 3),
|
||||
boost::posix_time::time_duration(14, 56, 45) +
|
||||
boost::posix_time::milliseconds(123)));
|
||||
BOOST_CHECK_EQUAL(tmap.getTimeStepLength(/*index=*/8), 6*24*60*60);
|
||||
BOOST_CHECK_EQUAL(tmap.getTimeStepLength(/*index=*/9), 7*24*60*60);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user