Remove unused test functions

[ci skip]
This commit is contained in:
Daniel Marjamäki 2019-01-12 18:32:18 +01:00
parent 784131ab98
commit 5276fd68b2
1 changed files with 0 additions and 174 deletions

View File

@ -92,9 +92,6 @@ private:
TEST_CASE(valueFlowSwitchVariable);
TEST_CASE(valueFlowForLoop);
// TODO value flow in sub function
//TEST_CASE(valueFlowSubFunction);
//TEST_CASE(valueFlowSubFunctionLibrary);
TEST_CASE(valueFlowFunctionReturn);
TEST_CASE(valueFlowFunctionDefaultParameter);
@ -2740,177 +2737,6 @@ private:
ASSERT_EQUALS(true, testValueOfX(code, 5U, 3));
}
void valueFlowSubFunction() {
const char *code;
code = "void f1(int x) { return x; }\n"
"void f2(int x) {\n"
" f1(123);\n"
"}";
ASSERT_EQUALS(true, testValueOfX(code, 1U, 123));
code = "void f1(int x) { return x; }\n"
"void f2(int x) {\n"
" f1(x);\n"
" if (x==0){}\n"
"}";
ASSERT_EQUALS(true, testValueOfX(code, 1U, 0));
code = "void f1(int x) {\n"
" if (x == 0) return;\n"
" int y = 1234 / x;\n"
"}\n"
"\n"
"void f2() {\n"
" f1(0);\n"
"}";
ASSERT_EQUALS(false, testValueOfX(code, 3U, 0));
code = "void f1(int x) {\n"
" if (x == 0) return;\n"
" int y = x;\n"
"}\n"
"\n"
"void f2() {\n"
" f1(x&4);\n" // possible {0,4}
"}";
ASSERT_EQUALS(false, testValueOfX(code, 3U, 0));
ASSERT_EQUALS(true, testValueOfX(code, 3U, 4));
code = "int f(int i) {\n"
" if(i >= 2)\n"
" return 0;\n"
" else if(i == 0)\n"
" return 0;\n"
" int a = i;\n"
"}\n"
"void g(int i) {\n"
" return f(0);\n"
"}";
ASSERT_EQUALS(false, testValueOfX(code, 6U, 0));
code = "void f1(int x) { a=x; }\n"
"void f2(int y) { f1(y<123); }\n";
ASSERT_EQUALS(true, testValueOfX(code, 1U, 0));
ASSERT_EQUALS(true, testValueOfX(code, 1U, 1));
code = "void f1(int x) { a=(abc)x; }\n"
"void f2(int y) { f1(123); }\n";
ASSERT_EQUALS(true, testValueOfX(code, 1U, 123));
code = "void f1(int x) {\n"
" x ?\n"
" 1024 / x :\n"
" 0; }\n"
"void f2() { f1(0); }";
ASSERT_EQUALS(true, testValueOfX(code, 2U, 0));
ASSERT_EQUALS(false, testValueOfX(code, 3U, 0));
code = "void f1(int *x) {\n"
" if (x &&\n"
" *x) {}\n"
"}\n"
"void f2() { f1(0); }";
ASSERT_EQUALS(true, testValueOfX(code, 2U, 0));
ASSERT_EQUALS(false, testValueOfX(code, 3U, 0));
// #5861 - fp with float
code = "void f1(float x) {\n"
" return 1.0 / x;\n"
"}\n"
"void f2() { f1(0.5); }";
ASSERT_EQUALS(false, testValueOfX(code, 2U, 0));
code = "void dostuff(int x) {\n"
" return x/x;\n"
"}\n"
"\n"
"void test(int x) {\n"
" if(x==1) {}\n"
" dostuff(x+1);\n"
"}\n";
ASSERT_EQUALS(true, testValueOfX(code, 2U, 2));
code = "void leaveNotifyEvent(const XCrossingEvent * const) { }\n"
"void motionNotifyEvent() {\n"
" leaveNotifyEvent(0);\n"
"}";
testValueOfX(code, 2U, 2); // No complaint about Token::Match called with varid 0. (#6443)
// #6560 - multivariables
code = "void f1(int x) {\n"
" int a = x && y;\n"
" int b = a ? x : 0;\n"
"}\n"
"void f2() {\n"
" f1(0);\n"
"}";
ASSERT_EQUALS(false, testValueOfX(code, 3U, 0));
code = "class A\n"
"{\n"
" void f1(int x) { return x; }\n"
" void f2(int x) {\n"
" f1(123);\n"
" }\n"
"};";
ASSERT_EQUALS(true, testValueOfX(code, 3U, 123));
code = "class A\n"
"{\n"
" virtual void f1(int x) { return x; }\n"
" void f2(int x) {\n"
" f1(123);\n"
" }\n"
"};";
ASSERT_EQUALS(true, testValueOfX(code, 3U, 123));
code = "void foo(int x, int y) {\n"
" if (y == 1) {\n"
" a = x;\n" // <- x is not 1
" }\n"
"}\n"
"\n"
"void bar() {\n"
" foo(1, 10);\n"
"}";
ASSERT_EQUALS(false, testValueOfX(code, 3U, 1));
}
void valueFlowSubFunctionLibrary() {
const char *code;
const char xmldata[] = "<?xml version=\"1.0\"?>\n"
"<def>\n"
" <function name=\"add\">\n"
" <returnValue>arg1+arg2</returnValue>\n"
" <arg nr=\"1\"/>\n"
" <arg nr=\"2\"/>\n"
" </function>\n"
"</def>";
settings.library.loadxmldata(xmldata, sizeof(xmldata));
code = "void f() {\n"
" int x = add(100, 23);\n"
" return x;\n"
"}";
ASSERT_EQUALS(true, testValueOfX(code, 3U, 123));
code = "void f() {\n"
" int a;\n"
" if (cond)\n"
" a = 1;\n"
" else\n"
" a = 2;\n"
" add(a, a);\n"
"}";
std::list<ValueFlow::Value> values = tokenValues(code, "( a , a )");
ASSERT_EQUALS(2, values.size());
ASSERT_EQUALS(2, values.front().intvalue);
ASSERT_EQUALS(4, values.back().intvalue);
}
void valueFlowFunctionReturn() {
const char *code;