diff --git a/opm/parser/eclipse/Parser/tests/CMakeLists.txt b/opm/parser/eclipse/Parser/tests/CMakeLists.txt index df06c3cc2..b28faf6d8 100644 --- a/opm/parser/eclipse/Parser/tests/CMakeLists.txt +++ b/opm/parser/eclipse/Parser/tests/CMakeLists.txt @@ -3,17 +3,20 @@ add_executable(runParserKeywordTests ParserKeywordTests.cpp) add_executable(runParserRecordTests ParserRecordTests.cpp) add_executable(runParserItemTests ParserItemTests.cpp) add_executable(runParserEnumTests ParserEnumTests.cpp) +add_executable(runParserIncludeTests ParserIncludeTests.cpp) target_link_libraries(runParserTests Parser ${Boost_LIBRARIES}) target_link_libraries(runParserKeywordTests Parser ${Boost_LIBRARIES}) target_link_libraries(runParserRecordTests Parser ${Boost_LIBRARIES}) target_link_libraries(runParserItemTests Parser ${Boost_LIBRARIES}) +target_link_libraries(runParserIncludeTests Parser ${Boost_LIBRARIES}) target_link_libraries(runParserEnumTests Parser ${Boost_LIBRARIES}) add_test(NAME runParserTests WORKING_DIRECTORY ${PROJECT_SOURCE_DIR} COMMAND ${TEST_MEMCHECK_TOOL} ${EXECUTABLE_OUTPUT_PATH}/runParserTests ) add_test(NAME runParserKeywordTests COMMAND ${TEST_MEMCHECK_TOOL} ${EXECUTABLE_OUTPUT_PATH}/runParserKeywordTests ) add_test(NAME runParserRecordTests COMMAND ${TEST_MEMCHECK_TOOL} ${EXECUTABLE_OUTPUT_PATH}/runParserRecordTests ) add_test(NAME runParserItemTests COMMAND ${TEST_MEMCHECK_TOOL} ${EXECUTABLE_OUTPUT_PATH}/runParserItemTests ) +add_test(NAME runParserIncludeTests COMMAND ${TEST_MEMCHECK_TOOL} ${EXECUTABLE_OUTPUT_PATH}/runParserIncludeTests ) add_test(NAME runParserEnumTests COMMAND ${TEST_MEMCHECK_TOOL} ${EXECUTABLE_OUTPUT_PATH}/runParserEnumTests ) set_property(SOURCE ParserRecordTests.cpp PROPERTY COMPILE_FLAGS "-Wno-error") diff --git a/opm/parser/eclipse/Parser/tests/ParserIncludeTests.cpp b/opm/parser/eclipse/Parser/tests/ParserIncludeTests.cpp new file mode 100644 index 000000000..666415b8b --- /dev/null +++ b/opm/parser/eclipse/Parser/tests/ParserIncludeTests.cpp @@ -0,0 +1,59 @@ +/* + Copyright 2014 by Andreas Lauser + + 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 . + */ + + +#define BOOST_TEST_MODULE ParserTests +#include + +#include +#include + +BOOST_AUTO_TEST_CASE(ParserKeyword_includeValid) { + boost::filesystem::path inputFilePath("testdata/parser/includeValid.data"); + + Opm::ParserPtr parser(new Opm::Parser()); + Opm::DeckConstPtr deck = parser->parseFile(inputFilePath.string()); + + BOOST_CHECK_EQUAL(true , deck->hasKeyword("OIL")); + BOOST_CHECK_EQUAL(false , deck->hasKeyword("WATER")); +} + +BOOST_AUTO_TEST_CASE(ParserKeyword_includeInvalid) { + boost::filesystem::path inputFilePath("testdata/parser/includeInvalid.data"); + + Opm::ParserPtr parser(new Opm::Parser()); + BOOST_CHECK_THROW(parser->parseFile(inputFilePath.string()), std::runtime_error); +} + +BOOST_AUTO_TEST_CASE(ParserKeyword_includeWrongCase) { + boost::filesystem::path inputFile1Path("testdata/parser/includeWrongCase1.data"); + boost::filesystem::path inputFile2Path("testdata/parser/includeWrongCase2.data"); + boost::filesystem::path inputFile3Path("testdata/parser/includeWrongCase3.data"); + + Opm::ParserPtr parser(new Opm::Parser()); + + // so far, we expect the files which are included to exhibit + // exactly the same spelling as their names on disk. Eclipse seems + // to be a bit more relaxed when it comes to this, so we might + // have to change the current behavior one not-so-fine day... + BOOST_CHECK_THROW(parser->parseFile(inputFile1Path.string()), std::runtime_error); + BOOST_CHECK_THROW(parser->parseFile(inputFile2Path.string()), std::runtime_error); + BOOST_CHECK_THROW(parser->parseFile(inputFile3Path.string()), std::runtime_error); +} + diff --git a/testdata/parser/include/some_flags.inc b/testdata/parser/include/some_flags.inc new file mode 100644 index 000000000..c3e31e44a --- /dev/null +++ b/testdata/parser/include/some_flags.inc @@ -0,0 +1 @@ +OIL diff --git a/testdata/parser/includeInvalid.data b/testdata/parser/includeInvalid.data new file mode 100644 index 000000000..7e8a1f56a --- /dev/null +++ b/testdata/parser/includeInvalid.data @@ -0,0 +1,3 @@ +INCLUDE + 'some_nonexisting_file.inc' +/ diff --git a/testdata/parser/includeValid.data b/testdata/parser/includeValid.data new file mode 100644 index 000000000..ac7c5c122 --- /dev/null +++ b/testdata/parser/includeValid.data @@ -0,0 +1,3 @@ +INCLUDE + 'include/some_flags.inc' +/ diff --git a/testdata/parser/includeWrongCase1.data b/testdata/parser/includeWrongCase1.data new file mode 100644 index 000000000..8e31f17b1 --- /dev/null +++ b/testdata/parser/includeWrongCase1.data @@ -0,0 +1,3 @@ +INCLUDE + 'include/SOME_flags.inc' +/ diff --git a/testdata/parser/includeWrongCase2.data b/testdata/parser/includeWrongCase2.data new file mode 100644 index 000000000..5e977d778 --- /dev/null +++ b/testdata/parser/includeWrongCase2.data @@ -0,0 +1,3 @@ +INCLUDE + 'Include/some_flags.inc' +/ diff --git a/testdata/parser/includeWrongCase3.data b/testdata/parser/includeWrongCase3.data new file mode 100644 index 000000000..40b17f1c7 --- /dev/null +++ b/testdata/parser/includeWrongCase3.data @@ -0,0 +1,3 @@ +INCLUDE + 'Include/SOME_flags.inc' +/