#8307 Input Eclipse Case: Handle trailing line comment

This commit is contained in:
Magne Sjaastad 2022-03-24 11:22:27 +01:00
parent be7783776c
commit 7cd917e0d8
2 changed files with 31 additions and 1 deletions

View File

@ -88,7 +88,8 @@ std::pair<std::string, std::vector<float>>
{ {
std::vector<float> values; std::vector<float> values;
const auto commentChar = '-'; const auto commentChar = '-';
const auto commentString = "--";
std::string keywordName; std::string keywordName;
std::string_view line; std::string_view line;
@ -121,6 +122,12 @@ std::pair<std::string, std::vector<float>>
if ( keywordName.empty() ) if ( keywordName.empty() )
{ {
auto found = line.find_first_of( commentString );
if ( found != std::string::npos )
{
line = line.substr( 0, found );
}
trim( line ); trim( line );
if ( !line.empty() ) if ( !line.empty() )
{ {

View File

@ -82,6 +82,29 @@ TEST( RifEclipseTextFileReader, DISABLED_ReadKeywordsAndValuesPerformanceTest )
} }
} }
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
TEST( RifEclipseTextFileReader, ReadKeywordsWithComment )
{
QString faceTexts = "SPECGRID -- Generated : simulator name\n"
"124 134 41 1 F /\n"
"COORDSYS -- Generated : simulator name\n"
" 1 41 INCOMP /\n ";
auto stdString = faceTexts.toStdString();
size_t bytesRead = 0;
auto objects = RifEclipseTextFileReader::readKeywordAndValues( stdString, 0, bytesRead );
{
std::string toMatch( "SPECGRID" );
EXPECT_STREQ( objects.first.data(), toMatch.data() );
auto values = objects.second;
EXPECT_FLOAT_EQ( values[0], 124.0 );
}
}
//-------------------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------------------
/// ///
//-------------------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------------------