Strip redundant std::string usage from tests.

Done by command:
git grep -l ASSERT_EQUALS | xargs sed -i 's|ASSERT_EQUALS(std::string(\(".\+"\)),|ASSERT_EQUALS(\1,|'

Should be no functional change.
This commit is contained in:
Slava Semushin 2009-06-01 02:48:55 +07:00
parent 2de4c516e9
commit e5c0383594
17 changed files with 181 additions and 181 deletions

View File

@ -74,7 +74,7 @@ private:
"{\n"
" int num=2;"
"res=#}");
ASSERT_EQUALS(std::string("[test.cpp:3]: (error) Wrong assignement of an auto-variable to an effective parameter of a function\n"), errout.str());
ASSERT_EQUALS("[test.cpp:3]: (error) Wrong assignement of an auto-variable to an effective parameter of a function\n", errout.str());
}
void testautovararray()
{
@ -82,7 +82,7 @@ private:
"{\n"
" int num=2;"
"arr[0]=#}");
ASSERT_EQUALS(std::string("[test.cpp:3]: (error) Wrong assignement of an auto-variable to an effective parameter of a function\n"), errout.str());
ASSERT_EQUALS("[test.cpp:3]: (error) Wrong assignement of an auto-variable to an effective parameter of a function\n", errout.str());
}
void testautovarreturn()
{
@ -90,7 +90,7 @@ private:
"{\n"
" int num=2;"
"return #}");
ASSERT_EQUALS(std::string("[test.cpp:3]: (error) Return of the address of an auto-variable\n"), errout.str());
ASSERT_EQUALS("[test.cpp:3]: (error) Return of the address of an auto-variable\n", errout.str());
}
};

View File

@ -197,7 +197,7 @@ private:
" int data[2];\n"
" data[ sizeof(data[0]) ] = 0;\n"
"}\n");
ASSERT_EQUALS(std::string("[test.cpp:4]: (all) Array index out of bounds\n"), errout.str());
ASSERT_EQUALS("[test.cpp:4]: (all) Array index out of bounds\n", errout.str());
}
@ -211,7 +211,7 @@ private:
" str[15] = 0;\n"
" str[16] = 0;\n"
"}\n");
ASSERT_EQUALS(std::string("[test.cpp:5]: (all) Array index out of bounds\n"), errout.str());
ASSERT_EQUALS("[test.cpp:5]: (all) Array index out of bounds\n", errout.str());
}
@ -223,7 +223,7 @@ private:
" str[15] = 0;\n"
" str[16] = 0;\n"
"}\n");
ASSERT_EQUALS(std::string("[test.cpp:5]: (all) Array index out of bounds\n"), errout.str());
ASSERT_EQUALS("[test.cpp:5]: (all) Array index out of bounds\n", errout.str());
}
@ -236,7 +236,7 @@ private:
" for (i = 0; i < 100; i++)\n"
" sum += val[i];\n"
"}\n");
ASSERT_EQUALS(std::string("[test.cpp:5]: (all) Buffer overrun\n"), errout.str());
ASSERT_EQUALS("[test.cpp:5]: (all) Buffer overrun\n", errout.str());
}
{
@ -246,7 +246,7 @@ private:
" for (i = 1; i < 100; i++)\n"
" sum += val[i];\n"
"}\n");
ASSERT_EQUALS(std::string("[test.cpp:5]: (all) Buffer overrun\n"), errout.str());
ASSERT_EQUALS("[test.cpp:5]: (all) Buffer overrun\n", errout.str());
}
@ -257,7 +257,7 @@ private:
" for (i = a; i < 100; i++)\n"
" sum += val[i];\n"
"}\n");
ASSERT_EQUALS(std::string("[test.cpp:5]: (all) Buffer overrun\n"), errout.str());
ASSERT_EQUALS("[test.cpp:5]: (all) Buffer overrun\n", errout.str());
}
}
@ -270,7 +270,7 @@ private:
" int i[SIZE];\n"
" i[SIZE] = 0;\n"
"}\n");
ASSERT_EQUALS(std::string("[test.cpp:5]: (all) Array index out of bounds\n"), errout.str());
ASSERT_EQUALS("[test.cpp:5]: (all) Array index out of bounds\n", errout.str());
}
@ -281,7 +281,7 @@ private:
" int i[10];\n"
" i[ sizeof(i) - 1 ] = 0;\n"
"}\n");
ASSERT_EQUALS(std::string("[test.cpp:4]: (all) Array index out of bounds\n"), errout.str());
ASSERT_EQUALS("[test.cpp:4]: (all) Array index out of bounds\n", errout.str());
}
@ -297,7 +297,7 @@ private:
" struct ABC abc;\n"
" abc.str[10] = 0;\n"
"}\n");
ASSERT_EQUALS(std::string("[test.cpp:9]: (all) Array index out of bounds\n"), errout.str());
ASSERT_EQUALS("[test.cpp:9]: (all) Array index out of bounds\n", errout.str());
}
@ -312,7 +312,7 @@ private:
"{\n"
" abc->str[10] = 0;\n"
"}\n");
ASSERT_EQUALS(std::string("[test.cpp:8]: (all) Array index out of bounds\n"), errout.str());
ASSERT_EQUALS("[test.cpp:8]: (all) Array index out of bounds\n", errout.str());
}
@ -330,7 +330,7 @@ private:
" struct ABC abc;\n"
" abc.str[SIZE] = 0;\n"
"}\n");
ASSERT_EQUALS(std::string("[test.cpp:11]: (all) Array index out of bounds\n"), errout.str());
ASSERT_EQUALS("[test.cpp:11]: (all) Array index out of bounds\n", errout.str());
}
void array_index_9()
@ -345,7 +345,7 @@ private:
" char str[5];\n"
" memclr( str ); // ERROR\n"
"}\n");
ASSERT_EQUALS(std::string("[test.cpp:9] -> [test.cpp:3]: (all) Array index out of bounds\n"), errout.str());
ASSERT_EQUALS("[test.cpp:9] -> [test.cpp:3]: (all) Array index out of bounds\n", errout.str());
}
@ -365,7 +365,7 @@ private:
"{\n"
" memclr(abc->str);\n"
"}\n");
ASSERT_EQUALS(std::string("[test.cpp:13] -> [test.cpp:8]: (all) Array index out of bounds\n"), errout.str());
ASSERT_EQUALS("[test.cpp:13] -> [test.cpp:8]: (all) Array index out of bounds\n", errout.str());
}
@ -386,7 +386,7 @@ private:
" abc->str[10] = 0;\n"
" }\n"
"}\n");
ASSERT_EQUALS(std::string("[test.cpp:12]: (all) Array index out of bounds\n"), errout.str());
ASSERT_EQUALS("[test.cpp:12]: (all) Array index out of bounds\n", errout.str());
}
@ -404,7 +404,7 @@ private:
" str[10] = 0;\n"
"}\n");
std::string err(errout.str());
ASSERT_EQUALS(std::string("[test.cpp:10]: (all) Array index out of bounds\n"), err);
ASSERT_EQUALS("[test.cpp:10]: (all) Array index out of bounds\n", err);
}
void buffer_overrun_1()
@ -414,7 +414,7 @@ private:
" char str[3];\n"
" strcpy(str, \"abc\");\n"
"}\n");
ASSERT_EQUALS(std::string("[test.cpp:4]: (all) Buffer overrun\n"), errout.str());
ASSERT_EQUALS("[test.cpp:4]: (all) Buffer overrun\n", errout.str());
}
@ -429,7 +429,7 @@ private:
"{\n"
" strcpy( abc->str, \"abcdef\" );\n"
"}\n");
ASSERT_EQUALS(std::string("[test.cpp:8]: (all) Buffer overrun\n"), errout.str());
ASSERT_EQUALS("[test.cpp:8]: (all) Buffer overrun\n", errout.str());
}
@ -444,7 +444,7 @@ private:
" a[i] = 0;\n"
"}\n");
std::string err(errout.str());
ASSERT_EQUALS(std::string("[test.cpp:7]: (all) Buffer overrun\n"), err);
ASSERT_EQUALS("[test.cpp:7]: (all) Buffer overrun\n", err);
}
@ -458,7 +458,7 @@ private:
" char str[3];\n"
" sprintf(str, \"%s\", \"abc\");\n"
"}\n");
ASSERT_EQUALS(std::string("[test.cpp:4]: (all) Buffer overrun\n"), errout.str());
ASSERT_EQUALS("[test.cpp:4]: (all) Buffer overrun\n", errout.str());
}
void snprintf1()
@ -468,7 +468,7 @@ private:
" char str[5];\n"
" snprintf(str, 10, \"%s\", \"abc\");\n"
"}\n");
ASSERT_EQUALS(std::string("[test.cpp:4]: (error) snprintf size is out of bounds\n"), errout.str());
ASSERT_EQUALS("[test.cpp:4]: (error) snprintf size is out of bounds\n", errout.str());
}
void snprintf2()
@ -512,7 +512,7 @@ private:
" strncpy(str, a, 10);\n"
" strncat(str, b, 10);\n"
"}\n");
ASSERT_EQUALS(std::string("[test.cpp:5]: (all) Dangerous usage of strncat, possible buffer overrun\n"), errout.str());
ASSERT_EQUALS("[test.cpp:5]: (all) Dangerous usage of strncat, possible buffer overrun\n", errout.str());
}
void strncat2()
@ -522,7 +522,7 @@ private:
" char str[5];\n"
" strncat(str, a, 5);\n"
"}\n");
ASSERT_EQUALS(std::string("[test.cpp:4]: (all) Dangerous usage of strncat, possible buffer overrun\n"), errout.str());
ASSERT_EQUALS("[test.cpp:4]: (all) Dangerous usage of strncat, possible buffer overrun\n", errout.str());
}
@ -534,7 +534,7 @@ private:
" char str[10];\n"
" cin >> str;\n"
"}\n");
ASSERT_EQUALS(std::string("[test.cpp:4]: (all) Buffer overrun\n"), errout.str());
ASSERT_EQUALS("[test.cpp:4]: (all) Buffer overrun\n", errout.str());
}
@ -576,7 +576,7 @@ private:
"{\n"
" str[3] = 0;\n"
"}\n");
ASSERT_EQUALS(std::string("[test.cpp:5]: (all) Array index out of bounds\n"), errout.str());
ASSERT_EQUALS("[test.cpp:5]: (all) Array index out of bounds\n", errout.str());
}
@ -588,14 +588,14 @@ private:
" char *s = new char[10];\n"
" s[10] = 0;\n"
"}\n");
ASSERT_EQUALS(std::string("[test.cpp:4]: (all) Array index out of bounds\n"), errout.str());
ASSERT_EQUALS("[test.cpp:4]: (all) Array index out of bounds\n", errout.str());
check("void foo()\n"
"{\n"
" char *s = malloc(10);\n"
" s[10] = 0;\n"
"}\n");
ASSERT_EQUALS(std::string("[test.cpp:4]: (all) Array index out of bounds\n"), errout.str());
ASSERT_EQUALS("[test.cpp:4]: (all) Array index out of bounds\n", errout.str());
}
@ -606,7 +606,7 @@ private:
" char s[10];\n"
" memset(s, 5, '*');\n"
"}\n");
ASSERT_EQUALS(std::string("[test.cpp:4]: (all) The size argument is given as a char constant\n"), errout.str());
ASSERT_EQUALS("[test.cpp:4]: (all) The size argument is given as a char constant\n", errout.str());
}
};

View File

@ -72,20 +72,20 @@ private:
" char ch = 0x80;\n"
" buf[ch] = 0;\n"
"}\n");
ASSERT_EQUALS(std::string("[test.cpp:4]: (style) Warning - using char variable as array index\n"), errout.str());
ASSERT_EQUALS("[test.cpp:4]: (style) Warning - using char variable as array index\n", errout.str());
check("void foo()\n"
"{\n"
" signed char ch = 0x80;\n"
" buf[ch] = 0;\n"
"}\n");
ASSERT_EQUALS(std::string("[test.cpp:4]: (style) Warning - using char variable as array index\n"), errout.str());
ASSERT_EQUALS("[test.cpp:4]: (style) Warning - using char variable as array index\n", errout.str());
check("void foo(char ch)\n"
"{\n"
" buf[ch] = 0;\n"
"}\n");
ASSERT_EQUALS(std::string("[test.cpp:3]: (style) Warning - using char variable as array index\n"), errout.str());
ASSERT_EQUALS("[test.cpp:3]: (style) Warning - using char variable as array index\n", errout.str());
}
@ -96,7 +96,7 @@ private:
" char ch;\n"
" result = a | ch;\n"
"}\n");
ASSERT_EQUALS(std::string("[test.cpp:4]: (style) Warning - using char variable in bit operation\n"), errout.str());
ASSERT_EQUALS("[test.cpp:4]: (style) Warning - using char variable in bit operation\n", errout.str());
}
void bitop2()

View File

@ -92,7 +92,7 @@ private:
checkVirtualDestructor("class Base { };\n"
"class Derived : public Base { public: ~Derived() { (void)11; } };");
ASSERT_EQUALS(std::string("[test.cpp:1]: (error) Class Base which is inherited by class Derived does not have a virtual destructor\n"), errout.str());
ASSERT_EQUALS("[test.cpp:1]: (error) Class Base which is inherited by class Derived does not have a virtual destructor\n", errout.str());
checkVirtualDestructor("class Base { };\n"
"class Derived : Base { public: ~Derived() { (void)11; } };");
@ -105,11 +105,11 @@ private:
checkVirtualDestructor("class Base { public: ~Base(); };\n"
"class Derived : public Base { public: ~Derived() { (void)11; } };");
ASSERT_EQUALS(std::string("[test.cpp:1]: (error) Class Base which is inherited by class Derived does not have a virtual destructor\n"), errout.str());
ASSERT_EQUALS("[test.cpp:1]: (error) Class Base which is inherited by class Derived does not have a virtual destructor\n", errout.str());
checkVirtualDestructor("class Base { public: ~Base(); };\n"
"class Derived : private Fred, public Base { public: ~Derived() { (void)11; } };");
ASSERT_EQUALS(std::string("[test.cpp:1]: (error) Class Base which is inherited by class Derived does not have a virtual destructor\n"), errout.str());
ASSERT_EQUALS("[test.cpp:1]: (error) Class Base which is inherited by class Derived does not have a virtual destructor\n", errout.str());
}
void virtualDestructor4()
@ -247,7 +247,7 @@ private:
" Foo(int _i) { }\n"
"};\n");
TODO_ASSERT_EQUALS(std::string("[test.cpp:7] (style) Member variable not initialized in the constructor Foo::foo"), errout.str());
TODO_ASSERT_EQUALS("[test.cpp:7] (style) Member variable not initialized in the constructor Foo::foo", errout.str());
}

View File

@ -100,7 +100,7 @@ private:
" Fred() { }\n"
" int i;\n"
"};\n");
ASSERT_EQUALS(std::string("[test.cpp:4]: (style) Member variable not initialized in the constructor 'Fred::i'\n"), errout.str());
ASSERT_EQUALS("[test.cpp:4]: (style) Member variable not initialized in the constructor 'Fred::i'\n", errout.str());
}
@ -114,7 +114,7 @@ private:
"};\n"
"Fred::Fred()\n"
"{ }\n");
ASSERT_EQUALS(std::string("[test.cpp:7]: (style) Member variable not initialized in the constructor 'Fred::i'\n"), errout.str());
ASSERT_EQUALS("[test.cpp:7]: (style) Member variable not initialized in the constructor 'Fred::i'\n", errout.str());
}
@ -133,7 +133,7 @@ private:
"{\n"
" i = _i;\n"
"}\n");
ASSERT_EQUALS(std::string("[test.cpp:8]: (style) Member variable not initialized in the constructor 'Fred::i'\n"), errout.str());
ASSERT_EQUALS("[test.cpp:8]: (style) Member variable not initialized in the constructor 'Fred::i'\n", errout.str());
}
@ -200,7 +200,7 @@ private:
" void operator=() { }\n"
" int i;\n"
"};\n");
ASSERT_EQUALS(std::string("[test.cpp:5]: (all style) Member variable 'Fred::i' is not assigned a value in 'Fred::operator='\n"), errout.str());
ASSERT_EQUALS("[test.cpp:5]: (all style) Member variable 'Fred::i' is not assigned a value in 'Fred::operator='\n", errout.str());
}
void initvar_operator_eq3()
@ -310,7 +310,7 @@ private:
"};\n"
"Fred::Fred()\n"
"{ }");
ASSERT_EQUALS(std::string("[test.cpp:7]: (style) Member variable not initialized in the constructor 'Fred::s'\n"), errout.str());
ASSERT_EQUALS("[test.cpp:7]: (style) Member variable not initialized in the constructor 'Fred::s'\n", errout.str());
}
@ -369,7 +369,7 @@ private:
"\n"
"void Fred::operator=(const Fred &f)\n"
"{ }", true);
ASSERT_EQUALS(std::string("[test.cpp:13]: (all style) Member variable 'Fred::ints' is not assigned a value in 'Fred::operator='\n"), errout.str());
ASSERT_EQUALS("[test.cpp:13]: (all style) Member variable 'Fred::ints' is not assigned a value in 'Fred::operator='\n", errout.str());
}
};

View File

@ -74,7 +74,7 @@ private:
"{\n"
" char *x = mktemp(\"/tmp/zxcv\");\n"
"}\n");
ASSERT_EQUALS(std::string("[test.cpp:3]: (style) Found 'mktemp'. You should use 'mkstemp' instead\n"), errout.str());
ASSERT_EQUALS("[test.cpp:3]: (style) Found 'mktemp'. You should use 'mkstemp' instead\n", errout.str());
}
void testgets()
@ -83,7 +83,7 @@ private:
"{\n"
" char *x = gets();\n"
"}\n");
ASSERT_EQUALS(std::string("[test.cpp:3]: (style) Found 'gets'. You should use 'fgets' instead\n"), errout.str());
ASSERT_EQUALS("[test.cpp:3]: (style) Found 'gets'. You should use 'fgets' instead\n", errout.str());
}
void testscanf()
@ -93,7 +93,7 @@ private:
" char *x;\n"
" scanf(\"%s\", x);\n"
"}\n");
ASSERT_EQUALS(std::string("[test.cpp:4]: (style) Found 'scanf'. You should use 'fgets' instead\n"), errout.str());
ASSERT_EQUALS("[test.cpp:4]: (style) Found 'scanf'. You should use 'fgets' instead\n", errout.str());
}
};

View File

@ -74,7 +74,7 @@ private:
" unsigned int uvar = 2;\n"
" return ivar / uvar;\n"
"}\n");
ASSERT_EQUALS(std::string("[test.cpp:5]: (all style) Warning: Division with signed and unsigned operators\n"), errout.str());
ASSERT_EQUALS("[test.cpp:5]: (all style) Warning: Division with signed and unsigned operators\n", errout.str());
}
void division2()
@ -85,7 +85,7 @@ private:
" unsigned int uvar = 2;\n"
" return uvar / ivar;\n"
"}\n");
ASSERT_EQUALS(std::string("[test.cpp:5]: (all style) Warning: Division with signed and unsigned operators\n"), errout.str());
ASSERT_EQUALS("[test.cpp:5]: (all style) Warning: Division with signed and unsigned operators\n", errout.str());
}
void division3()
@ -98,7 +98,7 @@ private:
" u32 uvar = 2;\n"
" return uvar / ivar;\n"
"}\n");
ASSERT_EQUALS(std::string("[test.cpp:7]: (all style) Warning: Division with signed and unsigned operators\n"), errout.str());
ASSERT_EQUALS("[test.cpp:7]: (all style) Warning: Division with signed and unsigned operators\n", errout.str());
}
void division4()
@ -134,7 +134,7 @@ private:
" unsigned int val = 32;\n"
" int i = val / -2; }\n"
);
ASSERT_EQUALS(std::string("[test.cpp:4]: (error) Unsigned division. The result will be wrong.\n"), errout.str());
ASSERT_EQUALS("[test.cpp:4]: (error) Unsigned division. The result will be wrong.\n", errout.str());
}
void division7()
@ -144,7 +144,7 @@ private:
" unsigned int val = 32;\n"
" int i = -96 / val; }\n"
);
ASSERT_EQUALS(std::string("[test.cpp:4]: (error) Unsigned division. The result will be wrong.\n"), errout.str());
ASSERT_EQUALS("[test.cpp:4]: (error) Unsigned division. The result will be wrong.\n", errout.str());
}
};

View File

@ -35,16 +35,16 @@ private:
void simplify_path()
{
ASSERT_EQUALS(std::string("index.h"), FileLister::simplifyPath("index.h"));
ASSERT_EQUALS(std::string("/index.h"), FileLister::simplifyPath("/index.h"));
ASSERT_EQUALS(std::string("/path/"), FileLister::simplifyPath("/path/"));
ASSERT_EQUALS(std::string("/"), FileLister::simplifyPath("/"));
ASSERT_EQUALS(std::string("./index.h"), FileLister::simplifyPath("./index.h"));
ASSERT_EQUALS(std::string("../index.h"), FileLister::simplifyPath("../index.h"));
ASSERT_EQUALS(std::string("/index.h"), FileLister::simplifyPath("/path/../index.h"));
ASSERT_EQUALS(std::string("/index.h"), FileLister::simplifyPath("/path/../other/../index.h"));
ASSERT_EQUALS(std::string("/index.h"), FileLister::simplifyPath("/path/../other///././../index.h"));
ASSERT_EQUALS(std::string("../path/index.h"), FileLister::simplifyPath("../path/other/../index.h"));
ASSERT_EQUALS("index.h", FileLister::simplifyPath("index.h"));
ASSERT_EQUALS("/index.h", FileLister::simplifyPath("/index.h"));
ASSERT_EQUALS("/path/", FileLister::simplifyPath("/path/"));
ASSERT_EQUALS("/", FileLister::simplifyPath("/"));
ASSERT_EQUALS("./index.h", FileLister::simplifyPath("./index.h"));
ASSERT_EQUALS("../index.h", FileLister::simplifyPath("../index.h"));
ASSERT_EQUALS("/index.h", FileLister::simplifyPath("/path/../index.h"));
ASSERT_EQUALS("/index.h", FileLister::simplifyPath("/path/../other/../index.h"));
ASSERT_EQUALS("/index.h", FileLister::simplifyPath("/path/../other///././../index.h"));
ASSERT_EQUALS("../path/index.h", FileLister::simplifyPath("../path/other/../index.h"));
}

View File

@ -90,7 +90,7 @@ private:
" \"abc\";\n"
"}\n");
ASSERT_EQUALS(std::string("[test.cpp:3]: (style) Redundant code: Found a statement that begins with string constant\n"), errout.str());
ASSERT_EQUALS("[test.cpp:3]: (style) Redundant code: Found a statement that begins with string constant\n", errout.str());
}
void test3()
@ -125,7 +125,7 @@ private:
" 50;\n"
"}\n");
ASSERT_EQUALS(std::string("[test.cpp:3]: (style) Redundant code: Found a statement that begins with numeric constant\n"), errout.str());
ASSERT_EQUALS("[test.cpp:3]: (style) Redundant code: Found a statement that begins with numeric constant\n", errout.str());
}
void test_numeric()

View File

@ -37,12 +37,12 @@ private:
void calculate()
{
ASSERT_EQUALS(std::string("256"), MathLib::add("0xff", "1"));
ASSERT_EQUALS(std::string("-0.003"), MathLib::multiply("-1e-3", "3"));
ASSERT_EQUALS(std::string("5"), MathLib::divide("25.5", "5.1"));
ASSERT_EQUALS(std::string("-11.96"), MathLib::multiply("-2.3", "5.2"));
ASSERT_EQUALS(std::string("7"), MathLib::divide("21.", "3"));
ASSERT_EQUALS(std::string("1"), MathLib::divide("3", "2"));
ASSERT_EQUALS("256", MathLib::add("0xff", "1"));
ASSERT_EQUALS("-0.003", MathLib::multiply("-1e-3", "3"));
ASSERT_EQUALS("5", MathLib::divide("25.5", "5.1"));
ASSERT_EQUALS("-11.96", MathLib::multiply("-2.3", "5.2"));
ASSERT_EQUALS("7", MathLib::divide("21.", "3"));
ASSERT_EQUALS("1", MathLib::divide("3", "2"));
}
void convert()

View File

@ -234,7 +234,7 @@ private:
"{\n"
" int *a = new int[10];\n"
"}\n");
ASSERT_EQUALS(std::string("[test.cpp:4]: (error) Memory leak: a\n"), errout.str());
ASSERT_EQUALS("[test.cpp:4]: (error) Memory leak: a\n", errout.str());
}
void simple2()
@ -265,7 +265,7 @@ private:
" char *s = new char[100];\n"
" return 0;\n"
"}\n");
ASSERT_EQUALS(std::string("[test.cpp:4]: (error) Memory leak: s\n"), errout.str());
ASSERT_EQUALS("[test.cpp:4]: (error) Memory leak: s\n", errout.str());
}
@ -351,7 +351,7 @@ private:
" str = new char[20];\n"
" delete [] str;\n"
"}\n");
ASSERT_EQUALS(std::string("[test.cpp:5]: (error) Memory leak: str\n"), errout.str());
ASSERT_EQUALS("[test.cpp:5]: (error) Memory leak: str\n", errout.str());
}
@ -416,7 +416,7 @@ private:
" }\n"
" free(str);\n"
"}\n");
ASSERT_EQUALS(std::string("[test.cpp:6]: (error) Memory leak: str\n"), errout.str());
ASSERT_EQUALS("[test.cpp:6]: (error) Memory leak: str\n", errout.str());
}
@ -442,7 +442,7 @@ private:
" return;\n"
" }\n"
"}\n", true);
ASSERT_EQUALS(std::string("[test.cpp:9]: (all) Memory leak: str\n"), errout.str());
ASSERT_EQUALS("[test.cpp:9]: (all) Memory leak: str\n", errout.str());
}
@ -492,7 +492,7 @@ private:
" }\n"
" return NULL;\n"
"}\n");
ASSERT_EQUALS(std::string("[test.cpp:8]: (error) Memory leak: s\n"), errout.str());
ASSERT_EQUALS("[test.cpp:8]: (error) Memory leak: s\n", errout.str());
}
@ -570,7 +570,7 @@ private:
" return;\n"
" foo(p);\n"
"}\n");
ASSERT_EQUALS(std::string("[test.cpp:6]: (error) Memory leak: p\n"), errout.str());
ASSERT_EQUALS("[test.cpp:6]: (error) Memory leak: p\n", errout.str());
}
void if2()
@ -672,7 +672,7 @@ private:
" }\n"
" free(c);\n"
"}\n");
ASSERT_EQUALS(std::string("[test.cpp:11]: (error) Memory leak: c\n"), errout.str());
ASSERT_EQUALS("[test.cpp:11]: (error) Memory leak: c\n", errout.str());
}
void if9()
@ -702,7 +702,7 @@ private:
" ;\n"
" free(buf);\n"
"}\n");
TODO_ASSERT_EQUALS(std::string("[test.cpp:6]: (error) Memory leak: buf\n"), errout.str());
TODO_ASSERT_EQUALS("[test.cpp:6]: (error) Memory leak: buf\n", errout.str());
}
void if11()
@ -716,7 +716,7 @@ private:
" }\n"
" delete [] x;\n"
"}\n", true);
ASSERT_EQUALS(std::string("[test.cpp:6]: (error) Memory leak: x\n"), errout.str());
ASSERT_EQUALS("[test.cpp:6]: (error) Memory leak: x\n", errout.str());
}
@ -754,7 +754,7 @@ private:
" free(str);\n"
" }\n"
"}\n");
ASSERT_EQUALS(std::string("[test.cpp:7]: (error) Memory leak: str\n"), errout.str());
ASSERT_EQUALS("[test.cpp:7]: (error) Memory leak: str\n", errout.str());
}
@ -769,7 +769,7 @@ private:
" }\n"
" free(str);\n"
"}\n");
ASSERT_EQUALS(std::string("[test.cpp:4]: (error) Memory leak: str\n"), errout.str());
ASSERT_EQUALS("[test.cpp:4]: (error) Memory leak: str\n", errout.str());
}
@ -785,7 +785,7 @@ private:
" }\n"
" free(str);\n"
"}\n");
ASSERT_EQUALS(std::string("[test.cpp:4]: (error) Memory leak: str\n"), errout.str());
ASSERT_EQUALS("[test.cpp:4]: (error) Memory leak: str\n", errout.str());
}
@ -814,7 +814,7 @@ private:
" str = strdup(a[i]);\n"
" }\n"
"}\n");
ASSERT_EQUALS(std::string("[test.cpp:8]: (error) Memory leak: str\n"), errout.str());
ASSERT_EQUALS("[test.cpp:8]: (error) Memory leak: str\n", errout.str());
}
@ -830,7 +830,7 @@ private:
" free(str);\n"
" }\n"
"}\n");
ASSERT_EQUALS(std::string("[test.cpp:7]: (error) Memory leak: str\n"), errout.str());
ASSERT_EQUALS("[test.cpp:7]: (error) Memory leak: str\n", errout.str());
}
@ -853,7 +853,7 @@ private:
"\n"
" return a;\n"
"}\n");
TODO_ASSERT_EQUALS(std::string("[test.cpp:10]: (error) Memory leak: a\n"), errout.str());
TODO_ASSERT_EQUALS("[test.cpp:10]: (error) Memory leak: a\n", errout.str());
}
@ -895,7 +895,7 @@ private:
"\n"
" return a;\n"
"}\n", true);
ASSERT_EQUALS(std::string("[test.cpp:11]: (error) Memory leak: a\n"), errout.str());
ASSERT_EQUALS("[test.cpp:11]: (error) Memory leak: a\n", errout.str());
}
@ -914,7 +914,7 @@ private:
" while (!str);\n"
" return str;\n"
"}\n");
ASSERT_EQUALS(std::string("[test.cpp:6]: (error) Memory leak: str\n"), errout.str());
ASSERT_EQUALS("[test.cpp:6]: (error) Memory leak: str\n", errout.str());
}
@ -999,7 +999,7 @@ private:
" delete abc;\n"
"}\n");
ASSERT_EQUALS(std::string("[test.cpp:6]: (error) Memory leak: abc\n"), errout.str());
ASSERT_EQUALS("[test.cpp:6]: (error) Memory leak: abc\n", errout.str());
}
void ret3()
@ -1009,7 +1009,7 @@ private:
" FILE *filep = fopen(\"myfile.txt\",\"w\");\n"
"}\n");
ASSERT_EQUALS(std::string("[test.cpp:4]: (error) Resource leak: filep\n"), errout.str());
ASSERT_EQUALS("[test.cpp:4]: (error) Resource leak: filep\n", errout.str());
}
void ret4()
@ -1019,7 +1019,7 @@ private:
" FILE *p = popen( \"ls -l\", \"r\");\n"
"}\n");
ASSERT_EQUALS(std::string("[test.cpp:4]: (error) Resource leak: p\n"), errout.str());
ASSERT_EQUALS("[test.cpp:4]: (error) Resource leak: p\n", errout.str());
}
void ret5()
@ -1060,7 +1060,7 @@ private:
" int *a = new int[10];\n"
" free(a);\n"
"}\n", true);
ASSERT_EQUALS(std::string("[test.cpp:4]: (error) Mismatching allocation and deallocation: a\n"), errout.str());
ASSERT_EQUALS("[test.cpp:4]: (error) Mismatching allocation and deallocation: a\n", errout.str());
}
void mismatch2()
@ -1105,7 +1105,7 @@ private:
" }\n"
" delete [] p;\n"
"}\n", false);
ASSERT_EQUALS(std::string("[test.cpp:7]: (error) Mismatching allocation and deallocation: p\n"), errout.str());
ASSERT_EQUALS("[test.cpp:7]: (error) Mismatching allocation and deallocation: p\n", errout.str());
}
@ -1148,7 +1148,7 @@ private:
" char *p = new char[100];\n"
" foo(p);\n"
"}\n");
ASSERT_EQUALS(std::string("[test.cpp:8]: (error) Memory leak: p\n"), errout.str());
ASSERT_EQUALS("[test.cpp:8]: (error) Memory leak: p\n", errout.str());
}
@ -1181,7 +1181,7 @@ private:
" foo(p);\n"
"}\n", true);
std::string err(errout.str());
ASSERT_EQUALS(std::string("[test.cpp:9] -> [test.cpp:3]: (error) Mismatching allocation and deallocation: str\n"), err);
ASSERT_EQUALS("[test.cpp:9] -> [test.cpp:3]: (error) Mismatching allocation and deallocation: str\n", err);
}
@ -1198,7 +1198,7 @@ private:
" foo(p);\n"
"}\n");
std::string err(errout.str());
ASSERT_EQUALS(std::string("[test.cpp:10]: (error) Memory leak: p\n"), err);
ASSERT_EQUALS("[test.cpp:10]: (error) Memory leak: p\n", err);
}
@ -1217,7 +1217,7 @@ private:
" foo(p);\n"
"}\n");
std::string err(errout.str());
TODO_ASSERT_EQUALS(std::string("[test.cpp:11]: (error) Memory leak: p\n"), err);
TODO_ASSERT_EQUALS("[test.cpp:11]: (error) Memory leak: p\n", err);
}
@ -1361,7 +1361,7 @@ private:
" delete [] str2;\n"
"}\n", true);
ASSERT_EQUALS(std::string("[test.cpp:4]: (all) Memory leak: Fred::str1\n"), errout.str());
ASSERT_EQUALS("[test.cpp:4]: (all) Memory leak: Fred::str1\n", errout.str());
}
@ -1386,7 +1386,7 @@ private:
" free(str1);\n"
"}\n", true);
ASSERT_EQUALS(std::string("[test.cpp:17]: (error) Mismatching allocation and deallocation: Fred::str1\n"), errout.str());
ASSERT_EQUALS("[test.cpp:17]: (error) Mismatching allocation and deallocation: Fred::str1\n", errout.str());
}
void class3()
@ -1578,7 +1578,7 @@ private:
" delete [] str;\n"
"}\n");
ASSERT_EQUALS(std::string("[test.cpp:5]: (error) Memory leak: str\n"), errout.str());
ASSERT_EQUALS("[test.cpp:5]: (error) Memory leak: str\n", errout.str());
}
void throw2()
@ -1645,7 +1645,7 @@ private:
std::string err(errout.str());
ASSERT_EQUALS(std::string("[test.cpp:12]: (error) Memory leak: s2\n"), err);
ASSERT_EQUALS("[test.cpp:12]: (error) Memory leak: s2\n", err);
}
@ -1656,7 +1656,7 @@ private:
" char *a = (char *)malloc(10);\n"
" a = realloc(a, 100);\n"
"}\n");
ASSERT_EQUALS(std::string("[test.cpp:5]: (error) Memory leak: a\n"), errout.str());
ASSERT_EQUALS("[test.cpp:5]: (error) Memory leak: a\n", errout.str());
}
void realloc2()
@ -1668,7 +1668,7 @@ private:
" free(a);\n"
"}\n");
TODO_ASSERT_EQUALS(std::string("[test.cpp:5]: (error) Memory leak: a\n"), errout.str());
TODO_ASSERT_EQUALS("[test.cpp:5]: (error) Memory leak: a\n", errout.str());
}
void realloc3()
@ -1694,7 +1694,7 @@ private:
" free(a);\n"
"}\n");
TODO_ASSERT_EQUALS(std::string("[test.cpp:5]: (error) Memory leak: a\n"), errout.str());
TODO_ASSERT_EQUALS("[test.cpp:5]: (error) Memory leak: a\n", errout.str());
}
@ -1707,7 +1707,7 @@ private:
" free(a);\n"
"}\n");
ASSERT_EQUALS(std::string("[test.cpp:4]: (error) Memory leak: a\n"), errout.str());
ASSERT_EQUALS("[test.cpp:4]: (error) Memory leak: a\n", errout.str());
check("void foo()\n"
"{\n"
@ -1776,7 +1776,7 @@ private:
" char *a = reinterpret_cast<char *>(malloc(10));\n"
"}\n");
ASSERT_EQUALS(std::string("[test.cpp:4]: (error) Memory leak: a\n"), errout.str());
ASSERT_EQUALS("[test.cpp:4]: (error) Memory leak: a\n", errout.str());
}
void cast2()
@ -1814,7 +1814,7 @@ private:
" delete abc;\n"
"}\n");
TODO_ASSERT_EQUALS(std::string("[test.cpp:5]: (error) Memory leak: abc.a\n"), errout.str());
TODO_ASSERT_EQUALS("[test.cpp:5]: (error) Memory leak: abc.a\n", errout.str());
}
@ -1828,7 +1828,7 @@ private:
" delete [] s;\n"
" p = s;\n"
"}\n");
ASSERT_EQUALS(std::string("[test.cpp:5]: (error) Using 's' after it is deallocated / released\n"), errout.str());
ASSERT_EQUALS("[test.cpp:5]: (error) Using 's' after it is deallocated / released\n", errout.str());
}
void dealloc_use_2()
@ -1873,7 +1873,7 @@ private:
" free(str);\n"
" char c = str[10];\n"
"}\n");
ASSERT_EQUALS(std::string("[test.cpp:5]: (error) Using 'str' after it is deallocated / released\n"), errout.str());
ASSERT_EQUALS("[test.cpp:5]: (error) Using 'str' after it is deallocated / released\n", errout.str());
}
void dealloc_use_6()
@ -1895,7 +1895,7 @@ private:
" delete [] str;\n"
" str[10] = 0;\n"
"}\n");
ASSERT_EQUALS(std::string("[test.cpp:5]: (error) Using 'str' after it is deallocated / released\n"), errout.str());
ASSERT_EQUALS("[test.cpp:5]: (error) Using 'str' after it is deallocated / released\n", errout.str());
}
@ -1907,7 +1907,7 @@ private:
" free(str);\n"
" free(str);\n"
"}\n");
ASSERT_EQUALS(std::string("[test.cpp:5]: (error) Deallocating a deallocated pointer: str\n"), errout.str());
ASSERT_EQUALS("[test.cpp:5]: (error) Deallocating a deallocated pointer: str\n", errout.str());
}
void freefree2()
@ -1948,7 +1948,7 @@ private:
"{\n"
" Fred *f = new Fred;\n"
"}\n", true);
ASSERT_EQUALS(std::string("[test.cpp:4]: (all) Memory leak: f\n"), errout.str());
ASSERT_EQUALS("[test.cpp:4]: (all) Memory leak: f\n", errout.str());
}
@ -1960,7 +1960,7 @@ private:
" int *p = malloc(3);\n"
" free(p);\n"
"}\n", false);
ASSERT_EQUALS(std::string("[test.cpp:3]: (error) The given size 3 is mismatching\n"), errout.str());
ASSERT_EQUALS("[test.cpp:3]: (error) The given size 3 is mismatching\n", errout.str());
}
@ -2174,7 +2174,7 @@ private:
std::string err(errout.str());
ASSERT_EQUALS(std::string("[test.cpp:5]: (error) Memory leak: out\n"), err);
ASSERT_EQUALS("[test.cpp:5]: (error) Memory leak: out\n", err);
}
void strndup_function()
@ -2183,7 +2183,7 @@ private:
"{\n"
" char *out = strndup(\"text\", 3);\n"
"}\n");
ASSERT_EQUALS(std::string("[test.cpp:4]: (error) Memory leak: out\n"), errout.str());
ASSERT_EQUALS("[test.cpp:4]: (error) Memory leak: out\n", errout.str());
}
void fcloseall_function()
@ -2202,7 +2202,7 @@ private:
"{\n"
" DIR *f = opendir(\".\");\n"
"}\n");
ASSERT_EQUALS(std::string("[test.cpp:4]: (error) Resource leak: f\n"), errout.str());
ASSERT_EQUALS("[test.cpp:4]: (error) Resource leak: f\n", errout.str());
}
void fdopendir_function()
@ -2211,7 +2211,7 @@ private:
"{\n"
" DIR *f = fdopendir(fd);\n"
"}\n");
ASSERT_EQUALS(std::string("[test.cpp:4]: (error) Resource leak: f\n"), errout.str());
ASSERT_EQUALS("[test.cpp:4]: (error) Resource leak: f\n", errout.str());
}
void closedir_function()
@ -2250,7 +2250,7 @@ private:
" seekdir(f, 2)\n;"
" scandir(f, namelist, filter, comp);\n;"
"}\n");
ASSERT_EQUALS(std::string("[test.cpp:10]: (error) Resource leak: f\n"), errout.str());
ASSERT_EQUALS("[test.cpp:10]: (error) Resource leak: f\n", errout.str());
}
void file_functions()
@ -2277,7 +2277,7 @@ private:
"fgetpos(in, 10);\n"
"fprintf(in, \"text\\n\");\n"
"}\n");
ASSERT_EQUALS(std::string("[test.cpp:22]: (error) Resource leak: f\n"), errout.str());
ASSERT_EQUALS("[test.cpp:22]: (error) Resource leak: f\n", errout.str());
}
void pointer_to_pointer()

View File

@ -95,7 +95,7 @@ private:
"}");
ASSERT_EQUALS(std::string("[test.cpp:5]: (error) Division by zero\n"), errout.str());
ASSERT_EQUALS("[test.cpp:5]: (error) Division by zero\n", errout.str());
}
void zeroDiv2()
@ -137,28 +137,28 @@ private:
" delete p;\n"
" }\n"
"}\n");
ASSERT_EQUALS(std::string("[test.cpp:3]: (style) Redundant condition. It is safe to deallocate a NULL pointer\n"), errout.str());
ASSERT_EQUALS("[test.cpp:3]: (style) Redundant condition. It is safe to deallocate a NULL pointer\n", errout.str());
check("void foo()\n"
"{\n"
" if (p)\n"
" delete p;\n"
"}\n");
ASSERT_EQUALS(std::string("[test.cpp:3]: (style) Redundant condition. It is safe to deallocate a NULL pointer\n"), errout.str());
ASSERT_EQUALS("[test.cpp:3]: (style) Redundant condition. It is safe to deallocate a NULL pointer\n", errout.str());
check("void foo()\n"
"{\n"
" if (p != NULL)\n"
" delete p;\n"
"}\n");
ASSERT_EQUALS(std::string("[test.cpp:3]: (style) Redundant condition. It is safe to deallocate a NULL pointer\n"), errout.str());
ASSERT_EQUALS("[test.cpp:3]: (style) Redundant condition. It is safe to deallocate a NULL pointer\n", errout.str());
check("void foo()\n"
"{\n"
" if (p)\n"
" delete [] p;\n"
"}\n");
ASSERT_EQUALS(std::string("[test.cpp:3]: (style) Redundant condition. It is safe to deallocate a NULL pointer\n"), errout.str());
ASSERT_EQUALS("[test.cpp:3]: (style) Redundant condition. It is safe to deallocate a NULL pointer\n", errout.str());
}
void unreachable1()
@ -203,7 +203,7 @@ private:
" char buf[100];\n"
" sprintf(buf,\"%s\",buf);\n"
"}\n");
ASSERT_EQUALS(std::string("[test.cpp:4]: (error) Overlapping data buffer buf\n"), errout.str());
ASSERT_EQUALS("[test.cpp:4]: (error) Overlapping data buffer buf\n", errout.str());
}
void sprintf2()
@ -271,7 +271,7 @@ private:
"{\n"
" const char *p = \"/usr\" + '/';\n"
"}\n");
ASSERT_EQUALS(std::string("[test.cpp:3]: (error) Unusual pointer arithmetic\n"), errout.str());
ASSERT_EQUALS("[test.cpp:3]: (error) Unusual pointer arithmetic\n", errout.str());
}
void strPlusChar2()
@ -282,7 +282,7 @@ private:
" char ch = '/';\n"
" const char *p = \"/usr\" + ch;\n"
"}\n");
ASSERT_EQUALS(std::string("[test.cpp:4]: (error) Unusual pointer arithmetic\n"), errout.str());
ASSERT_EQUALS("[test.cpp:4]: (error) Unusual pointer arithmetic\n", errout.str());
}
void strPlusChar3()
@ -322,7 +322,7 @@ private:
" char str[100] = {0};\n"
" return str;\n"
"}\n");
ASSERT_EQUALS(std::string("[test.cpp:4]: (error) Returning pointer to local array variable\n"), errout.str());
ASSERT_EQUALS("[test.cpp:4]: (error) Returning pointer to local array variable\n", errout.str());
}
void returnLocalVariable2()
@ -439,7 +439,7 @@ private:
" while (tok);\n"
" tok = tok->next();\n"
"}\n");
ASSERT_EQUALS(std::string("[test.cpp:4]: (error) Possible null pointer dereference\n"), errout.str());
ASSERT_EQUALS("[test.cpp:4]: (error) Possible null pointer dereference\n", errout.str());
}
void nullpointer2()

View File

@ -80,7 +80,7 @@ private:
" if (haystack.find(needle) != haystack.end())\n"
" haystack.remove(needle);"
"}\n");
ASSERT_EQUALS(std::string("[test.cpp:3]: (style) Redundant condition. The remove function in the STL will not do anything if element doesn't exist\n"), errout.str());
ASSERT_EQUALS("[test.cpp:3]: (style) Redundant condition. The remove function in the STL will not do anything if element doesn't exist\n", errout.str());
}
void remove2()
@ -92,7 +92,7 @@ private:
" haystack.remove(needle);\n"
" }\n"
"}\n");
ASSERT_EQUALS(std::string("[test.cpp:3]: (style) Redundant condition. The remove function in the STL will not do anything if element doesn't exist\n"), errout.str());
ASSERT_EQUALS("[test.cpp:3]: (style) Redundant condition. The remove function in the STL will not do anything if element doesn't exist\n", errout.str());
}
};

View File

@ -397,7 +397,7 @@ private:
" a = 10;\n"
" a++;\n"
"}\n";
ASSERT_EQUALS(std::string("void f ( int a ) { if ( a > 10 ) { a = 5 ; } else { a = 10 ; } a ++ ; } "), tok(code));
ASSERT_EQUALS("void f ( int a ) { if ( a > 10 ) { a = 5 ; } else { a = 10 ; } a ++ ; } ", tok(code));
}
{
@ -409,7 +409,7 @@ private:
" a = 10;\n"
" ++a;\n"
"}\n";
ASSERT_EQUALS(std::string("void f ( int a ) { if ( a > 10 ) { a = 5 ; } else { a = 10 ; } ++ a ; } "), tok(code));
ASSERT_EQUALS("void f ( int a ) { if ( a > 10 ) { a = 5 ; } else { a = 10 ; } ++ a ; } ", tok(code));
}
}
@ -422,7 +422,7 @@ private:
" if (c>0) { c++; }\n"
" c++;\n"
"}\n";
ASSERT_EQUALS(std::string("void f ( ) { int c ; c = 3 ; ; { ; } ; } "), tok(code));
ASSERT_EQUALS("void f ( ) { int c ; c = 3 ; ; { ; } ; } ", tok(code));
}
@ -435,7 +435,7 @@ private:
" if (c>0) { ++c; }\n"
" ++c;\n"
"}\n";
ASSERT_EQUALS(std::string("void f ( ) { int c ; c = 3 ; ; { ; } ; } "), tok(code));
ASSERT_EQUALS("void f ( ) { int c ; c = 3 ; ; { ; } ; } ", tok(code));
}
@ -496,7 +496,7 @@ private:
" sizeof(i);\n"
" sizeof(*i);\n"
"}\n";
ASSERT_EQUALS(std::string(" void foo ( ) { int i [ 4 ] ; 16 ; 4 ; }"), sizeof_(code));
ASSERT_EQUALS(" void foo ( ) { int i [ 4 ] ; 16 ; 4 ; }", sizeof_(code));
}
void sizeof3()
@ -507,14 +507,14 @@ private:
" int i[10];\n"
" sizeof(i);\n"
"}\n";
ASSERT_EQUALS(std::string(" static int i [ 4 ] ; void f ( ) { int i [ 10 ] ; 40 ; }"), sizeof_(code));
ASSERT_EQUALS(" static int i [ 4 ] ; void f ( ) { int i [ 10 ] ; 40 ; }", sizeof_(code));
}
void sizeof4()
{
const char code[] = "int i[10];\n"
"sizeof(i[0]);\n";
ASSERT_EQUALS(std::string(" int i [ 10 ] ; 4 ;"), sizeof_(code));
ASSERT_EQUALS(" int i [ 10 ] ; 4 ;", sizeof_(code));
}
void sizeof5()
@ -522,7 +522,7 @@ private:
const char code[] =
"for (int i = 0; i < sizeof(g_ReservedNames[0]); i++)"
"{}";
ASSERT_EQUALS(std::string(" for ( int i = 0 ; i < 100 ; i ++ ) { }"), sizeof_(code));
ASSERT_EQUALS(" for ( int i = 0 ; i < 100 ; i ++ ) { }", sizeof_(code));
}
void sizeof6()

View File

@ -144,7 +144,7 @@ private:
" foo[ii] = 0;\n"
" }\n"
"}\n");
ASSERT_EQUALS(std::string("[test.cpp:6]: (error) When ii==foo.size(), foo[ii] is out of bounds\n"), errout.str());
ASSERT_EQUALS("[test.cpp:6]: (error) When ii==foo.size(), foo[ii] is out of bounds\n", errout.str());
}
void STLSizeNoErr()

View File

@ -233,7 +233,7 @@ private:
std::ostringstream ostr;
for (const Token *tok = tokenizer.tokens(); tok; tok = tok->next())
ostr << " " << tok->str();
ASSERT_EQUALS(std::string(" int * f ( int * ) ;"), ostr.str());
ASSERT_EQUALS(" int * f ( int * ) ;", ostr.str());
}
// remove static_cast..
@ -251,7 +251,7 @@ private:
std::ostringstream ostr;
for (const Token *tok = tokenizer.tokens(); tok; tok = tok->next())
ostr << " " << tok->str();
ASSERT_EQUALS(std::string(" t = ( & p ) ;"), ostr.str());
ASSERT_EQUALS(" t = ( & p ) ;", ostr.str());
}
@ -290,7 +290,7 @@ private:
tokenizer.fillFunctionList();
ASSERT_EQUALS(1, static_cast<unsigned int>(tokenizer.getFunctionList().size()));
ASSERT_EQUALS(std::string("b"), tokenizer.getFunctionList()[0]->str());
ASSERT_EQUALS("b", tokenizer.getFunctionList()[0]->str());
}
void const_and_volatile_functions()
@ -323,9 +323,9 @@ private:
ASSERT_EQUALS(3, static_cast<unsigned int>(tokenizer.getFunctionList().size()));
if (tokenizer.getFunctionList().size() == 3)
{
ASSERT_EQUALS(std::string("a"), tokenizer.getFunctionList()[0]->str());
ASSERT_EQUALS(std::string("b"), tokenizer.getFunctionList()[1]->str());
ASSERT_EQUALS(std::string("c"), tokenizer.getFunctionList()[2]->str());
ASSERT_EQUALS("a", tokenizer.getFunctionList()[0]->str());
ASSERT_EQUALS("b", tokenizer.getFunctionList()[1]->str());
ASSERT_EQUALS("c", tokenizer.getFunctionList()[2]->str());
}
}
@ -347,7 +347,7 @@ private:
std::ostringstream ostr;
for (const Token *tok = tokenizer.tokens(); tok; tok = tok->next())
ostr << " " << tok->str();
ASSERT_EQUALS(std::string(" void f ( ) { { ; } }"), ostr.str());
ASSERT_EQUALS(" void f ( ) { { ; } }", ostr.str());
}
void ifAddBraces1()
@ -368,7 +368,7 @@ private:
std::ostringstream ostr;
for (const Token *tok = tokenizer.tokens(); tok; tok = tok->next())
ostr << " " << tok->str();
ASSERT_EQUALS(std::string(" void f ( ) { if ( a ) { ; } else { ; } }"), ostr.str());
ASSERT_EQUALS(" void f ( ) { if ( a ) { ; } else { ; } }", ostr.str());
}
void ifAddBraces2()
@ -388,7 +388,7 @@ private:
std::ostringstream ostr;
for (const Token *tok = tokenizer.tokens(); tok; tok = tok->next())
ostr << " " << tok->str();
ASSERT_EQUALS(std::string(" void f ( ) { if ( a ) { if ( b ) { } } }"), ostr.str());
ASSERT_EQUALS(" void f ( ) { if ( a ) { if ( b ) { } } }", ostr.str());
}
void ifAddBraces3()
@ -408,7 +408,7 @@ private:
std::ostringstream ostr;
for (const Token *tok = tokenizer.tokens(); tok; tok = tok->next())
ostr << " " << tok->str();
ASSERT_EQUALS(std::string(" void f ( ) { if ( a ) { for ( ; ; ) { } } }"), ostr.str());
ASSERT_EQUALS(" void f ( ) { if ( a ) { for ( ; ; ) { } } }", ostr.str());
}
void ifAddBraces4()
@ -433,7 +433,7 @@ private:
std::ostringstream ostr;
for (const Token *tok = tokenizer.tokens(); tok; tok = tok->next())
ostr << " " << tok->str();
ASSERT_EQUALS(std::string(" char * foo ( ) { char * str ; str = malloc ( 10 ) ; if ( somecondition ) { for ( ; ; ) { } } return str ; }"), ostr.str());
ASSERT_EQUALS(" char * foo ( ) { char * str ; str = malloc ( 10 ) ; if ( somecondition ) { for ( ; ; ) { } } return str ; }", ostr.str());
}
void ifAddBraces5()
@ -458,7 +458,7 @@ private:
std::ostringstream ostr;
for (const Token *tok = tokenizer.tokens(); tok; tok = tok->next())
ostr << " " << tok->str();
ASSERT_EQUALS(std::string(" void f ( ) { for ( int i = 0 ; i < 2 ; i ++ ) { if ( true ) { return ; } } return ; }"), ostr.str());
ASSERT_EQUALS(" void f ( ) { for ( int i = 0 ; i < 2 ; i ++ ) { if ( true ) { return ; } } return ; }", ostr.str());
}
void ifAddBraces6()
@ -475,7 +475,7 @@ private:
std::ostringstream ostr;
for (const Token *tok = tokenizer.tokens(); tok; tok = tok->next())
ostr << " " << tok->str();
ASSERT_EQUALS(std::string(" if ( )"), ostr.str());
ASSERT_EQUALS(" if ( )", ostr.str());
}
void simplifyKnownVariables1()
@ -497,7 +497,7 @@ private:
std::ostringstream ostr;
for (const Token *tok = tokenizer.tokens(); tok; tok = tok->next())
ostr << " " << tok->str();
ASSERT_EQUALS(std::string(" void f ( ) { int a ; a = 10 ; if ( 10 ) ; }"), ostr.str());
ASSERT_EQUALS(" void f ( ) { int a ; a = 10 ; if ( 10 ) ; }", ostr.str());
}
void simplifyKnownVariables2()
@ -520,7 +520,7 @@ private:
std::ostringstream ostr;
for (const Token *tok = tokenizer.tokens(); tok; tok = tok->next())
ostr << " " << tok->str();
ASSERT_EQUALS(std::string(" void f ( ) { int a ; a = 10 ; a = g ( ) ; if ( a ) ; }"), ostr.str());
ASSERT_EQUALS(" void f ( ) { int a ; a = 10 ; a = g ( ) ; if ( a ) ; }", ostr.str());
}
void simplifyKnownVariables3()
@ -546,7 +546,7 @@ private:
std::ostringstream ostr;
for (const Token *tok = tokenizer.tokens(); tok; tok = tok->next())
ostr << " " << tok->str();
ASSERT_EQUALS(std::string(" void f ( ) { int a ; a = 4 ; while ( true ) { break ; a = 10 ; } if ( a ) ; }"), ostr.str());
ASSERT_EQUALS(" void f ( ) { int a ; a = 4 ; while ( true ) { break ; a = 10 ; } if ( a ) ; }", ostr.str());
}
void simplifyKnownVariables4()
@ -568,7 +568,7 @@ private:
std::ostringstream ostr;
for (const Token *tok = tokenizer.tokens(); tok; tok = tok->next())
ostr << " " << tok->str();
ASSERT_EQUALS(std::string(" void f ( ) { int a ; a = 4 ; if ( g ( 4 ) ) ; }"), ostr.str());
ASSERT_EQUALS(" void f ( ) { int a ; a = 4 ; if ( g ( 4 ) ) ; }", ostr.str());
}
void simplifyKnownVariables5()
@ -590,7 +590,7 @@ private:
std::ostringstream ostr;
for (const Token *tok = tokenizer.tokens(); tok; tok = tok->next())
ostr << " " << tok->str();
ASSERT_EQUALS(std::string(" void f ( ) { int a ; a = 4 ; if ( a = 5 ) ; }"), ostr.str());
ASSERT_EQUALS(" void f ( ) { int a ; a = 4 ; if ( a = 5 ) ; }", ostr.str());
}
void simplifyKnownVariables6()
@ -613,7 +613,7 @@ private:
std::ostringstream ostr;
for (const Token *tok = tokenizer.tokens(); tok; tok = tok->next())
ostr << " " << tok->str();
ASSERT_EQUALS(std::string(" void f ( ) { char str [ 2 ] ; int a ; a = 4 ; str [ 4 ] = 0 ; }"), ostr.str());
ASSERT_EQUALS(" void f ( ) { char str [ 2 ] ; int a ; a = 4 ; str [ 4 ] = 0 ; }", ostr.str());
}
void simplifyKnownVariables7()
@ -635,7 +635,7 @@ private:
std::ostringstream ostr;
for (const Token *tok = tokenizer.tokens(); tok; tok = tok->next())
ostr << " " << tok->str();
ASSERT_EQUALS(std::string(" void foo ( ) { int i ; i = 24 ; abc [ 22 ] = 1 ; abc [ 24 ] = 2 ; }"), ostr.str());
ASSERT_EQUALS(" void foo ( ) { int i ; i = 24 ; abc [ 22 ] = 1 ; abc [ 24 ] = 2 ; }", ostr.str());
}
void simplifyKnownVariables8()
@ -657,7 +657,7 @@ private:
std::ostringstream ostr;
for (const Token *tok = tokenizer.tokens(); tok; tok = tok->next())
ostr << " " << tok->str();
ASSERT_EQUALS(std::string(" void foo ( ) { int i ; i = 23 ; ; abc [ 23 ] = 0 ; }"), ostr.str());
ASSERT_EQUALS(" void foo ( ) { int i ; i = 23 ; ; abc [ 23 ] = 0 ; }", ostr.str());
}
void simplifyKnownVariables9()
@ -679,7 +679,7 @@ private:
std::ostringstream ostr;
for (const Token *tok = tokenizer.tokens(); tok; tok = tok->next())
ostr << " " << tok->str();
ASSERT_EQUALS(std::string(" void foo ( ) { int a ; a = 1 ; int b ; b = 2 ; if ( 1 < 2 ) ; }"), ostr.str());
ASSERT_EQUALS(" void foo ( ) { int a ; a = 1 ; int b ; b = 2 ; if ( 1 < 2 ) ; }", ostr.str());
}
void simplifyKnownVariables10()
@ -709,7 +709,7 @@ private:
std::ostringstream ostr;
for (const Token *tok = tokenizer.tokens(); tok; tok = tok->next())
ostr << " " << tok->str();
TODO_ASSERT_EQUALS(std::string(" void f ( ) { bool b ; b = false ; { b = true ; } if ( true ) { a ( ) ; } }"), ostr.str());
TODO_ASSERT_EQUALS(" void f ( ) { bool b ; b = false ; { b = true ; } if ( true ) { a ( ) ; } }", ostr.str());
}
{
@ -737,7 +737,7 @@ private:
std::ostringstream ostr;
for (const Token *tok = tokenizer.tokens(); tok; tok = tok->next())
ostr << " " << tok->str();
TODO_ASSERT_EQUALS(std::string(" void f ( ) { bool b ; b = false ; { b = false ; } { b = true ; } if ( true ) { a ( ) ; } }"), ostr.str());
TODO_ASSERT_EQUALS(" void f ( ) { bool b ; b = false ; { b = false ; } { b = true ; } if ( true ) { a ( ) ; } }", ostr.str());
}
{
@ -762,7 +762,7 @@ private:
std::ostringstream ostr;
for (const Token *tok = tokenizer.tokens(); tok; tok = tok->next())
ostr << " " << tok->str();
ASSERT_EQUALS(std::string(" void f ( ) { int b ; b = 0 ; b = 1 ; for ( int i = 0 ; i < 10 ; i ++ ) { } a ( 1 ) ; }"), ostr.str());
ASSERT_EQUALS(" void f ( ) { int b ; b = 0 ; b = 1 ; for ( int i = 0 ; i < 10 ; i ++ ) { } a ( 1 ) ; }", ostr.str());
}
}
@ -1553,7 +1553,7 @@ private:
std::ostringstream ostr;
for (const Token *tok = tokenizer.tokens(); tok; tok = tok->next())
ostr << " " << tok->str();
ASSERT_EQUALS(std::string(" void f ( int x ) { }"), ostr.str());
ASSERT_EQUALS(" void f ( int x ) { }", ostr.str());
}
{
@ -1571,7 +1571,7 @@ private:
std::ostringstream ostr;
for (const Token *tok = tokenizer.tokens(); tok; tok = tok->next())
ostr << " " << tok->str();
ASSERT_EQUALS(std::string(" void f ( int x , char y ) { }"), ostr.str());
ASSERT_EQUALS(" void f ( int x , char y ) { }", ostr.str());
}
{
@ -1593,7 +1593,7 @@ private:
std::ostringstream ostr;
for (const Token *tok = tokenizer.tokens(); tok; tok = tok->next())
ostr << " " << tok->str();
ASSERT_EQUALS(std::string(" void foo ( ) { if ( x ) { int x ; } { } }"), ostr.str());
ASSERT_EQUALS(" void foo ( ) { if ( x ) { int x ; } { } }", ostr.str());
}
}
@ -1616,7 +1616,7 @@ private:
std::ostringstream ostr;
for (const Token *tok = tokenizer.tokens(); tok; tok = tok->next())
ostr << " " << tok->str();
ASSERT_EQUALS(std::string(" void foo ( ) { free ( p ) ; }"), ostr.str());
ASSERT_EQUALS(" void foo ( ) { free ( p ) ; }", ostr.str());
}
void removeParantheses2()
@ -1637,7 +1637,7 @@ private:
std::ostringstream ostr;
for (const Token *tok = tokenizer.tokens(); tok; tok = tok->next())
ostr << " " << tok->str();
ASSERT_EQUALS(std::string(" void foo ( ) { if ( ! s ) { return ; } }"), ostr.str());
ASSERT_EQUALS(" void foo ( ) { if ( ! s ) { return ; } }", ostr.str());
}
void removeParantheses3()
@ -1658,7 +1658,7 @@ private:
std::ostringstream ostr;
for (const Token *tok = tokenizer.tokens(); tok; tok = tok->next())
ostr << " " << tok->str();
ASSERT_EQUALS(std::string(" void foo ( ) { { } }"), ostr.str());
ASSERT_EQUALS(" void foo ( ) { { } }", ostr.str());
}
{
@ -1677,7 +1677,7 @@ private:
std::ostringstream ostr;
for (const Token *tok = tokenizer.tokens(); tok; tok = tok->next())
ostr << " " << tok->str();
ASSERT_EQUALS(std::string(" void foo ( ) { { } }"), ostr.str());
ASSERT_EQUALS(" void foo ( ) { { } }", ostr.str());
}
{
@ -1696,7 +1696,7 @@ private:
std::ostringstream ostr;
for (const Token *tok = tokenizer.tokens(); tok; tok = tok->next())
ostr << " " << tok->str();
ASSERT_EQUALS(std::string(" void foo ( ) { if ( g ( 10 ) ) { } }"), ostr.str());
ASSERT_EQUALS(" void foo ( ) { if ( g ( 10 ) ) { } }", ostr.str());
}
}
@ -1722,7 +1722,7 @@ private:
std::ostringstream ostr;
for (const Token *tok = tokenizer.tokens(); tok; tok = tok->next())
ostr << " " << tok->str();
ASSERT_EQUALS(std::string(" void f ( ) { int x ; x = 0 ; if ( ! x ) { } }"), ostr.str());
ASSERT_EQUALS(" void f ( ) { int x ; x = 0 ; if ( ! x ) { } }", ostr.str());
}
void tokenize_double()
@ -1744,7 +1744,7 @@ private:
std::ostringstream ostr;
for (const Token *tok = tokenizer.tokens(); tok; tok = tok->next())
ostr << " " << tok->str();
ASSERT_EQUALS(std::string(" void f ( ) { double a ; a = 4.2 ; float b ; b = 4.2f ; double c ; c = 4.2e+10 ; double d ; d = 4.2e-10 ; int e ; e = 4 + 2 ; }"), ostr.str());
ASSERT_EQUALS(" void f ( ) { double a ; a = 4.2 ; float b ; b = 4.2f ; double c ; c = 4.2e+10 ; double d ; d = 4.2e-10 ; int e ; e = 4 + 2 ; }", ostr.str());
}
void tokenize_strings()
@ -1768,7 +1768,7 @@ private:
std::ostringstream ostr;
for (const Token *tok = tokenizer.tokens(); tok; tok = tok->next())
ostr << " " << tok->str();
ASSERT_EQUALS(std::string(" void f ( ) { const char * a ; a = { \"hello more world\" } ; }"), ostr.str());
ASSERT_EQUALS(" void f ( ) { const char * a ; a = { \"hello more world\" } ; }", ostr.str());
}
void simplify_constants()
@ -1796,7 +1796,7 @@ private:
std::ostringstream ostr;
for (const Token *tok = tokenizer.tokens(); tok; tok = tok->next())
ostr << " " << tok->str();
ASSERT_EQUALS(std::string(" void f ( ) { const int a = 45 ; { int b ; b = 45 ; } } void g ( ) { int a ; a = 2 ; }"), ostr.str());
ASSERT_EQUALS(" void f ( ) { const int a = 45 ; { int b ; b = 45 ; } } void g ( ) { int a ; a = 2 ; }", ostr.str());
}
void simplify_constants2()
@ -1899,7 +1899,7 @@ private:
Tokenizer tokenizer(s, this);
std::istringstream istr(code);
ASSERT_EQUALS(false, tokenizer.tokenize(istr, "test.cpp"));
ASSERT_EQUALS(std::string("[test.cpp:1]: (error) Invalid number of character ({). Can't process file.\n"), errout.str());
ASSERT_EQUALS("[test.cpp:1]: (error) Invalid number of character ({). Can't process file.\n", errout.str());
}
{
@ -1908,7 +1908,7 @@ private:
Tokenizer tokenizer(s, this);
std::istringstream istr(code);
ASSERT_EQUALS(false, tokenizer.tokenize(istr, "test.cpp"));
ASSERT_EQUALS(std::string("[test.cpp:1]: (error) Invalid number of character ((). Can't process file.\n"), errout.str());
ASSERT_EQUALS("[test.cpp:1]: (error) Invalid number of character ((). Can't process file.\n", errout.str());
}
{

View File

@ -81,7 +81,7 @@ private:
"unsigned int Fred::f()\n"
"{ }\n");
ASSERT_EQUALS(std::string("[test.cpp:4]: (style) Unused private function 'Fred::f'\n"), errout.str());
ASSERT_EQUALS("[test.cpp:4]: (style) Unused private function 'Fred::f'\n", errout.str());
}
@ -163,7 +163,7 @@ private:
"Fred::Fred()\n"
"{}\n");
ASSERT_EQUALS(std::string("[test.cpp:6]: (style) Unused private function 'Fred::get'\n"), errout.str());
ASSERT_EQUALS("[test.cpp:6]: (style) Unused private function 'Fred::get'\n", errout.str());
}