Merge pull request #637 from joakim-hove/long-keywords

Add ParseContext::PARSE_LONG_KEYWORD
This commit is contained in:
Bård Skaflestad
2019-02-07 14:26:29 +01:00
committed by GitHub
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);
}

View File

@@ -278,7 +278,6 @@ BOOST_AUTO_TEST_CASE(WildCardTest) {
BOOST_CHECK(!parser.isRecognizedKeyword("TVDP*"));
BOOST_CHECK(!parser.isRecognizedKeyword("TVDP"));
BOOST_CHECK(parser.isRecognizedKeyword("TVDPXXX"));
BOOST_CHECK(!parser.isRecognizedKeyword("TVDPIAMTOOLONG"));
BOOST_CHECK(!parser.isRecognizedKeyword("TVD"));
BOOST_CHECK(!parser.isRecognizedKeyword("TVDP"));
@@ -1327,7 +1326,6 @@ BOOST_AUTO_TEST_CASE(ParserKeyword_withOtherSize_SizeTypeOTHER) {
BOOST_AUTO_TEST_CASE(ParserKeyword_validDeckName) {
BOOST_CHECK_EQUAL( true , ParserKeyword::validDeckName("SUMMARY"));
BOOST_CHECK_EQUAL( true , ParserKeyword::validDeckName("MixeCase"));
BOOST_CHECK_EQUAL( false , ParserKeyword::validDeckName("NAMETOOLONG"));
BOOST_CHECK_EQUAL( true , ParserKeyword::validDeckName("STRING88"));
BOOST_CHECK_EQUAL( false , ParserKeyword::validDeckName("88STRING"));
BOOST_CHECK_EQUAL( false , ParserKeyword::validDeckName("KEY.EXT"));
@@ -1368,7 +1366,6 @@ BOOST_AUTO_TEST_CASE(ParserKeywordMatches) {
BOOST_CHECK_EQUAL( false , parserKeyword->matches("WORLD"));
BOOST_CHECK_EQUAL( true , parserKeyword->matches("WORLDABC"));
BOOST_CHECK_EQUAL( false , parserKeyword->matches("WORLD#BC"));
BOOST_CHECK_EQUAL( false , parserKeyword->matches("WORLDIAMTOOLONG"));
}
BOOST_AUTO_TEST_CASE(AddDataKeyword_correctlyConfigured) {