Fixed bug in DynamicState when updating default.

This commit is contained in:
Joakim Hove
2015-08-06 16:58:43 +02:00
parent f389fe2eca
commit 10a211cf8b
2 changed files with 18 additions and 2 deletions

View File

@@ -100,8 +100,11 @@ namespace Opm {
if (m_initialValue != initialValue) {
size_t index;
m_initialValue = initialValue;
for (index = 0; index < m_initialRange; index++)
m_data[index] = m_initialValue;
if (m_initialRange > 0) {
for (index = 0; index < m_initialRange; index++)
m_data[index] = m_initialValue;
} else
m_currentValue = initialValue;
}
}

View File

@@ -235,3 +235,16 @@ BOOST_AUTO_TEST_CASE( CheckReturn ) {
BOOST_CHECK_EQUAL( false , state.update( 3 , 137 ));
BOOST_CHECK_EQUAL( true , state.update( 5 , 200 ));
}
BOOST_AUTO_TEST_CASE( UpdateEmptyInitial ) {
boost::gregorian::date startDate( 2010 , boost::gregorian::Jan , 1);
Opm::TimeMapPtr timeMap(new Opm::TimeMap(boost::posix_time::ptime(startDate)));
Opm::DynamicState<int> state(timeMap , 137);
for (size_t i = 0; i < 10; i++)
timeMap->addTStep( boost::posix_time::hours( (i+1) * 24 ));
BOOST_CHECK_EQUAL( state[5] , 137 );
state.updateInitial( 99 );
BOOST_CHECK_EQUAL( state[5] , 99 );
}