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:
@@ -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);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user