Add test for Token::eraseTokens.

This commit is contained in:
Edoardo Prezioso 2011-11-08 18:59:31 +01:00
parent 3cc9a333c9
commit 8a60ceed82
1 changed files with 13 additions and 0 deletions

View File

@ -49,6 +49,7 @@ private:
TEST_CASE(deleteLast);
TEST_CASE(nextArgument);
TEST_CASE(eraseTokens);
TEST_CASE(matchAny);
TEST_CASE(matchSingleChar);
@ -196,6 +197,18 @@ private:
ASSERT_EQUALS(true, Token::simpleMatch(example3.tokens()->tokAt(2)->nextArgument(), "2 , 3"));
}
void eraseTokens() {
givenACodeSampleToTokenize code("begin ; { this code will be removed } end");
Token::eraseTokens(code.tokens()->next(), code.tokens()->tokAt(9));
std::ostringstream ret;
for (const Token *tok = code.tokens(); tok; tok = tok->next()) {
if (tok != code.tokens())
ret << " ";
ret << tok->str();
}
ASSERT_EQUALS("begin ; end", ret.str());
}
void matchAny() {
givenACodeSampleToTokenize varBitOrVar("abc|def");