Test case TestTokenizer::simplify_constants added (commented out)
This commit is contained in:
parent
f4a3119c18
commit
de2ee0a29d
|
@ -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)
|
||||
|
|
Loading…
Reference in New Issue