Add ParseContext::PARSE_LONG_KEYWORD

The ParserContext error mode PARSE_LONG_KEYWORD is used to handle keywords
longer than 8 characters. The lenient option is to only consider the first 8
characters.
This commit is contained in:
Joakim Hove
2019-02-04 15:59:09 +01:00
parent e9756c3ee5
commit 65b629e423
6 changed files with 84 additions and 48 deletions

View File

@@ -769,3 +769,23 @@ BOOST_AUTO_TEST_CASE(Test_ERRORGUARD) {
eg.clear();
BOOST_CHECK(!eg);
}
BOOST_AUTO_TEST_CASE(LONG_KEYWORDS) {
const std::string deck_string = R"(
RPTRUNSPEC
)";
Parser parser;
ParseContext context;
ErrorGuard error;
context.update(ParseContext::PARSE_LONG_KEYWORD, InputError::IGNORE);
auto deck = parser.parseString(deck_string, context, error);
BOOST_CHECK( deck.hasKeyword("RPTRUNSP") );
context.update(ParseContext::PARSE_LONG_KEYWORD, InputError::THROW_EXCEPTION);
BOOST_CHECK_THROW( parser.parseString(deck_string, context, error), std::invalid_argument);
}