mirror of
https://github.com/OPM/ResInsight.git
synced 2026-10-24 22:27:55 -05:00
Fix crash in RigStimPlanFractureDefinition::minY/maxY on empty Ys
This commit is contained in:
1 parent
a94358cc0d
commit
a6a2f349b6
3 files changed
+22
-2
No files matched your search
@@ -127,7 +127,9 @@ double RigStimPlanFractureDefinition::bottomPerfTvd() const
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
double RigStimPlanFractureDefinition::minY() const
|
||||
{
|
||||
CAF_ASSERT( !m_Ys.empty() );
|
||||
// An empty m_Ys is not a programming error but a legitimate consequence of a StimPlan file
|
||||
// missing its "ys" grid data, so return a safe default instead of asserting.
|
||||
if ( m_Ys.empty() ) return 0.0;
|
||||
return m_Ys[0];
|
||||
}
|
||||
|
||||
@@ -136,7 +138,7 @@ double RigStimPlanFractureDefinition::minY() const
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
double RigStimPlanFractureDefinition::maxY() const
|
||||
{
|
||||
CAF_ASSERT( !m_Ys.empty() );
|
||||
if ( m_Ys.empty() ) return 0.0;
|
||||
return m_Ys.back();
|
||||
}
|
||||
|
||||
|
||||
@@ -39,6 +39,7 @@ set(SOURCE_UNITTEST_FILES
|
||||
${CMAKE_CURRENT_LIST_DIR}/RigNestedHybridGridReconstructor-Test.cpp
|
||||
${CMAKE_CURRENT_LIST_DIR}/RigStatisticsMath-Test.cpp
|
||||
${CMAKE_CURRENT_LIST_DIR}/RigStimPlanModelTools-Test.cpp
|
||||
${CMAKE_CURRENT_LIST_DIR}/RigStimPlanFractureDefinition-Test.cpp
|
||||
${CMAKE_CURRENT_LIST_DIR}/RigWellPathIntersectionTools-Test.cpp
|
||||
${CMAKE_CURRENT_LIST_DIR}/RimHistogramDataSource-Test.cpp
|
||||
${CMAKE_CURRENT_LIST_DIR}/RimPlotAxisTools-Test.cpp
|
||||
|
||||
@@ -0,0 +1,17 @@
|
||||
#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() );
|
||||
}
|
||||
Reference in new issue
Block a user