testtokenize: Added test case for simplifying '((x))' to '(x)'

This commit is contained in:
Daniel Marjamäki 2009-01-25 19:39:05 +00:00
parent bada255c80
commit 4bb43e7e4d
1 changed files with 25 additions and 0 deletions

View File

@ -74,6 +74,8 @@ private:
TEST_CASE(doublesharp);
// TODO TEST_CASE(simplify_function_parameters);
// TODO TEST_CASE(reduce_redundant_paranthesis); // Ticket #61
}
@ -772,6 +774,29 @@ private:
ASSERT_EQUALS(std::string(" void foo ( ) { if ( x ) int x ; { } }"), ostr.str());
}
}
// Simplify "((..))" into "(..)"
void reduce_redundant_paranthesis()
{
const char code[] = "void foo()\n"
"{\n"
" free(((void*)p));\n"
"}";
// tokenize..
Tokenizer tokenizer;
std::istringstream istr(code);
tokenizer.tokenize(istr, "test.cpp");
tokenizer.simplifyTokenList();
std::ostringstream ostr;
for (const Token *tok = tokenizer.tokens(); tok; tok = tok->next())
ostr << " " << tok->str();
ASSERT_EQUALS(std::string(" void foo ( ) { free ( p ) ; }"), ostr.str());
}
};
REGISTER_TEST(TestTokenizer)