ResInsight/ApplicationLibCode/UnitTests/RifCaseRealizationParametersReader-Test.cpp
Kristian Bendiksen ff209ad7c2
Refactor ensemble import dialog
* #9773 Refactor ensemble import dialog.
* #9773 Add support for ensemble import of StimPlan/Reveal summary data.
* #9773 Add method for finding min and max time steps.
* #9773 Add option for resampling to hour intervals.
* #9773 Add option for resampling to minute intervals.
* #9773 Ensemble statistics: determine sub-sampling period dynamically.
* Use RiaWeightedMeanCalculator for curve resampling.
* Add HOUR and MINUTE to date time app enum.
* #9773 Generate better ensembles for StimPlan summaries.
* #9773 Fix parameters.txt lookup for StimPlan summaries
* Refactor: Improve interface of RicImportSummaryCasesFreature::createSummaryCasesFromFiles

Co-authored-by: Magne Sjaastad <magne.sjaastad@ceetronsolutions.com>
2023-04-20 10:16:43 +02:00

77 lines
3.2 KiB
C++

#include "gtest/gtest.h"
#include "RiaTestDataDirectory.h"
#include "RifCaseRealizationParametersReader.h"
#include "RifFileParseTools.h"
#include <QString>
#include <numeric>
static const QString CASE_REAL_TEST_DATA_DIRECTORY_01 = QString( "%1/RifCaseRealizationParametersReader/" ).arg( TEST_DATA_DIR );
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
TEST( RifCaseRealizationParametersReaderTest, LocatorTestSuccess )
{
QString file = RifCaseRealizationParametersFileLocator::locate( CASE_REAL_TEST_DATA_DIRECTORY_01 + "4/3/2" );
QString expected = CASE_REAL_TEST_DATA_DIRECTORY_01 + "parameters.txt";
EXPECT_EQ( expected.toStdString(), file.toStdString() );
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
TEST( RifCaseRealizationParametersReaderTest, LocatorTestFailure )
{
QString file = RifCaseRealizationParametersFileLocator::locate( CASE_REAL_TEST_DATA_DIRECTORY_01 + "6/5/4/3/2/1" );
QString expected = "";
EXPECT_EQ( expected.toStdString(), file.toStdString() );
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
TEST( RifCaseRealizationParametersReaderTest, SuccessfulParsing )
{
RifCaseRealizationParametersReader reader( CASE_REAL_TEST_DATA_DIRECTORY_01 + "parameters.txt" );
try
{
reader.parse();
const std::shared_ptr<RigCaseRealizationParameters> parameters( reader.parameters() );
std::map<QString, RigCaseRealizationParameters::Value> params = parameters->parameters();
EXPECT_EQ( 1U, params.count( "LETSWOF:L_1OW" ) );
EXPECT_EQ( 1U, params.count( "LETSGOF:KRG1" ) );
EXPECT_EQ( 1U, params.count( "LOG10_MULTFLT:MULTFLT_F1" ) );
EXPECT_EQ( 1U, params.count( "TST:TEXT_PARAM" ) );
EXPECT_TRUE( params["LETSWOF:L_1OW"].isNumeric() );
EXPECT_EQ( 1.83555, params["LETSWOF:L_1OW"].numericValue() );
EXPECT_TRUE( params["LETSGOF:KRG1"].isNumeric() );
EXPECT_EQ( 0.97, params["LETSGOF:KRG1"].numericValue() );
EXPECT_TRUE( params["TST:TEXT_PARAM"].isText() );
EXPECT_EQ( std::string( "YES" ), params["TST:TEXT_PARAM"].textValue().toStdString() );
}
catch ( ... )
{
EXPECT_TRUE( false );
}
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
TEST( RifCaseRealizationParametersReaderTest, FindRealizationNumber )
{
QString filePath = "d:/gitroot-ceesol/ResInsight-regression-test/ModelData/ensemble_reek_with_params/realization-"
"7/iter-0/eclipse/model/3_R001_REEK-7.SMSPEC";
int realisationNumber = RifCaseRealizationParametersFileLocator::realizationNumber( filePath );
EXPECT_EQ( 7, realisationNumber );
}