Add TODO test case for #1452 (Simplify goto better)
http://sourceforge.net/apps/trac/cppcheck/ticket/1452
This commit is contained in:
parent
7d8adfb4df
commit
01c5bdfc68
|
@ -2151,6 +2151,69 @@ private:
|
|||
const char code[] = "void foo ( ) { int var ; var = x < y ? y : z ; } ;";
|
||||
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));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -120,7 +120,7 @@ int main()
|
|||
if (fname.find(".cpp") == std::string::npos)
|
||||
continue; // shouldn't happen
|
||||
fname.erase(fname.find(".cpp"));
|
||||
fout1 << std::string(11,' ') << "$$PWD/" << fname << ".h";
|
||||
fout1 << std::string(11, ' ') << "$$PWD/" << fname << ".h";
|
||||
if (i < libfiles.size() - 1)
|
||||
fout1 << " \\\n";
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue