mirror of
https://github.com/OPM/ResInsight.git
synced 2025-01-01 03:37:15 -06:00
2814b92055
* Qt6: Avoid insertWidget, use addWidget In Qt6, the insertWidget function checks if the index parameter is valid based on current widgets present in the layout. This is error prone, and use addWidget to avoid manual counting of index. * Disable use of Qt keyword foreach * Replace use of QRegExp with QRegularExpression Replace use of QRegExp with QRegularExpression Remove dependency on qt5compat module Simplify an expression based on review * Remove Qt5 ifdefs * Guard access out of bounds seen in debug build * Avoid reuse of string variable * Disconnect all signals from the QOpenGLContext The call stack when this assert happens indicates that there are more signals to be disconnected from the object. Crash is fixed by disconnecting all signals. Assert seen in debug build: ASSERT failure in caf::Viewer: "Called object is not of the correct type (class destructor may have already run)", file C:\Qt\6.6.3\msvc2019_64\include\QtCore/qobjectdefs_impl.h, line 130 * Fix issue related to delete of a linked view Guard null pointer use in view linker. Remove complicated cleanup in destructor in Rim3dVew.
401 lines
17 KiB
C++
401 lines
17 KiB
C++
#include "gtest/gtest.h"
|
|
|
|
#include "RiaTestDataDirectory.h"
|
|
#include "RifEclipseInputFileTools.h"
|
|
#include "RigEclipseCaseData.h"
|
|
#include "RigEquil.h"
|
|
|
|
#include <QDebug>
|
|
#include <QFile>
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
///
|
|
//--------------------------------------------------------------------------------------------------
|
|
TEST( RifEclipseInputFileToolsTest, FaultFaces )
|
|
{
|
|
{
|
|
QStringList faceTexts;
|
|
faceTexts << "X"
|
|
<< "X+"
|
|
<< "I"
|
|
<< "I+"
|
|
<< "x"
|
|
<< "x+"
|
|
<< "i"
|
|
<< "i+";
|
|
|
|
cvf::StructGridInterface::FaceEnum faceType;
|
|
for ( const QString& text : faceTexts )
|
|
{
|
|
faceType = RifEclipseInputFileTools::faceEnumFromText( text );
|
|
EXPECT_EQ( cvf::StructGridInterface::POS_I, faceType );
|
|
}
|
|
}
|
|
|
|
{
|
|
QStringList faceTexts;
|
|
faceTexts << "X-"
|
|
<< "I-"
|
|
<< "x-"
|
|
<< "i-";
|
|
|
|
cvf::StructGridInterface::FaceEnum faceType;
|
|
for ( const QString& text : faceTexts )
|
|
{
|
|
faceType = RifEclipseInputFileTools::faceEnumFromText( text );
|
|
EXPECT_EQ( cvf::StructGridInterface::NEG_I, faceType );
|
|
}
|
|
}
|
|
|
|
{
|
|
QStringList faceTexts;
|
|
faceTexts << "Y"
|
|
<< "Y+"
|
|
<< "J"
|
|
<< "J+"
|
|
<< "y"
|
|
<< "y+"
|
|
<< "j"
|
|
<< "j+";
|
|
|
|
cvf::StructGridInterface::FaceEnum faceType;
|
|
for ( const QString& text : faceTexts )
|
|
{
|
|
faceType = RifEclipseInputFileTools::faceEnumFromText( text );
|
|
EXPECT_EQ( cvf::StructGridInterface::POS_J, faceType );
|
|
}
|
|
}
|
|
|
|
{
|
|
QStringList faceTexts;
|
|
faceTexts << "Y-"
|
|
<< "J-"
|
|
<< "y-"
|
|
<< "j-";
|
|
|
|
cvf::StructGridInterface::FaceEnum faceType;
|
|
for ( const QString& text : faceTexts )
|
|
{
|
|
faceType = RifEclipseInputFileTools::faceEnumFromText( text );
|
|
EXPECT_EQ( cvf::StructGridInterface::NEG_J, faceType );
|
|
}
|
|
}
|
|
|
|
{
|
|
QStringList faceTexts;
|
|
faceTexts << "Z"
|
|
<< "Z+"
|
|
<< "K"
|
|
<< "k+"
|
|
<< "z"
|
|
<< "z+"
|
|
<< "k"
|
|
<< "k+";
|
|
|
|
cvf::StructGridInterface::FaceEnum faceType;
|
|
for ( const QString& text : faceTexts )
|
|
{
|
|
faceType = RifEclipseInputFileTools::faceEnumFromText( text );
|
|
EXPECT_EQ( cvf::StructGridInterface::POS_K, faceType );
|
|
}
|
|
}
|
|
|
|
{
|
|
QStringList faceTexts;
|
|
faceTexts << "Z-"
|
|
<< "K-"
|
|
<< "z-"
|
|
<< "k-";
|
|
|
|
cvf::StructGridInterface::FaceEnum faceType;
|
|
for ( const QString& text : faceTexts )
|
|
{
|
|
faceType = RifEclipseInputFileTools::faceEnumFromText( text );
|
|
EXPECT_EQ( cvf::StructGridInterface::NEG_K, faceType );
|
|
}
|
|
}
|
|
|
|
// Improved parsing handling some special cases
|
|
{
|
|
QStringList faceTexts;
|
|
faceTexts << "Z--"
|
|
<< "z--"
|
|
<< "z/"
|
|
<< " y /";
|
|
|
|
cvf::StructGridInterface::FaceEnum faceType;
|
|
for ( const QString& text : faceTexts )
|
|
{
|
|
faceType = RifEclipseInputFileTools::faceEnumFromText( text );
|
|
EXPECT_NE( cvf::StructGridInterface::NO_FACE, faceType );
|
|
}
|
|
}
|
|
|
|
// Invalid faces
|
|
{
|
|
QStringList faceTexts;
|
|
faceTexts << "-k-"
|
|
<< " -k "
|
|
<< " +k- ";
|
|
|
|
cvf::StructGridInterface::FaceEnum faceType;
|
|
for ( const QString& text : faceTexts )
|
|
{
|
|
faceType = RifEclipseInputFileTools::faceEnumFromText( text );
|
|
EXPECT_EQ( cvf::StructGridInterface::NO_FACE, faceType );
|
|
}
|
|
}
|
|
|
|
// Valid cases with whitespace
|
|
{
|
|
QStringList faceTexts;
|
|
faceTexts << " X"
|
|
<< " X+ "
|
|
<< " I "
|
|
<< " i+ ";
|
|
|
|
cvf::StructGridInterface::FaceEnum faceType;
|
|
for ( const QString& text : faceTexts )
|
|
{
|
|
faceType = RifEclipseInputFileTools::faceEnumFromText( text );
|
|
EXPECT_EQ( cvf::StructGridInterface::POS_I, faceType );
|
|
}
|
|
}
|
|
}
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
///
|
|
//--------------------------------------------------------------------------------------------------
|
|
TEST( RifEclipseInputFileToolsTest, EquilData )
|
|
{
|
|
static const QString testDataRootFolder = QString( "%1/ParsingOfDataKeywords/" ).arg( TEST_DATA_DIR );
|
|
|
|
{
|
|
QString fileName = testDataRootFolder + "simulation/MY_CASE.DATA";
|
|
|
|
QFile data( fileName );
|
|
if ( !data.open( QFile::ReadOnly ) )
|
|
{
|
|
return;
|
|
}
|
|
|
|
std::vector<std::pair<QString, QString>> pathAliasDefinitions;
|
|
RifEclipseInputFileTools::parseAndReadPathAliasKeyword( fileName, &pathAliasDefinitions );
|
|
|
|
const QString keyword( "EQUIL" );
|
|
const QString keywordToStopParsing;
|
|
const qint64 startPositionInFile = 0;
|
|
QStringList keywordContent;
|
|
std::vector<QString> fileNamesContainingKeyword;
|
|
bool isStopParsingKeywordDetected = false;
|
|
const QString includeStatementAbsolutePathPrefix;
|
|
|
|
RifEclipseInputFileTools::readKeywordAndParseIncludeStatementsRecursively( keyword,
|
|
keywordToStopParsing,
|
|
pathAliasDefinitions,
|
|
includeStatementAbsolutePathPrefix,
|
|
data,
|
|
startPositionInFile,
|
|
keywordContent,
|
|
fileNamesContainingKeyword,
|
|
isStopParsingKeywordDetected );
|
|
EXPECT_EQ( (int)10, keywordContent.size() );
|
|
}
|
|
}
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
///
|
|
//--------------------------------------------------------------------------------------------------
|
|
TEST( RifEclipseInputFileToolsTest, FaultData )
|
|
{
|
|
static const QString testDataRootFolder = QString( "%1/ParsingOfDataKeywords/" ).arg( TEST_DATA_DIR );
|
|
|
|
{
|
|
QString fileName = testDataRootFolder + "simulation/MY_CASE.DATA";
|
|
|
|
QFile data( fileName );
|
|
if ( !data.open( QFile::ReadOnly ) )
|
|
{
|
|
return;
|
|
}
|
|
|
|
std::vector<std::pair<QString, QString>> pathAliasDefinitions;
|
|
RifEclipseInputFileTools::parseAndReadPathAliasKeyword( fileName, &pathAliasDefinitions );
|
|
|
|
const QString keyword( "FAULTS" );
|
|
const QString keywordToStopParsing;
|
|
const qint64 startPositionInFile = 0;
|
|
QStringList keywordContent;
|
|
std::vector<QString> fileNamesContainingKeyword;
|
|
bool isStopParsingKeywordDetected = false;
|
|
const QString includeStatementAbsolutePathPrefix;
|
|
|
|
RifEclipseInputFileTools::readKeywordAndParseIncludeStatementsRecursively( keyword,
|
|
keywordToStopParsing,
|
|
pathAliasDefinitions,
|
|
includeStatementAbsolutePathPrefix,
|
|
data,
|
|
startPositionInFile,
|
|
keywordContent,
|
|
fileNamesContainingKeyword,
|
|
isStopParsingKeywordDetected );
|
|
|
|
EXPECT_EQ( (int)977, keywordContent.size() );
|
|
|
|
/*
|
|
for (const auto& s : keywordContent)
|
|
{
|
|
qDebug() << s;
|
|
}
|
|
*/
|
|
}
|
|
}
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
///
|
|
//--------------------------------------------------------------------------------------------------
|
|
TEST( RifEclipseInputFileToolsTest, FaultDataPflotran )
|
|
{
|
|
static const QString testDataRootFolder = QString( "%1/RifEclipseInputFileTools/pflotran" ).arg( TEST_DATA_DIR );
|
|
|
|
{
|
|
QString fileName = testDataRootFolder + "/model/P_FLT_TEST_NO-KH.in";
|
|
|
|
cvf::Collection<RigFault> faults;
|
|
|
|
RifEclipseInputFileTools::parsePflotranInputFile( fileName, &faults );
|
|
|
|
EXPECT_EQ( (size_t)4, faults.size() );
|
|
}
|
|
}
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
///
|
|
//--------------------------------------------------------------------------------------------------
|
|
TEST( RifEclipseInputFileToolsTest, StopAtKeyword )
|
|
{
|
|
static const QString testDataRootFolder = QString( "%1/ParsingOfDataKeywords/" ).arg( TEST_DATA_DIR );
|
|
QString fileName = testDataRootFolder + "simulation/MY_CASE_2.DATA";
|
|
|
|
QFile data( fileName );
|
|
if ( !data.open( QFile::ReadOnly ) )
|
|
{
|
|
return;
|
|
}
|
|
|
|
{
|
|
const QString keyword( "FAULTS" );
|
|
const QString keywordToStopParsing( "EDIT" );
|
|
const qint64 startPositionInFile = 0;
|
|
std::vector<std::pair<QString, QString>> pathAliasDefinitions;
|
|
QStringList keywordContent;
|
|
std::vector<QString> fileNamesContainingKeyword;
|
|
bool isStopParsingKeywordDetected = false;
|
|
const QString includeStatementAbsolutePathPrefix;
|
|
|
|
RifEclipseInputFileTools::readKeywordAndParseIncludeStatementsRecursively( keyword,
|
|
keywordToStopParsing,
|
|
pathAliasDefinitions,
|
|
includeStatementAbsolutePathPrefix,
|
|
data,
|
|
startPositionInFile,
|
|
keywordContent,
|
|
fileNamesContainingKeyword,
|
|
isStopParsingKeywordDetected );
|
|
|
|
EXPECT_TRUE( isStopParsingKeywordDetected );
|
|
EXPECT_TRUE( keywordContent.isEmpty() );
|
|
}
|
|
|
|
{
|
|
const QString keyword( "EQUIL" );
|
|
const QString keywordToStopParsing( "SCHEDULE" );
|
|
const qint64 startPositionInFile = 0;
|
|
std::vector<std::pair<QString, QString>> pathAliasDefinitions;
|
|
QStringList keywordContent;
|
|
std::vector<QString> fileNamesContainingKeyword;
|
|
bool isStopParsingKeywordDetected = false;
|
|
const QString includeStatementAbsolutePathPrefix;
|
|
|
|
RifEclipseInputFileTools::readKeywordAndParseIncludeStatementsRecursively( keyword,
|
|
keywordToStopParsing,
|
|
pathAliasDefinitions,
|
|
includeStatementAbsolutePathPrefix,
|
|
data,
|
|
startPositionInFile,
|
|
keywordContent,
|
|
fileNamesContainingKeyword,
|
|
isStopParsingKeywordDetected );
|
|
EXPECT_TRUE( isStopParsingKeywordDetected );
|
|
EXPECT_TRUE( keywordContent.isEmpty() );
|
|
}
|
|
}
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
///
|
|
//--------------------------------------------------------------------------------------------------
|
|
TEST( RifEclipseInputFileToolsTest, DISABLED_FindFilesWithVfp )
|
|
{
|
|
QString fileName = "d:/gitroot-ceesol/ResInsight-regression-test/ModelData/norne/NORNE_ATW2013.DATA";
|
|
|
|
{
|
|
QFile data( fileName );
|
|
if ( !data.open( QFile::ReadOnly ) )
|
|
{
|
|
return;
|
|
}
|
|
|
|
const QString keyword( "VFPPROD" );
|
|
const QString keywordToStopParsing;
|
|
const qint64 startPositionInFile = 0;
|
|
std::vector<std::pair<QString, QString>> pathAliasDefinitions;
|
|
QStringList keywordContent;
|
|
std::vector<QString> fileNamesContainingKeyword;
|
|
bool isStopParsingKeywordDetected = false;
|
|
const QString includeStatementAbsolutePathPrefix;
|
|
|
|
RifEclipseInputFileTools::readKeywordAndParseIncludeStatementsRecursively( keyword,
|
|
keywordToStopParsing,
|
|
pathAliasDefinitions,
|
|
includeStatementAbsolutePathPrefix,
|
|
data,
|
|
startPositionInFile,
|
|
keywordContent,
|
|
fileNamesContainingKeyword,
|
|
isStopParsingKeywordDetected );
|
|
|
|
// EXPECT_TRUE( isStopParsingKeywordDetected );
|
|
// EXPECT_TRUE( keywordContent.isEmpty() );
|
|
}
|
|
|
|
{
|
|
QFile data( fileName );
|
|
if ( !data.open( QFile::ReadOnly ) )
|
|
{
|
|
return;
|
|
}
|
|
|
|
const QString keyword( "VFPINJ" );
|
|
const QString keywordToStopParsing;
|
|
const qint64 startPositionInFile = 0;
|
|
std::vector<std::pair<QString, QString>> pathAliasDefinitions;
|
|
QStringList keywordContent;
|
|
std::vector<QString> fileNamesContainingKeyword;
|
|
bool isStopParsingKeywordDetected = false;
|
|
const QString includeStatementAbsolutePathPrefix;
|
|
|
|
RifEclipseInputFileTools::readKeywordAndParseIncludeStatementsRecursively( keyword,
|
|
keywordToStopParsing,
|
|
pathAliasDefinitions,
|
|
includeStatementAbsolutePathPrefix,
|
|
data,
|
|
startPositionInFile,
|
|
keywordContent,
|
|
fileNamesContainingKeyword,
|
|
isStopParsingKeywordDetected );
|
|
|
|
// EXPECT_TRUE( isStopParsingKeywordDetected );
|
|
// EXPECT_TRUE( keywordContent.isEmpty() );
|
|
}
|
|
}
|