mirror of
https://github.com/OPM/ResInsight.git
synced 2025-02-25 18:55:39 -06:00
#742 Integrated opm-parser and added basic unit test
This commit is contained in:
parent
2892653298
commit
9b6e422d0c
@ -27,6 +27,10 @@ include_directories(
|
||||
${ResInsight_SOURCE_DIR}/ThirdParty/Qwt/src
|
||||
${ERT_INCLUDE_DIRS}
|
||||
|
||||
${Boost_INCLUDE_DIRS}
|
||||
${custom-opm-common_SOURCE_DIR}/opm-common/
|
||||
${custom-opm-parser_SOURCE_DIR}/opm-parser/
|
||||
|
||||
${CMAKE_CURRENT_SOURCE_DIR}
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/Adm
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/Application
|
||||
@ -379,6 +383,7 @@ set( LINK_LIBRARIES
|
||||
|
||||
custom-opm-common
|
||||
custom-opm-parser
|
||||
opmjson
|
||||
|
||||
NRLib
|
||||
|
||||
|
@ -21,6 +21,7 @@ ${CEE_CURRENT_LIST_DIR}RivPipeGeometryGenerator-Test.cpp
|
||||
${CEE_CURRENT_LIST_DIR}RivTernaryScalarMapper-Test.cpp
|
||||
${CEE_CURRENT_LIST_DIR}ScalarMapper-Test.cpp
|
||||
${CEE_CURRENT_LIST_DIR}WellPathAsciiFileReader-Test.cpp
|
||||
${CEE_CURRENT_LIST_DIR}opm-parser-Test.cpp
|
||||
)
|
||||
|
||||
list(APPEND CODE_HEADER_FILES
|
||||
|
103
ApplicationCode/UnitTests/opm-parser-Test.cpp
Normal file
103
ApplicationCode/UnitTests/opm-parser-Test.cpp
Normal file
@ -0,0 +1,103 @@
|
||||
#include "gtest/gtest.h"
|
||||
|
||||
|
||||
/*
|
||||
#include <opm/parser/eclipse/Parser/Parser.hpp>
|
||||
#include "opm/parser/eclipse/Parser/ParseContext.hpp"
|
||||
#include "opm/json/JsonObject.hpp"
|
||||
#include "opm/parser/eclipse/Parser/ParserStringItem.hpp"
|
||||
#include "opm/parser/eclipse/Parser/ParserRecord.hpp"
|
||||
*/
|
||||
|
||||
/*
|
||||
#include "custom-opm-common/opm-common/opm/common/OpmLog/Logger.hpp"
|
||||
#include "custom-opm-common/opm-common/opm/common/OpmLog/CounterLog.hpp"
|
||||
#include "custom-opm-common/opm-common/opm/common/OpmLog/StreamLog.hpp"
|
||||
#include "custom-opm-common/opm-common/opm/common/OpmLog/LogUtil.hpp"
|
||||
*/
|
||||
|
||||
#include "custom-opm-parser/opm-parser/opm/parser/eclipse/Parser/Parser.hpp"
|
||||
|
||||
|
||||
using namespace Opm;
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
TEST(opm_parser_test, basicConstruction)
|
||||
{
|
||||
Parser parser;
|
||||
std::string filename = "d:/Models/Statoil/testcase_juli_2011/data/TEST10K_FLT_LGR_NNC.DATA";
|
||||
// parser.newDeckFromFile(filename, Opm::ParseContext());
|
||||
/*
|
||||
{
|
||||
std::string inline_json = "{\"key\": \"value\"}";
|
||||
Json::JsonObject parser(inline_json);
|
||||
parser.has_item("key");
|
||||
parser.has_item("keyX");
|
||||
}
|
||||
|
||||
{
|
||||
ParserStringItemPtr itemString(new ParserStringItem(std::string("STRINGITEM1")));
|
||||
ParserRecordPtr record1(new ParserRecord());
|
||||
RawRecord rawRecord(" ' VALUE ' ");
|
||||
ParseContext parseContext;
|
||||
record1->addItem(itemString);
|
||||
//BOOST_CHECK_EQUAL(" VALUE ", deckRecord.getItem(0).get< std::string >(0));
|
||||
}
|
||||
|
||||
*/
|
||||
{
|
||||
const auto* input_deck = "RUNSPEC\n\n"
|
||||
"TITLE\n\n"
|
||||
"DIMENS\n10 10 10/\n"
|
||||
"EQLDIMS\n/\n";
|
||||
|
||||
Parser parser;
|
||||
const auto deck = parser.newDeckFromString(input_deck, ParseContext());
|
||||
//BOOST_CHECK_EQUAL("untitled", deck->getKeyword("TITLE").getStringData().front());
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
// TEST opm- common
|
||||
TEST(opm_parser_test, opm_common_test)
|
||||
{
|
||||
/*
|
||||
Logger logger;
|
||||
std::ostringstream log_stream;
|
||||
std::shared_ptr<CounterLog> counter = std::make_shared<CounterLog>();
|
||||
std::shared_ptr<StreamLog> streamLog = std::make_shared<StreamLog>(log_stream, Log::MessageType::Warning);
|
||||
logger.hasBackend("NO");
|
||||
|
||||
logger.addBackend("COUNTER", counter);
|
||||
logger.addBackend("STREAM", streamLog);
|
||||
*/
|
||||
/*
|
||||
BOOST_CHECK_EQUAL(true, logger.hasBackend("COUNTER"));
|
||||
BOOST_CHECK_EQUAL(true, logger.hasBackend("STREAM"));
|
||||
|
||||
logger.addMessage(Log::MessageType::Error, "Error");
|
||||
logger.addMessage(Log::MessageType::Warning, "Warning");
|
||||
BOOST_CHECK_EQUAL(1U, counter->numMessages(Log::MessageType::Error));
|
||||
BOOST_CHECK_EQUAL(1U, counter->numMessages(Log::MessageType::Warning));
|
||||
BOOST_CHECK_EQUAL(0U, counter->numMessages(Log::MessageType::Info));
|
||||
|
||||
BOOST_CHECK_EQUAL(log_stream.str(), "Warning\n");
|
||||
|
||||
|
||||
BOOST_CHECK_THROW(logger.getBackend<LogBackend>("No"), std::invalid_argument);
|
||||
{
|
||||
auto counter2 = logger.getBackend<CounterLog>("COUNTER");
|
||||
BOOST_CHECK_EQUAL(1U, counter2->numMessages(Log::MessageType::Warning));
|
||||
BOOST_CHECK_EQUAL(1U, counter2->numMessages(Log::MessageType::Error));
|
||||
BOOST_CHECK_EQUAL(0, counter2->numMessages(Log::MessageType::Info));
|
||||
}
|
||||
|
||||
BOOST_CHECK_EQUAL(false, logger.removeBackend("NO-not-found"));
|
||||
BOOST_CHECK_EQUAL(true, logger.removeBackend("COUNTER"));
|
||||
BOOST_CHECK_EQUAL(false, logger.hasBackend("COUNTER"));
|
||||
*/
|
||||
}
|
@ -61,7 +61,9 @@ endif ()
|
||||
set(Boost_USE_MULTITHREADED ON)
|
||||
set(Boost_USE_STATIC_RUNTIME OFF)
|
||||
|
||||
|
||||
if (MSVC)
|
||||
ADD_DEFINITIONS("-DBOOST_ALL_NO_LIB")
|
||||
endif()
|
||||
|
||||
|
||||
# Requires BOOST filesystem version 3, thus 1.44 is necessary.
|
||||
@ -102,7 +104,7 @@ else(RESINSIGHT_ERT_EXTERNAL_LIB_ROOT OR RESINSIGHT_ERT_EXTERNAL_INCLUDE_ROOT)
|
||||
SET(BUILD_PYTHON OFF CACHE BOOL "ERT: Run py_compile on the python wrappers")
|
||||
SET(BUILD_SHARED_LIBS OFF CACHE BOOL "ERT: Build shared libraries")
|
||||
SET(ERT_USE_OPENMP ${OPENMP_FOUND} CACHE BOOL "ERT: Compile using OpenMP")
|
||||
SET(ERT_BUILD_CXX OFF CACHE BOOL "ERT: Disable build of CXX wrappers")
|
||||
SET(ERT_BUILD_CXX ON CACHE BOOL "ERT: Enable build of CXX wrappers")
|
||||
|
||||
if (NOT MSVC)
|
||||
SET(RESINSIGHT_ERT_EXTERNAL_SOURCE_ROOT "" CACHE STRING "Path to ERT CMakeList.txt (source path)")
|
||||
@ -129,15 +131,19 @@ else(RESINSIGHT_ERT_EXTERNAL_LIB_ROOT OR RESINSIGHT_ERT_EXTERNAL_INCLUDE_ROOT)
|
||||
|
||||
list(APPEND ERT_LIBRARIES
|
||||
ecl
|
||||
eclxx
|
||||
ecl_well
|
||||
ert_geometry
|
||||
ert_util
|
||||
)
|
||||
|
||||
set_property(TARGET
|
||||
${ERT_LIBRARIES}
|
||||
PROPERTY FOLDER "ERT"
|
||||
)
|
||||
if (MSVC)
|
||||
set_property(TARGET
|
||||
${ERT_LIBRARIES}
|
||||
ecl_lfs
|
||||
PROPERTY FOLDER "ERT"
|
||||
)
|
||||
endif()
|
||||
|
||||
endif(RESINSIGHT_ERT_EXTERNAL_LIB_ROOT OR RESINSIGHT_ERT_EXTERNAL_INCLUDE_ROOT)
|
||||
|
||||
@ -149,6 +155,16 @@ endif(RESINSIGHT_ERT_EXTERNAL_LIB_ROOT OR RESINSIGHT_ERT_EXTERNAL_INCLUDE_ROOT)
|
||||
add_subdirectory(ThirdParty/custom-opm-common)
|
||||
add_subdirectory(ThirdParty/custom-opm-parser)
|
||||
|
||||
include_directories(${custom-opm-parser_SOURCE_DIR}/opm-parser/)
|
||||
add_subdirectory(ThirdParty/custom-opm-parser/opm-parser/opm/json)
|
||||
|
||||
set_property(TARGET
|
||||
custom-opm-common
|
||||
custom-opm-parser
|
||||
opmjson
|
||||
PROPERTY FOLDER "OPM"
|
||||
)
|
||||
|
||||
|
||||
################################################################################
|
||||
# NRLib
|
||||
|
4
ThirdParty/NRLib/CMakeLists.txt
vendored
4
ThirdParty/NRLib/CMakeLists.txt
vendored
@ -1,6 +1,8 @@
|
||||
cmake_minimum_required (VERSION 2.8)
|
||||
|
||||
ADD_DEFINITIONS("-DBOOST_ALL_NO_LIB")
|
||||
if (MSVC)
|
||||
ADD_DEFINITIONS("-DBOOST_ALL_NO_LIB")
|
||||
endif()
|
||||
|
||||
project (NRLib)
|
||||
|
||||
|
15
ThirdParty/custom-opm-parser/CMakeLists.txt
vendored
15
ThirdParty/custom-opm-parser/CMakeLists.txt
vendored
@ -1,5 +1,20 @@
|
||||
cmake_minimum_required (VERSION 2.8)
|
||||
|
||||
|
||||
# -DBOOST_FILESYSTEM_VERSION=3 -DBOOST_TEST_DYN_LINK -DHAVE_CASE_SENSITIVE_FILESYSTEM=1 -DHAVE_REGEX=1 -DOPM_PARSER_DECK_API=1 -Wall -std=c++11 -fopenmp -Wall -g -O0 -DDEBUG -ggdb3
|
||||
|
||||
|
||||
if(MSVC)
|
||||
add_definitions( "/W3 /D_CRT_SECURE_NO_WARNINGS /wd4996" )
|
||||
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /MP")
|
||||
else()
|
||||
#always set these flags to make opm-parser compile on Linux
|
||||
SET( CMAKE_CXX_FLAGS "-pipe -std=c++0x -pedantic -Wall -Wextra -Wformat-nonliteral -Wcast-align -Wpointer-arith -Wmissing-declarations -Wcast-qual -Wshadow -Wwrite-strings -Wchar-subscripts -Wredundant-decls")
|
||||
|
||||
SET( CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS} ${CMAKE_CXX_FLAGS_DEBUG} -O0 -DDEBUG -ggdb3")
|
||||
SET( CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS} ${CMAKE_CXX_FLAGS_RELEASE} -O3 -DNDEBUG -mtune=native")
|
||||
endif(MSVC)
|
||||
|
||||
project (custom-opm-parser)
|
||||
|
||||
include_directories(
|
||||
|
Loading…
Reference in New Issue
Block a user