Files
ResInsight/ApplicationLibCode/UnitTests/RigStimPlanFractureDefinition-Test.cpp
T
Magne Sjaastad 99d675b796 Fix crash when StimPlan file has no time steps
Time steps are not read when a file has more than one grid section. setDefaultsBasedOnFile() then indexed the empty time step list, and setDataAtTimeValue() wrote at index -1. Use index 0 and skip data for unknown time steps.

Call stack:
[0] performCrashLogging at ResInsight/ApplicationExeCode/RiaMainTools.cpp:178
[1] manageSegFailureSA(int, siginfo_t*, void*) at ResInsight/ApplicationExeCode/RiaMainTools.cpp:310
[3] RimStimPlanFractureTemplate::setDefaultsBasedOnFile() at ResInsight/ApplicationLibCode/ProjectDataModel/Completions/RimStimPlanFractureTemplate.cpp:116
[4] RicMeshFractureTemplateHelper<RimStimPlanFractureTemplate>::createNewTemplatesFromFiles(std::vector<QString, std::allocator<QString> > const&, QString const&, bool) at ResInsight/ApplicationLibCode/Commands/FractureCommands/RicMeshFractureTemplateHelper.inl:150
[5] RicMeshFractureTemplateHelper<RimStimPlanFractureTemplate>::createNewTemplates(QString const&, QString const&, QString const&, QString const&) at ResInsight/ApplicationLibCode/Commands/FractureCommands/RicMeshFractureTemplateHelper.inl:89
[6] RicNewStimPlanFractureTemplateFeature::createNewTemplates() at ResInsight/ApplicationLibCode/Commands/FractureCommands/RicNewStimPlanFractureTemplateFeature.cpp:58
[7] RicNewStimPlanFractureTemplateFeature::onActionTriggered(bool) at ResInsight/ApplicationLibCode/Commands/FractureCommands/RicNewStimPlanFractureTemplateFeature.cpp:78
[8] caf::CmdFeature::actionTriggered(bool) at ResInsight/Fwk/AppFwk/cafCommand/cafCmdFeature.cpp:176
[17] RiaGuiApplication::notify(QObject*, QEvent*) at ResInsight/ApplicationLibCode/Application/RiaGuiApplication.cpp:1879
[23] RiaGuiApplication::notify(QObject*, QEvent*) at ResInsight/ApplicationLibCode/Application/RiaGuiApplication.cpp:1879
[35] RiuMainWindow::customMenuRequested(QPoint const&) at ResInsight/ApplicationLibCode/UserInterface/RiuMainWindow.cpp:2094
[43] RiaGuiApplication::notify(QObject*, QEvent*) at ResInsight/ApplicationLibCode/Application/RiaGuiApplication.cpp:1879
[48] RiaGuiApplication::notify(QObject*, QEvent*) at ResInsight/ApplicationLibCode/Application/RiaGuiApplication.cpp:1879
[59] main at ResInsight/ApplicationExeCode/RiaMain.cpp:267
[60] __libc_start_main at :0
2026-11-09 10:22:43 +01:00

35 lines
1.8 KiB
C++

#include "gtest/gtest.h"
#include "RigStimPlanFractureDefinition.h"
//--------------------------------------------------------------------------------------------------
/// minY/maxY (and minDepth/maxDepth derived from them) must not crash when the StimPlan fracture
/// definition has no Y samples, e.g. when the "ys" element is missing from the XML file.
//--------------------------------------------------------------------------------------------------
TEST( RigStimPlanFractureDefinitionTest, MinMaxYWithEmptyYsDoesNotCrash )
{
cvf::ref<RigStimPlanFractureDefinition> fractureData = new RigStimPlanFractureDefinition;
EXPECT_EQ( size_t( 0 ), fractureData->yCount() );
EXPECT_NO_FATAL_FAILURE( fractureData->minDepth() );
EXPECT_NO_FATAL_FAILURE( fractureData->maxDepth() );
}
//--------------------------------------------------------------------------------------------------
/// Data for a time step that is not in the time step list is ignored
//--------------------------------------------------------------------------------------------------
TEST( RigStimPlanFractureDefinitionTest, SetDataAtUnknownTimeValueIsIgnored )
{
cvf::ref<RigStimPlanFractureDefinition> fractureData = new RigStimPlanFractureDefinition;
const std::vector<std::vector<double>> data = { { 1.0, 2.0 } };
EXPECT_FALSE( fractureData->setDataAtTimeValue( "CONDUCTIVITY", "md-m", data, 10.0 ) );
EXPECT_TRUE( fractureData->getDataAtTimeIndex( "CONDUCTIVITY", "md-m", 0 ).empty() );
fractureData->addTimeStep( 10.0 );
EXPECT_TRUE( fractureData->setDataAtTimeValue( "CONDUCTIVITY", "md-m", data, 10.0 ) );
EXPECT_FALSE( fractureData->setDataAtTimeValue( "CONDUCTIVITY", "md-m", data, 20.0 ) );
EXPECT_EQ( data, fractureData->getDataAtTimeIndex( "CONDUCTIVITY", "md-m", 0 ) );
}