Started integration testing
This commit is contained in:
@@ -28,24 +28,26 @@ namespace Opm {
|
||||
Parser::Parser() {
|
||||
}
|
||||
|
||||
RawDeckPtr Parser::parse(const std::string &path) {
|
||||
DeckPtr Parser::parse(const std::string &path) {
|
||||
Logger::initLogger();
|
||||
Logger::info("Starting parsing of file: " + path);
|
||||
|
||||
|
||||
|
||||
RawDeckPtr rawDeck(new RawDeck(RawParserKWsConstPtr(new RawParserKWs())));
|
||||
rawDeck->readDataIntoDeck(path);
|
||||
|
||||
|
||||
//Iterate through rawDeck, and return Deck
|
||||
|
||||
DeckPtr deck(new Deck());
|
||||
|
||||
{
|
||||
RawDeckPtr rawDeck(new RawDeck(RawParserKWsConstPtr(new RawParserKWs())));
|
||||
rawDeck->parse(path);
|
||||
|
||||
|
||||
|
||||
}
|
||||
Logger::info("Done parsing of file: " + path);
|
||||
Logger::closeLogger();
|
||||
return rawDeck;
|
||||
return deck;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
Parser::~Parser() {
|
||||
}
|
||||
|
||||
@@ -27,6 +27,7 @@
|
||||
#include <opm/parser/eclipse/Logger/Logger.hpp>
|
||||
#include <opm/parser/eclipse/RawDeck/RawKeyword.hpp>
|
||||
#include <opm/parser/eclipse/RawDeck/RawDeck.hpp>
|
||||
#include <opm/parser/eclipse/Deck/Deck.hpp>
|
||||
#include <opm/parser/eclipse/Parser/ParserKW.hpp>
|
||||
|
||||
namespace Opm {
|
||||
@@ -40,7 +41,7 @@ namespace Opm {
|
||||
Parser();
|
||||
|
||||
/// The starting point of the parsing process. The supplied file is parsed, and the resulting Deck is returned.
|
||||
RawDeckPtr parse(const std::string &path);
|
||||
DeckPtr parse(const std::string &path);
|
||||
virtual ~Parser();
|
||||
|
||||
/// Method to add ParserKW instances, these holding type and size information about the keywords and their data.
|
||||
@@ -51,6 +52,7 @@ namespace Opm {
|
||||
};
|
||||
|
||||
typedef boost::shared_ptr<Parser> ParserPtr;
|
||||
typedef boost::shared_ptr<const Parser> ParserConstPtr;
|
||||
} // namespace Opm
|
||||
#endif /* PARSER_H */
|
||||
|
||||
|
||||
@@ -1,24 +1,20 @@
|
||||
add_executable(runParserTests ParserTests.cpp)
|
||||
add_executable(runParserTestsInternalData ParserTestsInternalData.cpp)
|
||||
add_executable(runParserKWTests ParserKWTests.cpp)
|
||||
add_executable(runParserRecordTests ParserRecordTests.cpp)
|
||||
add_executable(runParserRecordSizeTests ParserRecordSizeTests.cpp)
|
||||
add_executable(runParserItemTests ParserItemTests.cpp)
|
||||
|
||||
target_link_libraries(runParserTests Parser ${Boost_LIBRARIES})
|
||||
target_link_libraries(runParserTestsInternalData Parser ${Boost_LIBRARIES})
|
||||
target_link_libraries(runParserKWTests Parser ${Boost_LIBRARIES})
|
||||
target_link_libraries(runParserRecordSizeTests Parser ${Boost_LIBRARIES})
|
||||
target_link_libraries(runParserRecordTests Parser ${Boost_LIBRARIES})
|
||||
target_link_libraries(runParserItemTests Parser ${Boost_LIBRARIES})
|
||||
|
||||
add_test(NAME runParserTests WORKING_DIRECTORY ${PROJECT_SOURCE_DIR} COMMAND ${EXECUTABLE_OUTPUT_PATH}/runParserTests )
|
||||
add_test(NAME runParserTestsInternalData WORKING_DIRECTORY ${EXECUTABLE_OUTPUT_PATH} COMMAND runParserTestsInternalData)
|
||||
add_test(NAME runParserKWTests COMMAND ${EXECUTABLE_OUTPUT_PATH}/runParserKWTests )
|
||||
add_test(NAME runParserRecordSizeTests COMMAND ${EXECUTABLE_OUTPUT_PATH}/runParserRecordSizeTests )
|
||||
add_test(NAME runParserRecordTests COMMAND ${EXECUTABLE_OUTPUT_PATH}/runParserRecordTests )
|
||||
add_test(NAME runParserItemTests COMMAND ${EXECUTABLE_OUTPUT_PATH}/runParserItemTests )
|
||||
|
||||
set_tests_properties(runParserTestsInternalData PROPERTIES LABELS Statoil)
|
||||
|
||||
set_property(SOURCE ParserRecordTests.cpp PROPERTY COMPILE_FLAGS "-Wno-error")
|
||||
|
||||
@@ -24,113 +24,24 @@
|
||||
#include <boost/test/unit_test.hpp>
|
||||
|
||||
|
||||
#include "opm/parser/eclipse/Parser/Parser.hpp"
|
||||
#include "opm/parser/eclipse/Parser/ParserKW.hpp"
|
||||
#include "opm/parser/eclipse/Parser/ParserRecordSize.hpp"
|
||||
#include "opm/parser/eclipse/RawDeck/RawDeck.hpp"
|
||||
#include <opm/parser/eclipse/Parser/Parser.hpp>
|
||||
#include <opm/parser/eclipse/Parser/ParserKW.hpp>
|
||||
#include <opm/parser/eclipse/Parser/ParserRecordSize.hpp>
|
||||
#include <opm/parser/eclipse/RawDeck/RawDeck.hpp>
|
||||
|
||||
using namespace Opm;
|
||||
|
||||
BOOST_AUTO_TEST_CASE(RawDeckPrintToOStream) {
|
||||
boost::filesystem::path singleKeywordFile("testdata/small.data");
|
||||
|
||||
ParserPtr parser(new Parser());
|
||||
|
||||
RawDeckPtr rawDeck = parser->parse(singleKeywordFile.string());
|
||||
std::cout << *rawDeck << "\n";
|
||||
}
|
||||
|
||||
BOOST_AUTO_TEST_CASE(Initializing) {
|
||||
BOOST_CHECK_NO_THROW(Parser parser);
|
||||
BOOST_CHECK_NO_THROW(ParserPtr parserPtr(new Parser()));
|
||||
BOOST_CHECK_NO_THROW(ParserConstPtr parserConstPtr(new Parser()));
|
||||
}
|
||||
|
||||
BOOST_AUTO_TEST_CASE(ParseWithInvalidInputFileThrows) {
|
||||
ParserPtr parser(new Parser());
|
||||
BOOST_CHECK_THROW(parser->parse("nonexistingfile.asdf"), std::invalid_argument);
|
||||
}
|
||||
|
||||
BOOST_AUTO_TEST_CASE(ParseWithValidFileSetOnParseCallNoThrow) {
|
||||
|
||||
boost::filesystem::path singleKeywordFile("testdata/small.data");
|
||||
ParserPtr parser(new Parser());
|
||||
|
||||
BOOST_CHECK_NO_THROW(parser->parse(singleKeywordFile.string()));
|
||||
}
|
||||
|
||||
BOOST_AUTO_TEST_CASE(ParseWithInValidFileSetOnParseCallThrows) {
|
||||
boost::filesystem::path singleKeywordFile("testdata/nosuchfile.data");
|
||||
ParserPtr parser(new Parser());
|
||||
BOOST_CHECK_THROW(parser->parse(singleKeywordFile.string()), std::invalid_argument);
|
||||
}
|
||||
|
||||
BOOST_AUTO_TEST_CASE(ParseFileWithOneKeyword) {
|
||||
boost::filesystem::path singleKeywordFile("testdata/mini.data");
|
||||
|
||||
ParserPtr parser(new Parser());
|
||||
|
||||
RawDeckPtr rawDeck = parser->parse(singleKeywordFile.string());
|
||||
BOOST_CHECK_EQUAL((unsigned) 1, rawDeck->getNumberOfKeywords());
|
||||
RawKeywordConstPtr rawKeyword = rawDeck->getKeyword("ENDSCALE");
|
||||
const std::list<RawRecordConstPtr>& records = rawKeyword->getRecords();
|
||||
BOOST_CHECK_EQUAL((unsigned) 1, records.size());
|
||||
RawRecordConstPtr record = records.back();
|
||||
|
||||
const std::string& recordString = record->getRecordString();
|
||||
BOOST_CHECK_EQUAL("'NODIR' 'REVERS' 1 20", recordString);
|
||||
|
||||
const std::deque<std::string>& recordElements = record->getItems();
|
||||
BOOST_CHECK_EQUAL((unsigned) 4, recordElements.size());
|
||||
|
||||
BOOST_CHECK_EQUAL("NODIR", recordElements[0]);
|
||||
BOOST_CHECK_EQUAL("REVERS", recordElements[1]);
|
||||
BOOST_CHECK_EQUAL("1", recordElements[2]);
|
||||
BOOST_CHECK_EQUAL("20", recordElements[3]);
|
||||
}
|
||||
|
||||
BOOST_AUTO_TEST_CASE(ParseFileWithFewKeywords) {
|
||||
boost::filesystem::path singleKeywordFile("testdata/small.data");
|
||||
|
||||
ParserPtr parser(new Parser());
|
||||
|
||||
RawDeckPtr rawDeck = parser->parse(singleKeywordFile.string());
|
||||
BOOST_CHECK_EQUAL((unsigned) 7, rawDeck->getNumberOfKeywords());
|
||||
|
||||
RawKeywordConstPtr matchingKeyword = rawDeck->getKeyword("OIL");
|
||||
std::list<RawRecordConstPtr> records = matchingKeyword->getRecords();
|
||||
BOOST_CHECK_EQUAL("OIL", matchingKeyword->getKeyword());
|
||||
BOOST_CHECK_EQUAL((unsigned) 0, records.size());
|
||||
|
||||
// The two next come in via the include of the include path/readthis.sch file
|
||||
matchingKeyword = rawDeck->getKeyword("GRUPTREE");
|
||||
BOOST_CHECK_EQUAL("GRUPTREE", matchingKeyword->getKeyword());
|
||||
records = matchingKeyword->getRecords();
|
||||
BOOST_CHECK_EQUAL((unsigned) 2, records.size());
|
||||
|
||||
matchingKeyword = rawDeck->getKeyword("WHISTCTL");
|
||||
BOOST_CHECK_EQUAL("WHISTCTL", matchingKeyword->getKeyword());
|
||||
records = matchingKeyword->getRecords();
|
||||
BOOST_CHECK_EQUAL((unsigned) 1, records.size());
|
||||
|
||||
matchingKeyword = rawDeck->getKeyword("METRIC");
|
||||
BOOST_CHECK_EQUAL("METRIC", matchingKeyword->getKeyword());
|
||||
records = matchingKeyword->getRecords();
|
||||
BOOST_CHECK_EQUAL((unsigned) 0, records.size());
|
||||
|
||||
matchingKeyword = rawDeck->getKeyword("GRIDUNIT");
|
||||
BOOST_CHECK_EQUAL("GRIDUNIT", matchingKeyword->getKeyword());
|
||||
records = matchingKeyword->getRecords();
|
||||
BOOST_CHECK_EQUAL((unsigned) 1, records.size());
|
||||
|
||||
matchingKeyword = rawDeck->getKeyword("RADFIN4");
|
||||
records = matchingKeyword->getRecords();
|
||||
BOOST_CHECK_EQUAL("RADFIN4", matchingKeyword->getKeyword());
|
||||
BOOST_CHECK_EQUAL((unsigned) 1, records.size());
|
||||
|
||||
matchingKeyword = rawDeck->getKeyword("ABCDAD");
|
||||
BOOST_CHECK_EQUAL("ABCDAD", matchingKeyword->getKeyword());
|
||||
records = matchingKeyword->getRecords();
|
||||
|
||||
BOOST_CHECK_EQUAL((unsigned) 2, records.size());
|
||||
}
|
||||
|
||||
BOOST_AUTO_TEST_CASE(ParserAddKW) {
|
||||
Parser parser;
|
||||
|
||||
@@ -25,10 +25,11 @@
|
||||
#include <boost/test/unit_test.hpp>
|
||||
|
||||
|
||||
#include "opm/parser/eclipse/Parser/Parser.hpp"
|
||||
#include "opm/parser/eclipse/Parser/ParserKW.hpp"
|
||||
#include "opm/parser/eclipse/Parser/ParserRecordSize.hpp"
|
||||
#include "opm/parser/eclipse/RawDeck/RawDeck.hpp"
|
||||
#include <opm/parser/eclipse/Parser/Parser.hpp>
|
||||
#include <opm/parser/eclipse/Parser/ParserKW.hpp>
|
||||
#include <opm/parser/eclipse/Parser/ParserRecordSize.hpp>
|
||||
#include <opm/parser/eclipse/RawDeck/RawDeck.hpp>
|
||||
#include <opm/parser/eclipse/Deck/Deck.hpp>
|
||||
using namespace Opm;
|
||||
|
||||
//NOTE: needs statoil dataset
|
||||
|
||||
Reference in New Issue
Block a user