unused private function: Added test1 (assert that error message is given for simple case)

This commit is contained in:
Daniel Marjamäki 2008-11-11 20:02:10 +00:00
parent f347efd802
commit 57c144a342
1 changed files with 14 additions and 7 deletions

View File

@ -43,14 +43,14 @@ private:
{ {
// Tokenize.. // Tokenize..
tokens = tokens_back = NULL; tokens = tokens_back = NULL;
std::istringstream istr(code); std::istringstream istr(code);
Tokenizer tokenizer; Tokenizer tokenizer;
tokenizer.TokenizeCode( istr ); tokenizer.TokenizeCode( istr );
// Clear the error buffer.. // Clear the error buffer..
errout.str(""); errout.str("");
// Check for unused private functions.. // Check for unused private functions..
CheckClass checkClass; CheckClass checkClass;
checkClass.CheckUnusedPrivateFunctions(); checkClass.CheckUnusedPrivateFunctions();
@ -64,11 +64,18 @@ private:
check( "class Fred\n" check( "class Fred\n"
"{\n" "{\n"
"private:\n" "private:\n"
" unsigned int f()\n" " unsigned int f();\n"
" { }\n" "public:\n"
"};\n" ); " Fred();\n"
// Todo: This should be detected. "};\n"
ASSERT_EQUALS( std::string(""), errout.str() ); "\n"
"unsigned int Fred::Fred()\n"
"{ }\n"
"\n"
"unsigned int Fred::f()\n"
"{ }\n" );
ASSERT_EQUALS( std::string("Class 'Fred', unused private function: 'f'\n"), errout.str() );
} }
}; };