testclass: added todo testcase for #74

This commit is contained in:
Daniel Marjamäki 2009-02-04 19:31:25 +00:00
parent aeb573d529
commit 8187504cbb
2 changed files with 47 additions and 3 deletions

View File

@ -46,6 +46,7 @@ private:
TEST_CASE(uninitVar1);
TEST_CASE(uninitVarStream);
TEST_CASE(privateCtor); // If constructor is private..
// TODO TEST_CASE(function); // Function is not variable
}
// Check that base classes have virtual destructors
@ -189,10 +190,29 @@ private:
"};\n");
ASSERT_EQUALS(std::string(""), errout.str());
}
void function()
{
checkUninitVar("class A\n"
"{\n"
"public:\n"
" A();\n"
" int* f(int*);\n"
"};\n"
"\n"
"A::A()\n"
"{\n"
"}\n"
"\n"
"int* A::f(int* p)\n"
"{\n"
" return p;\n"
"}\n");
ASSERT_EQUALS(std::string(""), errout.str());
}
};

View File

@ -76,7 +76,8 @@ private:
TEST_CASE(simplify_function_parameters);
TEST_CASE(reduce_redundant_paranthesis); // Ticket #61
TEST_CASE(reduce_redundant_paranthesis1); // Ticket #61
TEST_CASE(reduce_redundant_paranthesis2); // Ticket #61
TEST_CASE(sizeof1);
TEST_CASE(sizeof2);
@ -809,7 +810,7 @@ private:
// Simplify "((..))" into "(..)"
void reduce_redundant_paranthesis()
void reduce_redundant_paranthesis1()
{
const char code[] = "void foo()\n"
"{\n"
@ -829,6 +830,29 @@ private:
ASSERT_EQUALS(std::string(" void foo ( ) { free ( p ) ; }"), ostr.str());
}
// Simplify "((..))" into "(..)"
void reduce_redundant_paranthesis2()
{
const char code[] = "class A\n"
"{\n"
"public:\n"
" A();\n"
" int *p(int *);\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(" class A { public: A ( ) ; int * p ( int * ) ; }"), ostr.str());
}
void sizeof1()