Added defaultApplied() method to DeckItem - and FAILING test
This commit is contained in:
parent
fa3cc810d8
commit
fb7dc690d1
@ -45,7 +45,7 @@ namespace Opm {
|
||||
push_back(data, data.size());
|
||||
}
|
||||
|
||||
void DeckIntItem::push_back(int data) {
|
||||
void DeckIntItem::push_back(int data) {
|
||||
m_data.push_back(data);
|
||||
}
|
||||
|
||||
|
@ -23,9 +23,15 @@ namespace Opm {
|
||||
|
||||
DeckItem::DeckItem(const std::string& name) {
|
||||
m_name = name;
|
||||
m_defaultApplied = false;
|
||||
}
|
||||
|
||||
const std::string& DeckItem::name() const {
|
||||
return m_name;
|
||||
}
|
||||
|
||||
bool DeckItem::defaultApplied() const {
|
||||
return m_defaultApplied;
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -33,6 +33,8 @@ namespace Opm {
|
||||
DeckItem(const std::string& name);
|
||||
const std::string& name() const;
|
||||
|
||||
bool defaultApplied() const;
|
||||
|
||||
virtual size_t size() const = 0;
|
||||
|
||||
virtual int getInt(size_t index) const {
|
||||
@ -70,7 +72,7 @@ namespace Opm {
|
||||
}
|
||||
private:
|
||||
std::string m_name;
|
||||
|
||||
bool m_defaultApplied;
|
||||
};
|
||||
typedef boost::shared_ptr<DeckItem> DeckItemPtr;
|
||||
typedef boost::shared_ptr<const DeckItem> DeckItemConstPtr;
|
||||
|
@ -69,3 +69,13 @@ BOOST_AUTO_TEST_CASE(size_correct) {
|
||||
deckIntItem.push_back( 100 );
|
||||
BOOST_CHECK_EQUAL( 3U , deckIntItem.size());
|
||||
}
|
||||
|
||||
|
||||
|
||||
BOOST_AUTO_TEST_CASE(DefaultApplied) {
|
||||
DeckIntItem deckIntItem("TEST");
|
||||
BOOST_CHECK_EQUAL( false , deckIntItem.defaultApplied() );
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
@ -494,3 +494,47 @@ BOOST_AUTO_TEST_CASE(scan_intsAndStrings_dataCorrect) {
|
||||
BOOST_CHECK_EQUAL(3, deckItemInts->getInt(2));
|
||||
BOOST_CHECK_EQUAL(3, deckItemInts->getInt(3));
|
||||
}
|
||||
|
||||
|
||||
BOOST_AUTO_TEST_CASE(ParseWithDefault_defaultAppliedCorrectInDeck) {
|
||||
ParserIntItem itemInt("ITEM", SINGLE);
|
||||
ParserIntItem itemString("ITEM", SINGLE);
|
||||
ParserIntItem itemDouble("ITEM", SINGLE);
|
||||
|
||||
{
|
||||
RawRecordPtr rawRecord(new RawRecord("* /"));
|
||||
DeckItemConstPtr deckStringItem = itemString.scan(rawRecord);
|
||||
DeckItemConstPtr deckIntItem = itemInt.scan(rawRecord);
|
||||
DeckItemConstPtr deckDoubleItem = itemDouble.scan(rawRecord);
|
||||
|
||||
BOOST_CHECK( deckStringItem->defaultApplied() );
|
||||
BOOST_CHECK( deckIntItem->defaultApplied() );
|
||||
BOOST_CHECK( deckDoubleItem->defaultApplied() );
|
||||
}
|
||||
|
||||
|
||||
{
|
||||
RawRecordPtr rawRecord(new RawRecord("/"));
|
||||
DeckItemConstPtr deckStringItem = itemString.scan(rawRecord);
|
||||
DeckItemConstPtr deckIntItem = itemInt.scan(rawRecord);
|
||||
DeckItemConstPtr deckDoubleItem = itemDouble.scan(rawRecord);
|
||||
|
||||
BOOST_CHECK( deckStringItem->defaultApplied() );
|
||||
BOOST_CHECK( deckIntItem->defaultApplied() );
|
||||
BOOST_CHECK( deckDoubleItem->defaultApplied() );
|
||||
}
|
||||
|
||||
|
||||
{
|
||||
RawRecordPtr rawRecord(new RawRecord("10 /"));
|
||||
DeckItemConstPtr deckStringItem = itemString.scan(rawRecord);
|
||||
DeckItemConstPtr deckIntItem = itemInt.scan(rawRecord);
|
||||
DeckItemConstPtr deckDoubleItem = itemDouble.scan(rawRecord);
|
||||
|
||||
BOOST_CHECK_EQUAL( false , deckStringItem->defaultApplied() );
|
||||
BOOST_CHECK_EQUAL( false , deckIntItem->defaultApplied() );
|
||||
BOOST_CHECK_EQUAL( false , deckDoubleItem->defaultApplied() );
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user