From c25275d0ee456d831c245f2dc1a361181da4a565 Mon Sep 17 00:00:00 2001 From: Andreas Lauser Date: Thu, 4 Apr 2019 16:53:36 +0200 Subject: [PATCH] add `parseContext` and `errorGuard` parameters to `Opm::checkDeck()` this requires a small downstream cleanup. --- opm/parser/eclipse/EclipseState/checkDeck.hpp | 4 +++- src/opm/parser/eclipse/EclipseState/checkDeck.cpp | 4 +++- tests/parser/integration/CheckDeckValidity.cpp | 14 ++++++++------ 3 files changed, 14 insertions(+), 8 deletions(-) diff --git a/opm/parser/eclipse/EclipseState/checkDeck.hpp b/opm/parser/eclipse/EclipseState/checkDeck.hpp index 857bc3148..8339f8ce9 100644 --- a/opm/parser/eclipse/EclipseState/checkDeck.hpp +++ b/opm/parser/eclipse/EclipseState/checkDeck.hpp @@ -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); } diff --git a/src/opm/parser/eclipse/EclipseState/checkDeck.cpp b/src/opm/parser/eclipse/EclipseState/checkDeck.cpp index b9b15454b..58a602ee7 100644 --- a/src/opm/parser/eclipse/EclipseState/checkDeck.cpp +++ b/src/opm/parser/eclipse/EclipseState/checkDeck.cpp @@ -24,9 +24,11 @@ #include #include #include +#include +#include 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 diff --git a/tests/parser/integration/CheckDeckValidity.cpp b/tests/parser/integration/CheckDeckValidity.cpp index 3a1db2a36..8eecd5251 100644 --- a/tests/parser/integration/CheckDeckValidity.cpp +++ b/tests/parser/integration/CheckDeckValidity.cpp @@ -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)); } }