add parseContext and errorGuard parameters to Opm::checkDeck()

this requires a small downstream cleanup.
This commit is contained in:
Andreas Lauser 2019-04-04 16:53:36 +02:00
parent 9afaa32ca7
commit c25275d0ee
3 changed files with 14 additions and 8 deletions

View File

@ -26,6 +26,8 @@ namespace Opm {
class Deck;
class Parser;
class ParseContext;
class ErrorGuard;
enum DeckChecks {
SectionTopology = 0x0001,
@ -40,7 +42,7 @@ enum DeckChecks {
// some semantical correctness checks of the deck. this method adds a warning to
// the deck object if any issue is found ...
bool checkDeck( const Deck& deck, const Parser&, size_t enabledChecks = AllChecks);
bool checkDeck( const Deck& deck, const Parser& parser, const ParseContext& parseContext, ErrorGuard& errorGuard, size_t enabledChecks = AllChecks);
}

View File

@ -24,9 +24,11 @@
#include <opm/parser/eclipse/Deck/DeckKeyword.hpp>
#include <opm/parser/eclipse/Deck/Section.hpp>
#include <opm/parser/eclipse/Parser/Parser.hpp>
#include <opm/parser/eclipse/Parser/ParseContext.hpp>
#include <opm/parser/eclipse/Parser/ErrorGuard.hpp>
namespace Opm {
bool checkDeck( const Deck& deck, const Parser& parser, size_t enabledChecks) {
bool checkDeck( const Deck& deck, const Parser& parser, const ParseContext& parseContext, ErrorGuard& errorGuard, size_t enabledChecks) {
bool deckValid = true;
// make sure that the deck does not contain unknown keywords

View File

@ -28,6 +28,8 @@
BOOST_AUTO_TEST_CASE( KeywordInCorrectSection ) {
Opm::Parser parser;
Opm::ParseContext parseContext;
Opm::ErrorGuard errorGuard;
{
const char *correctDeckString =
@ -50,7 +52,7 @@ BOOST_AUTO_TEST_CASE( KeywordInCorrectSection ) {
"SCHEDULE\n";
auto deck = parser.parseString(correctDeckString);
BOOST_CHECK(Opm::checkDeck(deck, parser));
BOOST_CHECK(Opm::checkDeck(deck, parser, parseContext, errorGuard));
}
{
@ -63,8 +65,8 @@ BOOST_AUTO_TEST_CASE( KeywordInCorrectSection ) {
"SCHEDULE\n";
auto deck = parser.parseString(correctDeckString);
BOOST_CHECK(!Opm::checkDeck(deck, parser));
BOOST_CHECK(Opm::checkDeck(deck, parser, ~Opm::SectionTopology));
BOOST_CHECK(!Opm::checkDeck(deck, parser, parseContext, errorGuard));
BOOST_CHECK(Opm::checkDeck(deck, parser, parseContext, errorGuard, ~Opm::SectionTopology));
}
{
@ -89,13 +91,13 @@ BOOST_AUTO_TEST_CASE( KeywordInCorrectSection ) {
"SCHEDULE\n";
auto deck = parser.parseString(incorrectDeckString);
BOOST_CHECK(!Opm::checkDeck(deck, parser));
BOOST_CHECK(!Opm::checkDeck(deck, parser, parseContext, errorGuard));
// this is supposed to succeed as we don't ensure that all keywords are in the
// correct section
BOOST_CHECK(Opm::checkDeck(deck, parser, Opm::SectionTopology));
BOOST_CHECK(Opm::checkDeck(deck, parser, parseContext, errorGuard, Opm::SectionTopology));
// this fails because of the incorrect BOX keyword
BOOST_CHECK(!Opm::checkDeck(deck, parser, Opm::SectionTopology | Opm::KeywordSection));
BOOST_CHECK(!Opm::checkDeck(deck, parser, parseContext, errorGuard, Opm::SectionTopology | Opm::KeywordSection));
}
}