From 0aa29411501332754c50b274105a2566e9816b2e Mon Sep 17 00:00:00 2001 From: goncalvesmachadoc Date: Thu, 6 Jul 2023 13:04:58 +0200 Subject: [PATCH] start for unit tests --- CMakeLists_files.cmake | 1 + .../EclipseState/Grid/LgrCollection.cpp | 9 +++++++ tests/parser/LgrTests.cpp | 27 +++++++++++++++++++ 3 files changed, 37 insertions(+) create mode 100644 tests/parser/LgrTests.cpp diff --git a/CMakeLists_files.cmake b/CMakeLists_files.cmake index dd5c8965b..1ea5bad5c 100644 --- a/CMakeLists_files.cmake +++ b/CMakeLists_files.cmake @@ -504,6 +504,7 @@ if(ENABLE_ECL_INPUT) tests/parser/ImportTests.cpp tests/parser/InitConfigTest.cpp tests/parser/IOConfigTests.cpp + tests/parser/LgrTests.cpp tests/parser/MICPTests.cpp tests/parser/MessageLimitTests.cpp tests/parser/MultiRegTests.cpp diff --git a/src/opm/input/eclipse/EclipseState/Grid/LgrCollection.cpp b/src/opm/input/eclipse/EclipseState/Grid/LgrCollection.cpp index 2d586082d..26aed247b 100644 --- a/src/opm/input/eclipse/EclipseState/Grid/LgrCollection.cpp +++ b/src/opm/input/eclipse/EclipseState/Grid/LgrCollection.cpp @@ -20,6 +20,7 @@ #include #include #include +#include #include @@ -59,4 +60,12 @@ namespace Opm { return m_lgrs.count( lgrName ) > 0; } + const Carfin& LgrCollection::getLgr(const std::string& lgrName) const { + return m_lgrs.get( lgrName ); + } + + Carfin& LgrCollection::getLgr(const std::string& lgrName) { + return m_lgrs.get( lgrName ); + } + } diff --git a/tests/parser/LgrTests.cpp b/tests/parser/LgrTests.cpp new file mode 100644 index 000000000..b269fd071 --- /dev/null +++ b/tests/parser/LgrTests.cpp @@ -0,0 +1,27 @@ +/* + Copyright (C) 2023 Equinor + 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 CarfinManagerTests + +#include + +#include + +BOOST_AUTO_TEST_CASE(CreateLgrCollection) { + Opm::LgrCollection lgrs; + BOOST_CHECK_EQUAL( lgrs.size() , 0U ); + BOOST_CHECK(! lgrs.hasLgr("NO-NotThisOne")); + BOOST_CHECK_THROW( lgrs.getLgr("NO") , std::invalid_argument ); +}