Files
ResInsight/ApplicationLibCode/UnitTests/RifPerforationIntervalReader-Test.cpp
T
Magne Sjaastad ab96c520bd #14895: Improve stability when importing malformed input files
* #14895: Fix null grid dereference when importing mismatching GRDECL
* #14895: Fix out-of-bounds read in perforation interval import
* #14895: Validate connectivity indices in VTK import
* #14895: Fix heap overflow for odd PORV count in dual porosity cases
* #14895: Update roffcpp to validate array lengths when parsing ROFF files
2026-10-12 09:40:23 +02:00

53 lines
2.0 KiB
C++

#include "gtest/gtest.h"
#include "RiaTestDataDirectory.h"
#include "RifPerforationIntervalReader.h"
#include <cmath> // Needed for HUGE_VAL on Linux
#include <numeric>
#include <QFile>
#include <QTemporaryDir>
#include <QTextStream>
static const QString PERFORATION_TEST_DATA_DIRECTORY = QString( "%1/RifPerforationIntervalReader/" ).arg( TEST_DATA_DIR );
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
TEST( RifPerforationIntervalReaderTest, SpacesInWellNameHandledSuccessfully )
{
std::map<QString, std::vector<RifPerforationInterval>> perforationIntervals = RifPerforationIntervalReader::readPerforationIntervals(
PERFORATION_TEST_DATA_DIRECTORY + "perforations_with_space_after_well_name.ev" );
EXPECT_EQ( size_t( 10 ), perforationIntervals["A1_RI_HZX"].size() );
}
//--------------------------------------------------------------------------------------------------
/// Records with too few fields used to read outside the list of parts and crash.
//--------------------------------------------------------------------------------------------------
TEST( RifPerforationIntervalReaderTest, ShortRecordsAreSkipped )
{
QTemporaryDir tempDir;
ASSERT_TRUE( tempDir.isValid() );
QString fileName = tempDir.path() + "/short.ev";
{
QFile file( fileName );
ASSERT_TRUE( file.open( QIODevice::WriteOnly | QIODevice::Text ) );
QTextStream out( &file );
out << "WELLNAME A1\n";
out << "10 JAN 2025 perforation 1500 2000\n";
out << "10 JAN 2025 perforation 1500 2000 0.2 0.0\n";
out << "START perforation 1500 2000\n";
out << "START perforation 1500 2000 0.2 0.0\n";
}
auto intervals = RifPerforationIntervalReader::readPerforationIntervals( fileName );
ASSERT_EQ( size_t( 2 ), intervals["A1"].size() );
EXPECT_FALSE( intervals["A1"][0].startOfHistory );
EXPECT_TRUE( intervals["A1"][1].startOfHistory );
}