mirror of
https://github.com/OPM/ResInsight.git
synced 2025-02-25 18:55:39 -06:00
#8307 Input Eclipse Case: Handle trailing line comment
This commit is contained in:
parent
be7783776c
commit
7cd917e0d8
@ -88,7 +88,8 @@ std::pair<std::string, std::vector<float>>
|
||||
{
|
||||
std::vector<float> values;
|
||||
|
||||
const auto commentChar = '-';
|
||||
const auto commentChar = '-';
|
||||
const auto commentString = "--";
|
||||
|
||||
std::string keywordName;
|
||||
std::string_view line;
|
||||
@ -121,6 +122,12 @@ std::pair<std::string, std::vector<float>>
|
||||
|
||||
if ( keywordName.empty() )
|
||||
{
|
||||
auto found = line.find_first_of( commentString );
|
||||
if ( found != std::string::npos )
|
||||
{
|
||||
line = line.substr( 0, found );
|
||||
}
|
||||
|
||||
trim( line );
|
||||
if ( !line.empty() )
|
||||
{
|
||||
|
@ -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 );
|
||||
}
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
|
Loading…
Reference in New Issue
Block a user