Add TODO test case for #1452 (Simplify goto better)

http://sourceforge.net/apps/trac/cppcheck/ticket/1452
This commit is contained in:
Reijo Tomperi 2010-02-24 22:55:16 +02:00
parent 7d8adfb4df
commit 01c5bdfc68
2 changed files with 64 additions and 1 deletions

View File

@ -2151,6 +2151,69 @@ private:
const char code[] = "void foo ( ) { int var ; var = x < y ? y : z ; } ;"; const char code[] = "void foo ( ) { int var ; var = x < y ? y : z ; } ;";
ASSERT_EQUALS(code, tok(code)); ASSERT_EQUALS(code, tok(code));
} }
{
const char code[] = "void foo(int x)\n"
"{\n"
" goto A;\n"
"A:\n"
" fooA();\n"
" goto B;\n"
" fooNever();\n"
"B:\n"
" fooB();\n"
" return 3;\n"
"}";
const char expect[] = "void foo ( int x ) "
"{ "
"fooA ( ) ; "
"fooB ( ) ; "
"return 3; "
"fooA ( ) ; "
"fooB ( ) ; "
"return 3 ; "
"fooNever ( ) ; "
"fooB ( ) ; "
"return 3 ; "
"}";
TODO_ASSERT_EQUALS(expect, tok(code));
}
{
const char code[] = "void foo(int x)\n"
"{\n"
" goto A;\n"
"A:\n"
" fooA();\n"
" if( x ) { goto B; }\n"
" fooNever();\n"
"B:\n"
" fooB();\n"
" return 3;\n"
"}";
const char expect[] = "void foo ( int x ) "
"{ "
"fooA ( ) ; "
"if ( x ) { "
"fooB ( ) ; "
"return 3 ; } "
"fooNever ( ) ; "
"fooB ( ) ; "
"return 3 ; "
"fooA ( ) ; "
"if ( x ) { "
"fooB ( ) ; "
"return 3 ; } "
"fooNever ( ) ; "
"fooB ( ) ; "
"return 3 ; "
"}";
ASSERT_EQUALS(expect, tok(code));
}
} }

View File

@ -120,7 +120,7 @@ int main()
if (fname.find(".cpp") == std::string::npos) if (fname.find(".cpp") == std::string::npos)
continue; // shouldn't happen continue; // shouldn't happen
fname.erase(fname.find(".cpp")); fname.erase(fname.find(".cpp"));
fout1 << std::string(11,' ') << "$$PWD/" << fname << ".h"; fout1 << std::string(11, ' ') << "$$PWD/" << fname << ".h";
if (i < libfiles.size() - 1) if (i < libfiles.size() - 1)
fout1 << " \\\n"; fout1 << " \\\n";
} }