Handle space in the 'BASIC = ?' RPT mnemonics

This commit is contained in:
Joakim Hove
2018-12-18 08:48:59 +01:00
parent cf61068ad1
commit 161f555bc0
3 changed files with 12 additions and 8 deletions

View File

@@ -316,14 +316,17 @@ inline std::map< std::string, int > RPT( const DeckKeyword& keyword,
std::map< std::string, int > mnemonics;
for( const auto& mnemonic : items ) {
const auto pos = mnemonic.find( '=' );
const auto sep_pos = mnemonic.find_first_of( "= " );
std::string base = mnemonic.substr( 0, pos );
std::string base = mnemonic.substr( 0, sep_pos );
if( !is_mnemonic( base ) ) continue;
const int val = pos != std::string::npos
? std::stoi( mnemonic.substr( pos + 1 ) )
: 1;
int val = 1;
if (sep_pos != std::string::npos) {
const auto value_pos = mnemonic.find_first_not_of("= ", sep_pos);
if (value_pos != std::string::npos)
val = std::stoi(mnemonic.substr(value_pos));
}
mnemonics.emplace( base, val );
}

View File

@@ -167,7 +167,7 @@ BOOST_AUTO_TEST_CASE(DefaultProperties) {
"\n"
"SCHEDULE\n"
"RPTRST\n"
"BASIC=1"
"'BASIC = 1'"
"/\n"
"DATES\n"
" 22 MAY 1981 /\n"
@@ -185,11 +185,12 @@ BOOST_AUTO_TEST_CASE(DefaultProperties) {
" 26 MAY 1984 /\n"
" 26 MAY 1985 /\n"
" 27 MAY 1985 /\n"
" 1 JAN 1986 /\n"
" 1 JAN 1986 /\n"
"/\n";
auto deck = Parser().parseString( data, ParseContext() );
IOConfig ioConfig( deck );
RestartConfig rstConfig( deck );
/*If no GRIDFILE nor NOGGF keywords are specified, default output an EGRID file*/
BOOST_CHECK( ioConfig.getWriteEGRIDFile() );

View File

@@ -16,7 +16,7 @@ SPECGRID
46 112 22 1 F /
SOLUTION
RPTRST
BASIC=2 KRO KRW KRG /
'BASIC = 2' KRO KRW KRG /
RPTSOL
FIP=3 SWAT /
SCHEDULE