From 705be62be6b4b0961c867637c5733b25682e6b0e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?B=C3=A5rd=20Skaflestad?= Date: Thu, 5 Sep 2019 13:32:18 +0200 Subject: [PATCH] ArrayDimChecker Unit Test: Refactor ParseContext Update This commit adds a little helper function to simplify assigning the same InputError::Action to all WELLDIMS-related contexts. --- tests/test_ArrayDimChecker.cpp | 21 +++++++++++++-------- 1 file changed, 13 insertions(+), 8 deletions(-) diff --git a/tests/test_ArrayDimChecker.cpp b/tests/test_ArrayDimChecker.cpp index 59150f1be..157b8f271 100644 --- a/tests/test_ArrayDimChecker.cpp +++ b/tests/test_ArrayDimChecker.cpp @@ -244,6 +244,17 @@ RedirectCERR::~RedirectCERR() BOOST_AUTO_TEST_SUITE(WellDimensions) +namespace { + void setWellDimsContext(const Opm::InputError::Action action, + Opm::ParseContext& ctxt) + { + ctxt.update(Opm::ParseContext::RUNSPEC_NUMWELLS_TOO_LARGE, action); + ctxt.update(Opm::ParseContext::RUNSPEC_CONNS_PER_WELL_TOO_LARGE, action); + ctxt.update(Opm::ParseContext::RUNSPEC_NUMGROUPS_TOO_LARGE, action); + ctxt.update(Opm::ParseContext::RUNSPEC_GROUPSIZE_TOO_LARGE, action); + } +} + BOOST_AUTO_TEST_CASE(MaxGroupSize) { Opm::ParseContext parseContext; @@ -256,10 +267,7 @@ BOOST_AUTO_TEST_CASE(MaxGroupSize) BOOST_AUTO_TEST_CASE(WellDims) { Opm::ParseContext parseContext; - parseContext.update(Opm::ParseContext::RUNSPEC_NUMWELLS_TOO_LARGE, Opm::InputError::THROW_EXCEPTION); - parseContext.update(Opm::ParseContext::RUNSPEC_CONNS_PER_WELL_TOO_LARGE, Opm::InputError::THROW_EXCEPTION); - parseContext.update(Opm::ParseContext::RUNSPEC_NUMGROUPS_TOO_LARGE, Opm::InputError::THROW_EXCEPTION); - parseContext.update(Opm::ParseContext::RUNSPEC_GROUPSIZE_TOO_LARGE, Opm::InputError::THROW_EXCEPTION); + setWellDimsContext(Opm::InputError::THROW_EXCEPTION, parseContext); auto cse = CaseObjects{ simCaseWellDims(), parseContext}; @@ -270,10 +278,7 @@ BOOST_AUTO_TEST_CASE(WellDims) parseContext, cse.guard), std::invalid_argument); - parseContext.update(Opm::ParseContext::RUNSPEC_NUMWELLS_TOO_LARGE, Opm::InputError::DELAYED_EXIT1); - parseContext.update(Opm::ParseContext::RUNSPEC_CONNS_PER_WELL_TOO_LARGE, Opm::InputError::DELAYED_EXIT1); - parseContext.update(Opm::ParseContext::RUNSPEC_NUMGROUPS_TOO_LARGE, Opm::InputError::DELAYED_EXIT1); - parseContext.update(Opm::ParseContext::RUNSPEC_GROUPSIZE_TOO_LARGE, Opm::InputError::DELAYED_EXIT1); + setWellDimsContext(Opm::InputError::DELAYED_EXIT1, parseContext); Opm::checkConsistentArrayDimensions(cse.es , cse.sched, parseContext, cse.guard);