Renamed DeckRecord::get() -> DeckRecord::getItem()
This commit is contained in:
parent
15c4874ee0
commit
a8d4a22894
@ -42,14 +42,14 @@ namespace Opm {
|
||||
throw std::invalid_argument("Item with name: " + deckItem->name() + " already exists in DeckRecord");
|
||||
}
|
||||
|
||||
DeckItemConstPtr DeckRecord::get(size_t index) const {
|
||||
DeckItemConstPtr DeckRecord::getItem(size_t index) const {
|
||||
if (index < m_items.size())
|
||||
return m_items[index];
|
||||
else
|
||||
throw std::range_error("Index out of range.");
|
||||
}
|
||||
|
||||
DeckItemConstPtr DeckRecord::get(const std::string& name) const {
|
||||
DeckItemConstPtr DeckRecord::getItem(const std::string& name) const {
|
||||
if (m_itemMap.find(name) == m_itemMap.end())
|
||||
throw std::invalid_argument("Itemname: " + name + " does not exist.");
|
||||
else
|
||||
|
@ -34,8 +34,8 @@ namespace Opm {
|
||||
DeckRecord();
|
||||
size_t size() const;
|
||||
void addItem(DeckItemConstPtr deckItem);
|
||||
DeckItemConstPtr get(size_t index) const;
|
||||
DeckItemConstPtr get(const std::string& name) const;
|
||||
DeckItemConstPtr getItem(size_t index) const;
|
||||
DeckItemConstPtr getItem(const std::string& name) const;
|
||||
|
||||
private:
|
||||
std::vector<DeckItemConstPtr> m_items;
|
||||
|
@ -77,28 +77,28 @@ BOOST_AUTO_TEST_CASE(get_byIndex_returnsItem) {
|
||||
DeckRecord deckRecord;
|
||||
DeckIntItemPtr intItem1(new DeckIntItem("TEST"));
|
||||
deckRecord.addItem(intItem1);
|
||||
BOOST_CHECK_NO_THROW(deckRecord.get(0U));
|
||||
BOOST_CHECK_NO_THROW(deckRecord.getItem(0U));
|
||||
}
|
||||
|
||||
BOOST_AUTO_TEST_CASE(get_indexoutofbounds_throws) {
|
||||
DeckRecord deckRecord;
|
||||
DeckIntItemPtr intItem1(new DeckIntItem("TEST"));
|
||||
deckRecord.addItem(intItem1);
|
||||
BOOST_CHECK_THROW(deckRecord.get(1), std::range_error);
|
||||
BOOST_CHECK_THROW(deckRecord.getItem(1), std::range_error);
|
||||
}
|
||||
|
||||
BOOST_AUTO_TEST_CASE(get_byName_returnsItem) {
|
||||
DeckRecord deckRecord;
|
||||
DeckIntItemPtr intItem1(new DeckIntItem("TEST"));
|
||||
deckRecord.addItem(intItem1);
|
||||
deckRecord.get("TEST");
|
||||
deckRecord.getItem("TEST");
|
||||
}
|
||||
|
||||
BOOST_AUTO_TEST_CASE(get_byNameNonExisting_throws) {
|
||||
DeckRecord deckRecord;
|
||||
DeckIntItemPtr intItem1(new DeckIntItem("TEST"));
|
||||
deckRecord.addItem(intItem1);
|
||||
BOOST_CHECK_THROW(deckRecord.get("INVALID"), std::invalid_argument);
|
||||
BOOST_CHECK_THROW(deckRecord.getItem("INVALID"), std::invalid_argument);
|
||||
}
|
||||
|
||||
BOOST_AUTO_TEST_CASE(get_oneoftwo_returnscorrectitem) {
|
||||
@ -107,8 +107,8 @@ BOOST_AUTO_TEST_CASE(get_oneoftwo_returnscorrectitem) {
|
||||
DeckIntItemPtr intItem2(new DeckIntItem("TEST2"));
|
||||
deckRecord.addItem(intItem1);
|
||||
deckRecord.addItem(intItem2);
|
||||
BOOST_CHECK_EQUAL(intItem2, deckRecord.get(1));
|
||||
BOOST_CHECK_EQUAL(intItem1, deckRecord.get("TEST"));
|
||||
BOOST_CHECK_EQUAL(intItem2, deckRecord.getItem(1));
|
||||
BOOST_CHECK_EQUAL(intItem1, deckRecord.getItem("TEST"));
|
||||
}
|
||||
|
||||
|
||||
|
@ -62,8 +62,8 @@ BOOST_AUTO_TEST_CASE(parse_fileWithWWCTKeyword_dataIsCorrect) {
|
||||
boost::filesystem::path singleKeywordFile("testdata/integration_tests/wwct.data");
|
||||
ParserPtr parser = createWWCTParser();
|
||||
DeckPtr deck = parser->parse(singleKeywordFile.string());
|
||||
BOOST_CHECK_EQUAL("WELL-1", deck->getKeyword("WWCT")->getRecord(0)->get(0)->getString(0));
|
||||
BOOST_CHECK_EQUAL("WELL-2", deck->getKeyword("WWCT")->getRecord(0)->get(0)->getString(1));
|
||||
BOOST_CHECK_EQUAL("WELL-1", deck->getKeyword("WWCT")->getRecord(0)->getItem(0)->getString(0));
|
||||
BOOST_CHECK_EQUAL("WELL-2", deck->getKeyword("WWCT")->getRecord(0)->getItem(0)->getString(1));
|
||||
}
|
||||
|
||||
ParserPtr createBPRParser() {
|
||||
@ -108,38 +108,38 @@ BOOST_AUTO_TEST_CASE(parse_fileWithBPRKeyword_dataiscorrect) {
|
||||
DeckRecordConstPtr record1 = keyword->getRecord(0);
|
||||
BOOST_CHECK_EQUAL(3U, record1->size());
|
||||
|
||||
DeckItemConstPtr I1 = record1->get(0);
|
||||
DeckItemConstPtr I1 = record1->getItem(0);
|
||||
BOOST_CHECK_EQUAL(1, I1->getInt(0));
|
||||
I1 = record1->get("I");
|
||||
I1 = record1->getItem("I");
|
||||
BOOST_CHECK_EQUAL(1, I1->getInt(0));
|
||||
|
||||
DeckItemConstPtr J1 = record1->get(1);
|
||||
DeckItemConstPtr J1 = record1->getItem(1);
|
||||
BOOST_CHECK_EQUAL(2, J1->getInt(0));
|
||||
J1 = record1->get("J");
|
||||
J1 = record1->getItem("J");
|
||||
BOOST_CHECK_EQUAL(2, J1->getInt(0));
|
||||
|
||||
DeckItemConstPtr K1 = record1->get(2);
|
||||
DeckItemConstPtr K1 = record1->getItem(2);
|
||||
BOOST_CHECK_EQUAL(3, K1->getInt(0));
|
||||
K1 = record1->get("K");
|
||||
K1 = record1->getItem("K");
|
||||
BOOST_CHECK_EQUAL(3, K1->getInt(0));
|
||||
|
||||
|
||||
DeckRecordConstPtr record2 = keyword->getRecord(0);
|
||||
BOOST_CHECK_EQUAL(3U, record2->size());
|
||||
|
||||
I1 = record2->get(0);
|
||||
I1 = record2->getItem(0);
|
||||
BOOST_CHECK_EQUAL(1, I1->getInt(0));
|
||||
I1 = record2->get("I");
|
||||
I1 = record2->getItem("I");
|
||||
BOOST_CHECK_EQUAL(1, I1->getInt(0));
|
||||
|
||||
J1 = record2->get(1);
|
||||
J1 = record2->getItem(1);
|
||||
BOOST_CHECK_EQUAL(2, J1->getInt(0));
|
||||
J1 = record2->get("J");
|
||||
J1 = record2->getItem("J");
|
||||
BOOST_CHECK_EQUAL(2, J1->getInt(0));
|
||||
|
||||
K1 = record2->get(2);
|
||||
K1 = record2->getItem(2);
|
||||
BOOST_CHECK_EQUAL(3, K1->getInt(0));
|
||||
K1 = record2->get("K");
|
||||
K1 = record2->getItem("K");
|
||||
BOOST_CHECK_EQUAL(3, K1->getInt(0));
|
||||
|
||||
}
|
||||
|
39
opm/parser/eclipse/IntegrationTests/ParseWCONHIST.cpp
Normal file
39
opm/parser/eclipse/IntegrationTests/ParseWCONHIST.cpp
Normal file
@ -0,0 +1,39 @@
|
||||
/*
|
||||
Copyright 2013 Statoil ASA.
|
||||
|
||||
This file is part of the Open Porous Media project (OPM).
|
||||
|
||||
OPM is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
OPM is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with OPM. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#define BOOST_TEST_MODULE ParserIntegrationTests
|
||||
#include <boost/test/unit_test.hpp>
|
||||
#include <boost/test/test_tools.hpp>
|
||||
|
||||
#include <opm/parser/eclipse/Deck/Deck.hpp>
|
||||
|
||||
#include <opm/parser/eclipse/Parser/Parser.hpp>
|
||||
#include <opm/parser/eclipse/Parser/ParserRecord.hpp>
|
||||
#include <opm/parser/eclipse/Parser/ParserIntItem.hpp>
|
||||
#include <opm/parser/eclipse/Parser/ParserStringItem.hpp>
|
||||
|
||||
#include <opm/parser/eclipse/Parser/ParserEnums.hpp>
|
||||
|
||||
using namespace Opm;
|
||||
|
||||
BOOST_AUTO_TEST_CASE( parse_WCHONHIST_OK ) {
|
||||
ParserPtr parser(new Parser(JSON_CONFIG_FILE));
|
||||
boost::filesystem::path wconhistFile("testdata/WCONHIST/WCONHIST1");
|
||||
DeckPtr deck = parser->parse(wconhistFile.string());
|
||||
}
|
5
testdata/WCONHIST/WCONHIST1
vendored
Normal file
5
testdata/WCONHIST/WCONHIST1
vendored
Normal file
@ -0,0 +1,5 @@
|
||||
WCONHIST
|
||||
'OP_1' 'OPEN' 'ORAT' 4000.000 4.000 1.46402E+006 5* /
|
||||
'OP_2' 'OPEN' 'ORAT' 7998.000 2.000 1461075.000 5* /
|
||||
'OP_3' 'OPEN' 'ORAT' 7999.000 1.000 1471824.000 5* /
|
||||
/
|
Loading…
Reference in New Issue
Block a user