Skip to content

Commit

Permalink
test methods at end of input
Browse files Browse the repository at this point in the history
  • Loading branch information
sloretz committed Apr 9, 2018
1 parent 591c35f commit a4ffdc2
Showing 1 changed file with 31 additions and 0 deletions.
31 changes: 31 additions & 0 deletions rcl/test/rcl/test_lexer_lookahead.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -108,6 +108,37 @@ TEST_F(CLASSNAME(TestLexerLookaheadFixture, RMW_IMPLEMENTATION), test_peek2)
EXPECT_EQ(RCL_LEXEME_FORWARD_SLASH, lexeme2);
}

TEST_F(CLASSNAME(TestLexerLookaheadFixture, RMW_IMPLEMENTATION), test_eof)
{
rcl_ret_t ret;
rcl_lexer_lookahead2_t buffer;
SCOPE_LOOKAHEAD2(buffer, "");

{
rcl_lexeme_t lexeme = RCL_LEXEME_NONE;
ret = rcl_lexer_lookahead2_peek(&buffer, &lexeme);
EXPECT_EQ(RCL_RET_OK, ret);
EXPECT_EQ(RCL_LEXEME_EOF, lexeme);
}
{
rcl_lexeme_t lexeme1 = RCL_LEXEME_NONE;
rcl_lexeme_t lexeme2 = RCL_LEXEME_NONE;
ret = rcl_lexer_lookahead2_peek2(&buffer, &lexeme1, &lexeme2);
EXPECT_EQ(RCL_RET_OK, ret) << rcl_get_error_string_safe();
EXPECT_EQ(RCL_LEXEME_EOF, lexeme1);
EXPECT_EQ(RCL_LEXEME_EOF, lexeme2);
}
// Accepting keeps the lexer at EOF
{
EXPECT_EQ(RCL_RET_OK, rcl_lexer_lookahead2_accept(&buffer, NULL, NULL));
rcl_lexeme_t lexeme = RCL_LEXEME_NONE;
ret = rcl_lexer_lookahead2_peek(&buffer, &lexeme);
EXPECT_EQ(RCL_RET_OK, ret);
EXPECT_EQ(RCL_LEXEME_EOF, lexeme);
}
}


TEST_F(CLASSNAME(TestLexerLookaheadFixture, RMW_IMPLEMENTATION), test_accept)
{
rcl_ret_t ret;
Expand Down

0 comments on commit a4ffdc2

Please sign in to comment.