testtokenize: sizeof handling

This commit is contained in:
Daniel Marjamäki 2009-02-02 06:21:48 +00:00
parent bbf4641304
commit dc994c346e
1 changed files with 22 additions and 0 deletions

View File

@ -76,6 +76,8 @@ private:
TEST_CASE(simplify_function_parameters);
TEST_CASE(reduce_redundant_paranthesis); // Ticket #61
TEST_CASE(sizeof1);
}
@ -799,6 +801,26 @@ private:
ASSERT_EQUALS(std::string(" void foo ( ) { free ( p ) ; }"), ostr.str());
}
void sizeof1()
{
const char code[] = "int i[4];\n"
"sizeof(i);\n"
"sizeof(*i);\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(" int i [ 4 ] ; 16 ; 4 ;"), ostr.str());
}
};
REGISTER_TEST(TestTokenizer)