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 ; } ;";
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));
}
}