Skip to content

Commit 8a60cee

Browse files
committed
Add test for Token::eraseTokens.
1 parent 3cc9a33 commit 8a60cee

1 file changed

Lines changed: 13 additions & 0 deletions

File tree

‎test/testtoken.cpp‎

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,7 @@ class TestToken : public TestFixture {
4949

5050
TEST_CASE(deleteLast);
5151
TEST_CASE(nextArgument);
52+
TEST_CASE(eraseTokens);
5253

5354
TEST_CASE(matchAny);
5455
TEST_CASE(matchSingleChar);
@@ -196,6 +197,18 @@ class TestToken : public TestFixture {
196197
ASSERT_EQUALS(true, Token::simpleMatch(example3.tokens()->tokAt(2)->nextArgument(), "2 , 3"));
197198
}
198199

200+
void eraseTokens() {
201+
givenACodeSampleToTokenize code("begin ; { this code will be removed } end");
202+
Token::eraseTokens(code.tokens()->next(), code.tokens()->tokAt(9));
203+
std::ostringstream ret;
204+
for (const Token *tok = code.tokens(); tok; tok = tok->next()) {
205+
if (tok != code.tokens())
206+
ret << " ";
207+
ret << tok->str();
208+
}
209+
ASSERT_EQUALS("begin ; end", ret.str());
210+
}
211+
199212

200213
void matchAny() {
201214
givenACodeSampleToTokenize varBitOrVar("abc|def");

0 commit comments

Comments
 (0)