Test case TestTokenizer::simplify_constants added (commented out)

This commit is contained in:
Reijo Tomperi 2009-02-11 22:15:22 +00:00
parent f4a3119c18
commit de2ee0a29d
1 changed files with 27 additions and 0 deletions

View File

@ -110,6 +110,7 @@ private:
TEST_CASE(simplify_numeric_condition);
TEST_CASE(tokenize_double);
TEST_CASE(tokenize_strings);
// TODO TEST_CASE(simplify_constants);
}
@ -1036,6 +1037,32 @@ private:
ostr << " " << tok->str();
ASSERT_EQUALS(std::string(" void f ( ) { const char * a = { \"hello more world\" } ; }"), ostr.str());
}
void simplify_constants()
{
const char code[] =
"void f()\n"
"{\n"
"const int a = 45;\n"
"}\n"
"void g()\n"
"{\n"
"int a = 2;\n"
"}\n";
// tokenize..
Tokenizer tokenizer;
std::istringstream istr(code);
tokenizer.tokenize(istr, "test.cpp");
tokenizer.setVarId();
tokenizer.simplifyTokenList();
std::ostringstream ostr;
for (const Token *tok = tokenizer.tokens(); tok; tok = tok->next())
ostr << " " << tok->str();
ASSERT_EQUALS(std::string(" void f ( ) { const int a = 45 ; } void g ( ) { int a ; a = 2 ; }"), ostr.str());
}
};
REGISTER_TEST(TestTokenizer)