Refactorized inefficient usage of std::string and const char[] (part 2).

This commit is contained in:
PKEuS 2014-04-02 17:33:04 +02:00
parent dcc245be9e
commit d4765bccc3
4 changed files with 14 additions and 16 deletions

View File

@ -2476,7 +2476,7 @@ private:
" char *p = a(len);\n"
" delete [] p;\n"
"}");
ASSERT_EQUALS(std::string(""), errout.str());
ASSERT_EQUALS("", errout.str());
check("char *a(char *a)\n"
"{\n"
@ -2491,7 +2491,7 @@ private:
" else\n"
" free(p);\n"
"}");
ASSERT_EQUALS(std::string(""), errout.str());
ASSERT_EQUALS("", errout.str());
check("char *a()\n"
"{\n"
@ -2502,7 +2502,7 @@ private:
" char *p = a();\n"
" free(p);\n"
"}");
ASSERT_EQUALS(std::string(""), errout.str());
ASSERT_EQUALS("", errout.str());
check("gchar *a()\n"
"{\n"
" return g_malloc(10);\n"
@ -2512,7 +2512,7 @@ private:
" gchar *p = a();\n"
" g_free(p);\n"
"}");
ASSERT_EQUALS(std::string(""), errout.str());
ASSERT_EQUALS("", errout.str());
}
void allocfunc3() {
@ -2623,7 +2623,7 @@ private:
" foo(&tmp);\n"
" free(tmp);\n"
"}");
ASSERT_EQUALS(std::string(""), errout.str());
ASSERT_EQUALS("", errout.str());
check("void foo(gchar **str)\n"
"{\n"
" g_free(*str);\n"
@ -2637,7 +2637,7 @@ private:
" foo(&tmp);\n"
" g_free(tmp);\n"
"}");
ASSERT_EQUALS(std::string(""), errout.str());
ASSERT_EQUALS("", errout.str());
//#ticket 1789: getcode other function:
check("void foo(char **str)\n"
@ -2655,7 +2655,7 @@ private:
" foo(&tmp);\n"
" free(tmp);\n"
"}");
ASSERT_EQUALS(std::string(""), errout.str());
ASSERT_EQUALS("", errout.str());
}
@ -2675,7 +2675,7 @@ private:
"\n"
" free(expr);\n"
"}");
ASSERT_EQUALS(std::string(""), errout.str());
ASSERT_EQUALS("", errout.str());
check("static FILE* data()\n"
"{\n"
" return fopen(\"data.txt\",\"rt\");\n"
@ -2691,7 +2691,7 @@ private:
"\n"
" g_free(expr);\n"
"}");
ASSERT_EQUALS(std::string(""), errout.str());
ASSERT_EQUALS("", errout.str());
}

View File

@ -5241,8 +5241,7 @@ private:
void simplifyTypedef75() { // ticket #2426
const char code[] = "typedef _Packed struct S { long l; };\n";
const std::string expected = "";
ASSERT_EQUALS(expected, tok(code));
ASSERT_EQUALS("", tok(code));
ASSERT_EQUALS("", errout.str());
}

View File

@ -7103,8 +7103,7 @@ private:
}
void functionpointer4() {
const char code[] = ""
"struct S\n"
const char code[] = "struct S\n"
"{\n"
" typedef void (*FP)();\n"
" virtual FP getFP();\n"

View File

@ -57,7 +57,7 @@ private:
TEST_CASE(valueFlowSubFunction);
}
bool testValueOfX(const std::string &code, unsigned int linenr, int value) {
bool testValueOfX(const char code[], unsigned int linenr, int value) {
Settings settings;
// strcpy cfg
@ -269,8 +269,8 @@ private:
" setx(x);\n"
" if (x == 1) {}\n"
"}";
ASSERT_EQUALS(true, testValueOfX(std::string("void setx(int x);")+code, 2U, 1));
ASSERT_EQUALS(false, testValueOfX(std::string("void setx(int &x);")+code, 2U, 1));
ASSERT_EQUALS(true, testValueOfX((std::string("void setx(int x);")+code).c_str(), 2U, 1));
ASSERT_EQUALS(false, testValueOfX((std::string("void setx(int &x);")+code).c_str(), 2U, 1));
ASSERT_EQUALS(true, testValueOfX(code, 2U, 1));
code = "void f(char* x) {\n"