Added test case simplify_function_parameters

This commit is contained in:
Reijo Tomperi 2009-01-24 07:56:47 +00:00
parent 9d29de02d3
commit 67f30376e1
1 changed files with 41 additions and 0 deletions

View File

@ -72,6 +72,8 @@ private:
TEST_CASE(file2); TEST_CASE(file2);
TEST_CASE(doublesharp); TEST_CASE(doublesharp);
// TODO TEST_CASE(simplify_function_parameters);
} }
@ -709,6 +711,45 @@ private:
ASSERT_EQUALS("TEST ( var , val ) var ## _ ## val = val ", ostr.str()); ASSERT_EQUALS("TEST ( var , val ) var ## _ ## val = val ", ostr.str());
} }
void simplify_function_parameters()
{
{
const char code[] = "void f(x) int x;\n"
"{\n"
"}\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 f ( int x ) { }"), ostr.str());
}
{
const char code[] = "void f(x,y) int x; char y;\n"
"{\n"
"}\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 f ( int x, char y ) { }"), ostr.str());
}
}
}; };
REGISTER_TEST(TestTokenizer) REGISTER_TEST(TestTokenizer)