Ticket #184 (Tokenizer - Simplification: Split up variable declarations), added testcases

This commit is contained in:
Daniel Marjamäki 2009-03-16 19:03:23 +01:00
parent 0cc7672673
commit f9b481ae3a
1 changed files with 34 additions and 0 deletions

View File

@ -122,6 +122,9 @@ private:
TEST_CASE(simplify_constants2); TEST_CASE(simplify_constants2);
TEST_CASE(findClassFunction1); TEST_CASE(findClassFunction1);
// Ticket 184 TEST_CASE(vardecl1);
// Ticket 184 TEST_CASE(vardecl2);
} }
@ -1313,6 +1316,37 @@ private:
ASSERT_EQUALS(0, (int)tok); ASSERT_EQUALS(0, (int)tok);
} }
void vardecl1()
{
const char code[] = "unsigned int a, b;";
// tokenize..
Tokenizer tokenizer;
std::istringstream istr(code);
tokenizer.tokenize(istr, "test.cpp");
std::ostringstream ostr;
for (const Token *tok = tokenizer.tokens(); tok; tok = tok->next())
ostr << " " << tok->str();
ASSERT_EQUALS(" unsigned int a ; unsigned int b ;", ostr.str());
}
void vardecl2()
{
const char code[] = "void foo(a,b) unsigned int a, b; { }";
// tokenize..
Tokenizer tokenizer;
std::istringstream istr(code);
tokenizer.tokenize(istr, "test.cpp");
std::ostringstream ostr;
for (const Token *tok = tokenizer.tokens(); tok; tok = tok->next())
ostr << " " << tok->str();
ASSERT_EQUALS(" void foo ( a , b ) unsigned int a ; unsigned int b ; { }", ostr.str());
}
}; };
REGISTER_TEST(TestTokenizer) REGISTER_TEST(TestTokenizer)