From 8a60ceed82992237eb5658e5918836fc21efb6ef Mon Sep 17 00:00:00 2001 From: Edoardo Prezioso Date: Tue, 8 Nov 2011 18:59:31 +0100 Subject: [PATCH] Add test for Token::eraseTokens. --- test/testtoken.cpp | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/test/testtoken.cpp b/test/testtoken.cpp index 2adc1b919..0bc6d5d97 100644 --- a/test/testtoken.cpp +++ b/test/testtoken.cpp @@ -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");