mirror of
https://github.com/OPM/ResInsight.git
synced 2026-08-27 05:37:21 -05:00
Fix index out of bounds in RigReservoirBuilderMock and RigWellTargetMappingTools test
Guard NNC cell indices against out-of-bounds in addNnc. Fix test using ActiveCellIndex(1) on a single-element vector.
This commit is contained in:
@@ -384,6 +384,9 @@ void RigReservoirBuilderMock::enableWellData( bool enableWellData )
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void RigReservoirBuilderMock::addNnc( RigMainGrid* grid, size_t i1, size_t j1, size_t k1, size_t i2, size_t j2, size_t k2, RigConnectionContainer& nncConnections )
|
||||
{
|
||||
if ( i1 >= grid->cellCountI() || j1 >= grid->cellCountJ() || k1 >= grid->cellCountK() ) return;
|
||||
if ( i2 >= grid->cellCountI() || j2 >= grid->cellCountJ() || k2 >= grid->cellCountK() ) return;
|
||||
|
||||
size_t c1GlobalIndex = grid->cellIndexFromIJK( i1, j1, k1 );
|
||||
size_t c2GlobalIndex = grid->cellIndexFromIJK( i2, j2, k2 );
|
||||
|
||||
|
||||
@@ -283,7 +283,7 @@ TEST( RigWellTargetMappingToolsTest, IsSaturationSufficient_OilBelowThreshold_Re
|
||||
limits.saturationOil = 0.2;
|
||||
limits.saturationGas = 0.1;
|
||||
|
||||
EXPECT_FALSE( RigWellTargetMappingTools::isSaturationSufficient( VolumeType::OIL, data, limits, ActiveCellIndex( 1 ) ) );
|
||||
EXPECT_FALSE( RigWellTargetMappingTools::isSaturationSufficient( VolumeType::OIL, data, limits, ActiveCellIndex( 0 ) ) );
|
||||
}
|
||||
|
||||
TEST( RigWellTargetMappingToolsTest, IsSaturationSufficient_OilExactlyAtThreshold_ReturnsTrue )
|
||||
|
||||
Reference in New Issue
Block a user