mirror of
https://github.com/OPM/ResInsight.git
synced 2025-02-25 18:55:39 -06:00
Merge pull request #5302 from OPM/well-measurements-file-format-changes-5216
Well measurements file format changes 5216
This commit is contained in:
@@ -98,8 +98,8 @@ RifWellMeasurement
|
||||
wellMeasurement.wellName = tokens[0];
|
||||
wellMeasurement.MD = parseDouble( tokens[1], "Measured Depth", lineNumber, filePath );
|
||||
wellMeasurement.date = parseDate( tokens[2], "Date", lineNumber, filePath );
|
||||
wellMeasurement.value = parseDouble( tokens[3], "Value", lineNumber, filePath );
|
||||
wellMeasurement.kind = tokens[4];
|
||||
wellMeasurement.kind = tokens[3].toUpper();
|
||||
wellMeasurement.value = parseDouble( tokens[4], "Value", lineNumber, filePath );
|
||||
wellMeasurement.quality = parseInt( tokens[5], "Quality", lineNumber, filePath );
|
||||
wellMeasurement.remark = tokens[6];
|
||||
wellMeasurement.filePath = filePath;
|
||||
@@ -185,7 +185,7 @@ bool RifWellMeasurementReader::isEmptyLine( const QString& line )
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
bool RifWellMeasurementReader::isCommentLine( const QString& line )
|
||||
{
|
||||
return line.startsWith( "#" );
|
||||
return line.trimmed().startsWith( "#" );
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
|
||||
@@ -37,8 +37,8 @@ TEST( RifWellMeasurementReaderTest, ReadCorrectInputFile )
|
||||
|
||||
{
|
||||
QTextStream out( &file );
|
||||
out << "NO 1234/5-6, 1234.56, 2019-11-13, 99.9, XLOT, 3, Good test\n"
|
||||
<< "NO 4321/7-8, 4321.79, 2024-12-24, 88.8, DP, 1, Poor test\n";
|
||||
out << "NO 1234/5-6, 1234.56, 2019-11-13, XLOT, 99.9, 3, Good test\n"
|
||||
<< "NO 4321/7-8, 4321.79, 2024-12-24, DP, 88.8, 1, Poor test\n";
|
||||
}
|
||||
|
||||
QStringList filePaths;
|
||||
@@ -78,6 +78,35 @@ TEST( RifWellMeasurementReaderTest, ReadCorrectInputFile )
|
||||
ASSERT_EQ( "Poor test", wellMeasurements[1].remark.toStdString() );
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
TEST( RifWellMeasurementReaderTest, KindsAreUppercased )
|
||||
{
|
||||
QTemporaryFile file;
|
||||
EXPECT_TRUE( file.open() );
|
||||
|
||||
{
|
||||
QTextStream out( &file );
|
||||
out << "NO 1234/1-2, 1234.56, 2019-11-13, LOT, 99.9, 3, Good test\n"
|
||||
<< "NO 1234/3-4, 2345.67, 2024-12-24, lot, 88.8, 1, Poor test\n"
|
||||
<< "NO 1234/5-6, 3456.78, 2026-12-24, lOt, 77.7, 2, Poor test\n";
|
||||
}
|
||||
|
||||
QStringList filePaths;
|
||||
filePaths.append( file.fileName() );
|
||||
|
||||
std::vector<RifWellMeasurement> wellMeasurements;
|
||||
RifWellMeasurementReader::readWellMeasurements( wellMeasurements, filePaths );
|
||||
|
||||
ASSERT_EQ( 3u, wellMeasurements.size() );
|
||||
|
||||
for ( unsigned int i = 0; i < wellMeasurements.size(); i++ )
|
||||
{
|
||||
ASSERT_EQ( "LOT", wellMeasurements[i].kind.toStdString() );
|
||||
}
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
/// Helper to check exception messages when reading invalid files
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
@@ -140,8 +169,8 @@ TEST( RifWellMeasurementReaderTest, ReadEmptyWellNameThrows )
|
||||
|
||||
{
|
||||
QTextStream out( &file );
|
||||
out << "NO 1234/5-6, 1234.56, 2019-11-13, 99.9, XLOT, 3, Good test\n";
|
||||
out << ", 1234.56, 2019-11-13, 99.9, XLOT, 3, Good test\n";
|
||||
out << "NO 1234/5-6, 1234.56, 2019-11-13, XLOT, 99.9, 3, Good test\n";
|
||||
out << ", 1234.56, 2019-11-13, XLOT, 99.9, 3, Good test\n";
|
||||
}
|
||||
|
||||
QStringList filePaths;
|
||||
@@ -161,8 +190,8 @@ TEST( RifWellMeasurementReaderTest, ReadInvalidMeasureDepthThrows )
|
||||
|
||||
{
|
||||
QTextStream out( &file );
|
||||
out << "well 1, 1234.56, 2019-11-13, 99.9, XLOT, 3, Good test\n";
|
||||
out << "well 2, this is should be a number, 2019-11-13, 99.9, XLOT, 3, Good test\n";
|
||||
out << "well 1, 1234.56, 2019-11-13, XLOT, 99.9, 3, Good test\n";
|
||||
out << "well 2, this is should be a number, 2019-11-13, XLOT, 99.9, 3, Good test\n";
|
||||
}
|
||||
|
||||
QStringList filePaths;
|
||||
@@ -182,8 +211,8 @@ TEST( RifWellMeasurementReaderTest, ReadInvalidQualityThrows )
|
||||
|
||||
{
|
||||
QTextStream out( &file );
|
||||
out << "well 1, 1234.56, 2019-11-13, 99.9, XLOT, this is not an int, Good test\n";
|
||||
out << "well 2, 1234.56, 2019-11-13, 99.9, XLOT, 3, Good test\n";
|
||||
out << "well 1, 1234.56, 2019-11-13, XLOT, 99.9, this is not an int, Good test\n";
|
||||
out << "well 2, 1234.56, 2019-11-13, XLOT, 99.9, 3, Good test\n";
|
||||
}
|
||||
|
||||
QStringList filePaths;
|
||||
@@ -203,8 +232,8 @@ TEST( RifWellMeasurementReaderTest, ReadInvalidDateFormateThrows )
|
||||
|
||||
{
|
||||
QTextStream out( &file );
|
||||
out << "well 1, 1234.56, 17th May 1814, 99.9, XLOT, 1, Good test\n";
|
||||
out << "well 2, 1234.56, 2019-11-13, 99.9, XLOT, 3, Good test\n";
|
||||
out << "well 1, 1234.56, 17th May 1814, XLOT, 99.9, 1, Good test\n";
|
||||
out << "well 2, 1234.56, 2019-11-13, XLOT, 99.9, 3, Good test\n";
|
||||
}
|
||||
|
||||
QStringList filePaths;
|
||||
@@ -227,19 +256,20 @@ TEST( RifWellMeasurementReaderTest, CommentsAndEmptyLinesAreIgnored )
|
||||
// Comment should be ignored
|
||||
out << "# This is a comment.\n";
|
||||
out << "#This is also a comment.\n";
|
||||
out << " # This is also a comment which does not start on first character.\n";
|
||||
// Should skip empty lines
|
||||
out << "\n";
|
||||
out << "\t\n";
|
||||
out << " \n";
|
||||
// Then some data
|
||||
out << "well 1, 1234.56, 2019-11-11, 199.9, XLOT, 1, Good test\n";
|
||||
out << "well 1, 1234.56, 2019-11-11, XLOT, 199.9, 1, Good test\n";
|
||||
// Comment in-between data should be ignored
|
||||
out << "# One more comment in-between the data\n";
|
||||
out << "well 2, 2234.56, 2019-11-12, 299.9, XLOT, 2, Good test\n";
|
||||
out << "well 2, 2234.56, 2019-11-12, XLOT, 299.9, 2, Good test\n";
|
||||
// Empty line in-between data should be ignored
|
||||
out << "\n";
|
||||
// Data with comment sign inside it is not ignored
|
||||
out << "well #3, 3234.56, 2019-11-13, 399.9, XLOT, 3, Good test\n";
|
||||
out << "well #3, 3234.56, 2019-11-13, XLOT, 399.9, 3, Good test\n";
|
||||
// Trailing empty lines should be ignored
|
||||
out << "\n\n\n";
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user