TestTokenize: Added testcase sizeof2 (TODO)

This commit is contained in:
Daniel Marjamäki 2009-02-02 06:26:20 +00:00
parent dc994c346e
commit 0e291c772c
1 changed files with 25 additions and 0 deletions

View File

@ -78,6 +78,7 @@ private:
TEST_CASE(reduce_redundant_paranthesis); // Ticket #61
TEST_CASE(sizeof1);
// TODO TEST_CASE(sizeof2);
}
@ -821,6 +822,30 @@ private:
ostr << " " << tok->str();
ASSERT_EQUALS(std::string(" int i [ 4 ] ; 16 ; 4 ;"), ostr.str());
}
void sizeof2()
{
const char code[] = "int i[4];\n"
"void f()\n"
"{\n"
" int i[10];\n"
" sizeof(i);\n"
" sizeof(*i);\n"
" sizeof(i[0]);\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(" int i [ 4 ] ; void f ( ) { int i [ 10 ] ; 40 ; 4 ; 4 ; }"), ostr.str());
}
};
REGISTER_TEST(TestTokenizer)