Moved some more tests to testgarbage.cpp

This commit is contained in:
PKEuS 2015-01-21 10:04:24 +01:00
parent f82dcc0523
commit 3274a00b82
5 changed files with 38 additions and 39 deletions

View File

@ -296,7 +296,6 @@ private:
TEST_CASE(executionPaths1); TEST_CASE(executionPaths1);
TEST_CASE(executionPaths2); TEST_CASE(executionPaths2);
TEST_CASE(executionPaths3); // no FP for function parameter TEST_CASE(executionPaths3); // no FP for function parameter
TEST_CASE(executionPaths4); // Ticket #2386 - Segmentation fault in the ExecutionPath handling
TEST_CASE(executionPaths5); // Ticket #2920 - False positive when size is unknown TEST_CASE(executionPaths5); // Ticket #2920 - False positive when size is unknown
TEST_CASE(executionPaths6); // unknown types TEST_CASE(executionPaths6); // unknown types
@ -3899,15 +3898,6 @@ private:
ASSERT_EQUALS("", errout.str()); ASSERT_EQUALS("", errout.str());
} }
void executionPaths4() {
// Ticket #2386 - Segmentation fault upon strange syntax
ASSERT_THROW(epcheck("void f() {\n"
" switch ( x ) {\n"
" case struct Tree : break;\n"
" }\n"
"}"), InternalError);
}
void executionPaths5() { void executionPaths5() {
// No false positive // No false positive
epcheck("class A {\n" epcheck("class A {\n"

View File

@ -178,7 +178,6 @@ private:
TEST_CASE(uninitVarPointer); // ticket #3801 TEST_CASE(uninitVarPointer); // ticket #3801
TEST_CASE(uninitConstVar); TEST_CASE(uninitConstVar);
TEST_CASE(constructors_crash1); // ticket #5641 TEST_CASE(constructors_crash1); // ticket #5641
TEST_CASE(invalidInitializerList); // ticket #5702
} }
@ -3139,14 +3138,6 @@ private:
"};\n"); "};\n");
ASSERT_EQUALS("", errout.str()); ASSERT_EQUALS("", errout.str());
} }
void invalidInitializerList() {
// 5702
ASSERT_THROW(check("struct R1 {\n"
" int a;\n"
" R1 () : a { }\n"
"};\n"), InternalError);
}
}; };
REGISTER_TEST(TestConstructors) REGISTER_TEST(TestConstructors)

View File

@ -65,6 +65,10 @@ private:
TEST_CASE(garbageCode22); TEST_CASE(garbageCode22);
TEST_CASE(garbageCode23); TEST_CASE(garbageCode23);
TEST_CASE(garbageCode24); // Ticket #6361 - crash TEST_CASE(garbageCode24); // Ticket #6361 - crash
TEST_CASE(garbageCode25);
TEST_CASE(garbageCode26);
TEST_CASE(garbageCode27);
TEST_CASE(garbageCode28);
TEST_CASE(garbageValueFlow); TEST_CASE(garbageValueFlow);
TEST_CASE(garbageSymbolDatabase); TEST_CASE(garbageSymbolDatabase);
@ -341,6 +345,40 @@ private:
"}\n"); "}\n");
} }
void garbageCode25() {
// Ticket #2386 - Segmentation fault upon strange syntax
ASSERT_THROW(checkCode("void f() {\n"
" switch ( x ) {\n"
" case struct Tree : break;\n"
" }\n"
"}"), InternalError);
}
void garbageCode26() {
// See tickets #2518 #2555 #4171
ASSERT_THROW(checkCode("void f() {\n"
" switch MAKEWORD(1)\n"
" {\n"
" case 0:\n"
" return;\n"
" }\n"
"}"), InternalError);
}
void garbageCode27() {
ASSERT_THROW(checkCode("int f() {\n"
" return if\n"
"}"), InternalError);
}
void garbageCode28() {
// 5702
ASSERT_THROW(checkCode("struct R1 {\n"
" int a;\n"
" R1 () : a { }\n"
"};\n"), InternalError);
}
void garbageValueFlow() { void garbageValueFlow() {
// #6089 // #6089
const char* code = "{} int foo(struct, x1, struct x2, x3, int, x5, x6, x7)\n" const char* code = "{} int foo(struct, x1, struct x2, x3, int, x5, x6, x7)\n"

View File

@ -198,7 +198,6 @@ private:
TEST_CASE(switch2); TEST_CASE(switch2);
TEST_CASE(switch3); TEST_CASE(switch3);
TEST_CASE(switch4); // #2555 - segfault
TEST_CASE(ret5); // Bug 2458436 - return use TEST_CASE(ret5); // Bug 2458436 - return use
TEST_CASE(ret6); TEST_CASE(ret6);
@ -1417,17 +1416,6 @@ private:
ASSERT_EQUALS("[test.cpp:9]: (error) Memory leak: str\n", errout.str()); ASSERT_EQUALS("[test.cpp:9]: (error) Memory leak: str\n", errout.str());
} }
void switch4() {
// See tickets #2518 #2555 #4171
ASSERT_THROW(check("void f() {\n"
" switch MAKEWORD(1)\n"
" {\n"
" case 0:\n"
" return;\n"
" }\n"
"}"), InternalError);
}
void ret5() { void ret5() {
check("static char * f()\n" check("static char * f()\n"
"{\n" "{\n"

View File

@ -80,7 +80,6 @@ private:
TEST_CASE(nullpointerStdStream); TEST_CASE(nullpointerStdStream);
TEST_CASE(functioncall); TEST_CASE(functioncall);
TEST_CASE(functioncalllibrary); // use Library to parse function call TEST_CASE(functioncalllibrary); // use Library to parse function call
TEST_CASE(crash1);
TEST_CASE(functioncallDefaultArguments); TEST_CASE(functioncallDefaultArguments);
TEST_CASE(nullpointer_internal_error); // #5080 TEST_CASE(nullpointer_internal_error); // #5080
TEST_CASE(nullpointerFputc); // #5645 FP: Null pointer dereference in fputc argument TEST_CASE(nullpointerFputc); // #5645 FP: Null pointer dereference in fputc argument
@ -2504,13 +2503,6 @@ private:
TODO_ASSERT_EQUALS("[test.cpp:2]: (warning) Possible null pointer dereference if the default parameter value is used: p\n", "", errout.str()); TODO_ASSERT_EQUALS("[test.cpp:2]: (warning) Possible null pointer dereference if the default parameter value is used: p\n", "", errout.str());
} }
void crash1() {
ASSERT_THROW(check("int f() {\n"
" return if\n"
"}"), InternalError);
}
void nullpointer_internal_error() { // ticket #5080 void nullpointer_internal_error() { // ticket #5080
check("struct A { unsigned int size; };\n" check("struct A { unsigned int size; };\n"
"struct B { struct A *a; };\n" "struct B { struct A *a; };\n"