}
// Common checks regarding expected/unexpected end-of-line
+//
+// The 'lexer' should be at a position before two consecutive '\n's.
+// The first one will be recognized, and the second one will be considered an
+// unexpected token. Then this helper consumes the second '\n', so the caller
+// can continue the test after these '\n's.
void
eolCheck(MasterLexer& lexer, MasterToken::Type expect) {
// If EOL is found and eol_ok is true, we get it.
// And also check the error token set in the exception object.
lexerErrorCheck(lexer, expect, MasterToken::UNEXPECTED_END);
+
+ // Then skip the 2nd '\n'
+ EXPECT_EQ(MasterToken::END_OF_LINE, lexer.getNextToken().getType());
}
// Common checks regarding expected/unexpected end-of-file
+//
+// The 'lexer' should be at a position just before an end-of-file.
void
eofCheck(MasterLexer& lexer, MasterToken::Type expect) {
EXPECT_EQ(MasterToken::END_OF_FILE,
lexer.getNextToken(MasterToken::STRING).getString());
eolCheck(lexer, MasterToken::STRING);
- // Skip the 2nd '\n'
- EXPECT_EQ(MasterToken::END_OF_LINE, lexer.getNextToken().getType());
-
// Same set of tests but for end-of-file
EXPECT_EQ("another-string",
lexer.getNextToken(MasterToken::STRING, true).getString());
lexer.getNextToken(MasterToken::QSTRING).getString());
eolCheck(lexer, MasterToken::QSTRING);
- // Skip the 2nd '\n'
- EXPECT_EQ(MasterToken::END_OF_LINE, lexer.getNextToken().getType());
-
// Expecting a quoted string but see a normal string. It's okay.
EXPECT_EQ("normal-string",
lexer.getNextToken(MasterToken::QSTRING).getString());
lexer.getNextToken(MasterToken::NUMBER).getNumber());
eolCheck(lexer, MasterToken::NUMBER);
- // Skip the 2nd '\n'
- EXPECT_EQ(MasterToken::END_OF_LINE, lexer.getNextToken().getType());
-
// Expecting a number, but it's too big for uint32.
lexerErrorCheck(lexer, MasterToken::NUMBER,
MasterToken::NUMBER_OUT_OF_RANGE);