astyle formatting
This commit is contained in:
parent
96e99d347e
commit
e11d9f1628
|
@ -40,37 +40,47 @@ void CheckPostfixOperator::postfixOperator()
|
||||||
for (const Token *tok = _tokenizer->tokens(); tok; tok = tok->next())
|
for (const Token *tok = _tokenizer->tokens(); tok; tok = tok->next())
|
||||||
{
|
{
|
||||||
bool result = false;
|
bool result = false;
|
||||||
if ( Token::Match(tok, "++|--") ) {
|
if (Token::Match(tok, "++|--"))
|
||||||
if ( Token::Match(tok->previous()->previous(), ";|{|}") && Token::Match(tok->next(), ";|)|,") ) {
|
{
|
||||||
result = true;
|
if (Token::Match(tok->previous()->previous(), ";|{|}") && Token::Match(tok->next(), ";|)|,"))
|
||||||
}
|
{
|
||||||
else if (tok->strAt(-2) == ",") {
|
result = true;
|
||||||
int i(1);
|
}
|
||||||
while(tok->strAt(i) != ")") {
|
else if (tok->strAt(-2) == ",")
|
||||||
if(tok->strAt(i) == ";") {
|
{
|
||||||
result = true;
|
int i(1);
|
||||||
break;
|
while (tok->strAt(i) != ")")
|
||||||
}
|
{
|
||||||
++i;
|
if (tok->strAt(i) == ";")
|
||||||
}
|
{
|
||||||
|
result = true;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
++i;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else if (tok->strAt(-2) == "<<" && tok->strAt(1) == "<<")
|
||||||
|
{
|
||||||
|
result = true;
|
||||||
}
|
}
|
||||||
else if (tok->strAt(-2) == "<<" && tok->strAt(1) == "<<") {
|
|
||||||
result = true;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if(result) {
|
if (result)
|
||||||
const Token *decltok = Token::findmatch(_tokenizer->tokens(), "%varid%", tok->previous()->varId());
|
{
|
||||||
if (decltok && Token::Match(decltok->previous(), "iterator|const_iterator|reverse_iterator|const_reverse_iterator")) {
|
const Token *decltok = Token::findmatch(_tokenizer->tokens(), "%varid%", tok->previous()->varId());
|
||||||
// the variable is an iterator
|
if (decltok && Token::Match(decltok->previous(), "iterator|const_iterator|reverse_iterator|const_reverse_iterator"))
|
||||||
postfixOperatorError(tok);
|
{
|
||||||
}
|
// the variable is an iterator
|
||||||
else {
|
postfixOperatorError(tok);
|
||||||
const std::string classDef = std::string("class ") + std::string(decltok->previous()->strAt(0));
|
}
|
||||||
if (Token::findmatch(_tokenizer->tokens(), classDef.c_str())) {
|
else
|
||||||
// the variable is an instance of class
|
{
|
||||||
postfixOperatorError(tok);
|
const std::string classDef = std::string("class ") + std::string(decltok->previous()->strAt(0));
|
||||||
}
|
if (Token::findmatch(_tokenizer->tokens(), classDef.c_str()))
|
||||||
|
{
|
||||||
|
// the variable is an instance of class
|
||||||
|
postfixOperatorError(tok);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -72,105 +72,105 @@ private:
|
||||||
void testsimple()
|
void testsimple()
|
||||||
{
|
{
|
||||||
check("\n"
|
check("\n"
|
||||||
"#include <iostream>\n"
|
"#include <iostream>\n"
|
||||||
"int main(int argc, char *argv[])\n"
|
"int main(int argc, char *argv[])\n"
|
||||||
"{\n"
|
"{\n"
|
||||||
" unsigned int k(0);\n"
|
" unsigned int k(0);\n"
|
||||||
" std::cout << k << std::endl;\n"
|
" std::cout << k << std::endl;\n"
|
||||||
" k++;\n"
|
" k++;\n"
|
||||||
" std::cout << k << std::endl;\n"
|
" std::cout << k << std::endl;\n"
|
||||||
" if(k) {\n"
|
" if(k) {\n"
|
||||||
" k++;\n"
|
" k++;\n"
|
||||||
" }\n"
|
" }\n"
|
||||||
" std::cout << k << std::endl;\n"
|
" std::cout << k << std::endl;\n"
|
||||||
" k--;\n"
|
" k--;\n"
|
||||||
" std::cout << k << std::endl;\n"
|
" std::cout << k << std::endl;\n"
|
||||||
" return 0;\n"
|
" return 0;\n"
|
||||||
"}\n");
|
"}\n");
|
||||||
ASSERT_EQUALS("", errout.str());
|
ASSERT_EQUALS("", errout.str());
|
||||||
|
|
||||||
check("\n"
|
check("\n"
|
||||||
"#include <iostream>\n"
|
"#include <iostream>\n"
|
||||||
"class K {};"
|
"class K {};"
|
||||||
"int main(int argc, char *argv[])\n"
|
"int main(int argc, char *argv[])\n"
|
||||||
"{\n"
|
"{\n"
|
||||||
" K k(0);\n"
|
" K k(0);\n"
|
||||||
" std::cout << k << std::endl;\n"
|
" std::cout << k << std::endl;\n"
|
||||||
" k++;\n"
|
" k++;\n"
|
||||||
" std::cout << k << std::endl;\n"
|
" std::cout << k << std::endl;\n"
|
||||||
" return 0;\n"
|
" return 0;\n"
|
||||||
"}\n");
|
"}\n");
|
||||||
ASSERT_EQUALS("[test.cpp:7]: (style) You should use ++ and -- as prefix whenever possible as these are more efficient than postfix operators\n", errout.str());
|
ASSERT_EQUALS("[test.cpp:7]: (style) You should use ++ and -- as prefix whenever possible as these are more efficient than postfix operators\n", errout.str());
|
||||||
|
|
||||||
check("\n"
|
check("\n"
|
||||||
"#include <iostream>\n"
|
"#include <iostream>\n"
|
||||||
"class K {};"
|
"class K {};"
|
||||||
"int main(int argc, char *argv[])\n"
|
"int main(int argc, char *argv[])\n"
|
||||||
"{\n"
|
"{\n"
|
||||||
" K k(1);\n"
|
" K k(1);\n"
|
||||||
" std::cout << k << std::endl;\n"
|
" std::cout << k << std::endl;\n"
|
||||||
" if(k) {\n"
|
" if(k) {\n"
|
||||||
" k++;\n"
|
" k++;\n"
|
||||||
" }\n"
|
" }\n"
|
||||||
" std::cout << k << std::endl;\n"
|
" std::cout << k << std::endl;\n"
|
||||||
" return 0;\n"
|
" return 0;\n"
|
||||||
"}\n");
|
"}\n");
|
||||||
ASSERT_EQUALS("[test.cpp:8]: (style) You should use ++ and -- as prefix whenever possible as these are more efficient than postfix operators\n", errout.str());
|
ASSERT_EQUALS("[test.cpp:8]: (style) You should use ++ and -- as prefix whenever possible as these are more efficient than postfix operators\n", errout.str());
|
||||||
|
|
||||||
check("\n"
|
check("\n"
|
||||||
"#include <iostream>\n"
|
"#include <iostream>\n"
|
||||||
"class K {};"
|
"class K {};"
|
||||||
"int main(int argc, char *argv[])\n"
|
"int main(int argc, char *argv[])\n"
|
||||||
"{\n"
|
"{\n"
|
||||||
" K k(1);\n"
|
" K k(1);\n"
|
||||||
" std::cout << k << std::endl;\n"
|
" std::cout << k << std::endl;\n"
|
||||||
" if(k) {\n"
|
" if(k) {\n"
|
||||||
" ++k;\n"
|
" ++k;\n"
|
||||||
" }\n"
|
" }\n"
|
||||||
" k++;\n"
|
" k++;\n"
|
||||||
" std::cout << k << std::endl;\n"
|
" std::cout << k << std::endl;\n"
|
||||||
" return 0;\n"
|
" return 0;\n"
|
||||||
"}\n");
|
"}\n");
|
||||||
ASSERT_EQUALS("[test.cpp:10]: (style) You should use ++ and -- as prefix whenever possible as these are more efficient than postfix operators\n", errout.str());
|
ASSERT_EQUALS("[test.cpp:10]: (style) You should use ++ and -- as prefix whenever possible as these are more efficient than postfix operators\n", errout.str());
|
||||||
|
|
||||||
|
|
||||||
check("\n"
|
check("\n"
|
||||||
"#include <iostream>\n"
|
"#include <iostream>\n"
|
||||||
"class K {};"
|
"class K {};"
|
||||||
"int main(int argc, char *argv[])\n"
|
"int main(int argc, char *argv[])\n"
|
||||||
"{\n"
|
"{\n"
|
||||||
" K k(0);\n"
|
" K k(0);\n"
|
||||||
" std::cout << k << std::endl;\n"
|
" std::cout << k << std::endl;\n"
|
||||||
" k--;\n"
|
" k--;\n"
|
||||||
" std::cout << k << std::endl;\n"
|
" std::cout << k << std::endl;\n"
|
||||||
" return 0;\n"
|
" return 0;\n"
|
||||||
"}\n");
|
"}\n");
|
||||||
ASSERT_EQUALS("[test.cpp:7]: (style) You should use ++ and -- as prefix whenever possible as these are more efficient than postfix operators\n", errout.str());
|
ASSERT_EQUALS("[test.cpp:7]: (style) You should use ++ and -- as prefix whenever possible as these are more efficient than postfix operators\n", errout.str());
|
||||||
|
|
||||||
check("\n"
|
check("\n"
|
||||||
"#include <iostream>\n"
|
"#include <iostream>\n"
|
||||||
"class K {};"
|
"class K {};"
|
||||||
"int main(int argc, char *argv[])\n"
|
"int main(int argc, char *argv[])\n"
|
||||||
"{\n"
|
"{\n"
|
||||||
" K k(0);\n"
|
" K k(0);\n"
|
||||||
" std::cout << k << std::endl;\n"
|
" std::cout << k << std::endl;\n"
|
||||||
" ++k;\n"
|
" ++k;\n"
|
||||||
" std::cout << k << std::endl;\n"
|
" std::cout << k << std::endl;\n"
|
||||||
" return 0;\n"
|
" return 0;\n"
|
||||||
"}\n");
|
"}\n");
|
||||||
ASSERT_EQUALS("", errout.str());
|
ASSERT_EQUALS("", errout.str());
|
||||||
|
|
||||||
check("\n"
|
check("\n"
|
||||||
"#include <iostream>\n"
|
"#include <iostream>\n"
|
||||||
"class K {};"
|
"class K {};"
|
||||||
"int main(int argc, char *argv[])\n"
|
"int main(int argc, char *argv[])\n"
|
||||||
"{\n"
|
"{\n"
|
||||||
" K k(0);\n"
|
" K k(0);\n"
|
||||||
" std::cout << k << std::endl;\n"
|
" std::cout << k << std::endl;\n"
|
||||||
" --k;\n"
|
" --k;\n"
|
||||||
" std::cout << k << std::endl;\n"
|
" std::cout << k << std::endl;\n"
|
||||||
" return 0;\n"
|
" return 0;\n"
|
||||||
"}\n");
|
"}\n");
|
||||||
ASSERT_EQUALS("", errout.str());
|
ASSERT_EQUALS("", errout.str());
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -178,191 +178,191 @@ private:
|
||||||
void testfor()
|
void testfor()
|
||||||
{
|
{
|
||||||
check("\n"
|
check("\n"
|
||||||
"#include <iostream>\n"
|
"#include <iostream>\n"
|
||||||
"int main(int argc, char *argv[])\n"
|
"int main(int argc, char *argv[])\n"
|
||||||
"{\n"
|
"{\n"
|
||||||
" for ( unsigned int i=0; i <= 10; i++) {\n"
|
" for ( unsigned int i=0; i <= 10; i++) {\n"
|
||||||
" std::cout << i << std::endl;\n"
|
" std::cout << i << std::endl;\n"
|
||||||
" }\n"
|
" }\n"
|
||||||
" return 0;\n"
|
" return 0;\n"
|
||||||
"}\n");
|
"}\n");
|
||||||
ASSERT_EQUALS("", errout.str());
|
ASSERT_EQUALS("", errout.str());
|
||||||
|
|
||||||
check("\n"
|
check("\n"
|
||||||
"#include <iostream>\n"
|
"#include <iostream>\n"
|
||||||
"class K {};\n"
|
"class K {};\n"
|
||||||
"int main(int argc, char *argv[])\n"
|
"int main(int argc, char *argv[])\n"
|
||||||
"{\n"
|
"{\n"
|
||||||
" for ( K i(0); i <= 10; i++) {\n"
|
" for ( K i(0); i <= 10; i++) {\n"
|
||||||
" std::cout << i << std::endl;\n"
|
" std::cout << i << std::endl;\n"
|
||||||
" }\n"
|
" }\n"
|
||||||
" return 0;\n"
|
" return 0;\n"
|
||||||
"}\n");
|
"}\n");
|
||||||
ASSERT_EQUALS("[test.cpp:6]: (style) You should use ++ and -- as prefix whenever possible as these are more efficient than postfix operators\n", errout.str());
|
ASSERT_EQUALS("[test.cpp:6]: (style) You should use ++ and -- as prefix whenever possible as these are more efficient than postfix operators\n", errout.str());
|
||||||
|
|
||||||
check("\n"
|
check("\n"
|
||||||
"#include <iostream>\n"
|
"#include <iostream>\n"
|
||||||
"class K {};\n"
|
"class K {};\n"
|
||||||
"int main(int argc, char *argv[])\n"
|
"int main(int argc, char *argv[])\n"
|
||||||
"{\n"
|
"{\n"
|
||||||
" for ( K i(0); i <= 10; ++i) {\n"
|
" for ( K i(0); i <= 10; ++i) {\n"
|
||||||
" std::cout << i << std::endl;\n"
|
" std::cout << i << std::endl;\n"
|
||||||
" }\n"
|
" }\n"
|
||||||
" return 0;\n"
|
" return 0;\n"
|
||||||
"}\n");
|
"}\n");
|
||||||
ASSERT_EQUALS("", errout.str());
|
ASSERT_EQUALS("", errout.str());
|
||||||
|
|
||||||
check("\n"
|
check("\n"
|
||||||
"#include <iostream>\n"
|
"#include <iostream>\n"
|
||||||
"class K {};\n"
|
"class K {};\n"
|
||||||
"int main(int argc, char *argv[])\n"
|
"int main(int argc, char *argv[])\n"
|
||||||
"{\n"
|
"{\n"
|
||||||
" for ( K i(10); i > 1; i--) {\n"
|
" for ( K i(10); i > 1; i--) {\n"
|
||||||
" std::cout << i << std::endl;\n"
|
" std::cout << i << std::endl;\n"
|
||||||
" }\n"
|
" }\n"
|
||||||
" return 0;\n"
|
" return 0;\n"
|
||||||
"}\n");
|
"}\n");
|
||||||
ASSERT_EQUALS("[test.cpp:6]: (style) You should use ++ and -- as prefix whenever possible as these are more efficient than postfix operators\n", errout.str());
|
ASSERT_EQUALS("[test.cpp:6]: (style) You should use ++ and -- as prefix whenever possible as these are more efficient than postfix operators\n", errout.str());
|
||||||
|
|
||||||
check("\n"
|
check("\n"
|
||||||
"#include <iostream>\n"
|
"#include <iostream>\n"
|
||||||
"class K {};\n"
|
"class K {};\n"
|
||||||
"int main(int argc, char *argv[])\n"
|
"int main(int argc, char *argv[])\n"
|
||||||
"{\n"
|
"{\n"
|
||||||
" for ( K i=10; i > 1; --i) {\n"
|
" for ( K i=10; i > 1; --i) {\n"
|
||||||
" std::cout << i << std::endl;\n"
|
" std::cout << i << std::endl;\n"
|
||||||
" }\n"
|
" }\n"
|
||||||
" return 0;\n"
|
" return 0;\n"
|
||||||
"}\n");
|
"}\n");
|
||||||
ASSERT_EQUALS("", errout.str());
|
ASSERT_EQUALS("", errout.str());
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void teststream()
|
void teststream()
|
||||||
{
|
{
|
||||||
check("\n"
|
check("\n"
|
||||||
"#include <iostream>\n"
|
"#include <iostream>\n"
|
||||||
"int main(int argc, char *argv[])\n"
|
"int main(int argc, char *argv[])\n"
|
||||||
"{\n"
|
"{\n"
|
||||||
" int k(0);\n"
|
" int k(0);\n"
|
||||||
" std::cout << k << std::endl;\n"
|
" std::cout << k << std::endl;\n"
|
||||||
" std::cout << k++ << std::endl;\n"
|
" std::cout << k++ << std::endl;\n"
|
||||||
" std::cout << k-- << std::endl;\n"
|
" std::cout << k-- << std::endl;\n"
|
||||||
" return 0;\n"
|
" return 0;\n"
|
||||||
"}\n");
|
"}\n");
|
||||||
ASSERT_EQUALS("", errout.str());
|
ASSERT_EQUALS("", errout.str());
|
||||||
|
|
||||||
check("\n"
|
check("\n"
|
||||||
"#include <iostream>\n"
|
"#include <iostream>\n"
|
||||||
"class K {};\n"
|
"class K {};\n"
|
||||||
"int main(int argc, char *argv[])\n"
|
"int main(int argc, char *argv[])\n"
|
||||||
"{\n"
|
"{\n"
|
||||||
" K k(0);\n"
|
" K k(0);\n"
|
||||||
" std::cout << k << std::endl;\n"
|
" std::cout << k << std::endl;\n"
|
||||||
" std::cout << k-- << std::endl;\n"
|
" std::cout << k-- << std::endl;\n"
|
||||||
" return 0;\n"
|
" return 0;\n"
|
||||||
"}\n");
|
"}\n");
|
||||||
ASSERT_EQUALS("[test.cpp:8]: (style) You should use ++ and -- as prefix whenever possible as these are more efficient than postfix operators\n", errout.str());
|
ASSERT_EQUALS("[test.cpp:8]: (style) You should use ++ and -- as prefix whenever possible as these are more efficient than postfix operators\n", errout.str());
|
||||||
|
|
||||||
check("\n"
|
check("\n"
|
||||||
"#include <iostream>\n"
|
"#include <iostream>\n"
|
||||||
"class K {};\n"
|
"class K {};\n"
|
||||||
"int main(int argc, char *argv[])\n"
|
"int main(int argc, char *argv[])\n"
|
||||||
"{\n"
|
"{\n"
|
||||||
" K k(0);\n"
|
" K k(0);\n"
|
||||||
" std::cout << k << std::endl;\n"
|
" std::cout << k << std::endl;\n"
|
||||||
" std::cout << ++k << std::endl;\n"
|
" std::cout << ++k << std::endl;\n"
|
||||||
" std::cout << --k << std::endl;\n"
|
" std::cout << --k << std::endl;\n"
|
||||||
" return 0;\n"
|
" return 0;\n"
|
||||||
"}\n");
|
"}\n");
|
||||||
ASSERT_EQUALS("", errout.str());
|
ASSERT_EQUALS("", errout.str());
|
||||||
}
|
}
|
||||||
|
|
||||||
void testvolatile()
|
void testvolatile()
|
||||||
{
|
{
|
||||||
check("\n"
|
check("\n"
|
||||||
"#include <iostream>\n"
|
"#include <iostream>\n"
|
||||||
"class K {};\n"
|
"class K {};\n"
|
||||||
"int main(int argc, char *argv[])\n"
|
"int main(int argc, char *argv[])\n"
|
||||||
"{\n"
|
"{\n"
|
||||||
" volatile K k(0);\n"
|
" volatile K k(0);\n"
|
||||||
" std::cout << k << std::endl;\n"
|
" std::cout << k << std::endl;\n"
|
||||||
" k++;\n"
|
" k++;\n"
|
||||||
" std::cout << k << std::endl;\n"
|
" std::cout << k << std::endl;\n"
|
||||||
" return 0;\n"
|
" return 0;\n"
|
||||||
"}\n");
|
"}\n");
|
||||||
TODO_ASSERT_EQUALS("", errout.str());
|
TODO_ASSERT_EQUALS("", errout.str());
|
||||||
}
|
}
|
||||||
|
|
||||||
void testiterator()
|
void testiterator()
|
||||||
{
|
{
|
||||||
check("\n"
|
check("\n"
|
||||||
"#include <vector>\n"
|
"#include <vector>\n"
|
||||||
"class Base {};\n"
|
"class Base {};\n"
|
||||||
"int main() {\n"
|
"int main() {\n"
|
||||||
" std::vector<Base*> v;\n"
|
" std::vector<Base*> v;\n"
|
||||||
" v.push_back(new Base());\n"
|
" v.push_back(new Base());\n"
|
||||||
" v.push_back(new Base());\n"
|
" v.push_back(new Base());\n"
|
||||||
" for (std::vector<Base*>::iterator i=v.begin(); i!=v.end(); i++) {\n"
|
" for (std::vector<Base*>::iterator i=v.begin(); i!=v.end(); i++) {\n"
|
||||||
" ;;\n"
|
" ;;\n"
|
||||||
" }\n"
|
" }\n"
|
||||||
" v.clear();\n"
|
" v.clear();\n"
|
||||||
" return 0;\n"
|
" return 0;\n"
|
||||||
"}\n");
|
"}\n");
|
||||||
ASSERT_EQUALS("[test.cpp:8]: (style) You should use ++ and -- as prefix whenever possible as these are more efficient than postfix operators\n", errout.str());
|
ASSERT_EQUALS("[test.cpp:8]: (style) You should use ++ and -- as prefix whenever possible as these are more efficient than postfix operators\n", errout.str());
|
||||||
|
|
||||||
check("\n"
|
check("\n"
|
||||||
"#include <iostream>\n"
|
"#include <iostream>\n"
|
||||||
"#include <vector>\n"
|
"#include <vector>\n"
|
||||||
"int main() {\n"
|
"int main() {\n"
|
||||||
" std::vector<int> v;\n"
|
" std::vector<int> v;\n"
|
||||||
" std::vector<int>::iterator it;\n"
|
" std::vector<int>::iterator it;\n"
|
||||||
" for( int i=0; i < 10; ++i ) v.push_back(i);\n"
|
" for( int i=0; i < 10; ++i ) v.push_back(i);\n"
|
||||||
" unsigned int total = 0;\n"
|
" unsigned int total = 0;\n"
|
||||||
" it = v.begin();\n"
|
" it = v.begin();\n"
|
||||||
" while( it != v.end() ) {\n"
|
" while( it != v.end() ) {\n"
|
||||||
" total += *it;\n"
|
" total += *it;\n"
|
||||||
" it++;\n"
|
" it++;\n"
|
||||||
" }\n"
|
" }\n"
|
||||||
" return 0;\n"
|
" return 0;\n"
|
||||||
"}\n");
|
"}\n");
|
||||||
ASSERT_EQUALS("[test.cpp:12]: (style) You should use ++ and -- as prefix whenever possible as these are more efficient than postfix operators\n", errout.str());
|
ASSERT_EQUALS("[test.cpp:12]: (style) You should use ++ and -- as prefix whenever possible as these are more efficient than postfix operators\n", errout.str());
|
||||||
|
|
||||||
check("\n"
|
check("\n"
|
||||||
"#include <iostream>\n"
|
"#include <iostream>\n"
|
||||||
"#include <vector>\n"
|
"#include <vector>\n"
|
||||||
"int main() {\n"
|
"int main() {\n"
|
||||||
" std::vector<int> v;\n"
|
" std::vector<int> v;\n"
|
||||||
" std::vector<int>::const_iterator it;\n"
|
" std::vector<int>::const_iterator it;\n"
|
||||||
" for( int i=0; i < 10; ++i ) v.push_back(i);\n"
|
" for( int i=0; i < 10; ++i ) v.push_back(i);\n"
|
||||||
" unsigned int total = 0;\n"
|
" unsigned int total = 0;\n"
|
||||||
" it = v.begin();\n"
|
" it = v.begin();\n"
|
||||||
" while( it != v.end() ) {\n"
|
" while( it != v.end() ) {\n"
|
||||||
" it++;\n"
|
" it++;\n"
|
||||||
" }\n"
|
" }\n"
|
||||||
" return 0;\n"
|
" return 0;\n"
|
||||||
"}\n");
|
"}\n");
|
||||||
ASSERT_EQUALS("[test.cpp:11]: (style) You should use ++ and -- as prefix whenever possible as these are more efficient than postfix operators\n", errout.str());
|
ASSERT_EQUALS("[test.cpp:11]: (style) You should use ++ and -- as prefix whenever possible as these are more efficient than postfix operators\n", errout.str());
|
||||||
|
|
||||||
check("\n"
|
check("\n"
|
||||||
"#include <iostream>\n"
|
"#include <iostream>\n"
|
||||||
"#include <vector>\n"
|
"#include <vector>\n"
|
||||||
"int main() {\n"
|
"int main() {\n"
|
||||||
" std::vector<int> v;\n"
|
" std::vector<int> v;\n"
|
||||||
" std::vector<int>::iterator it;\n"
|
" std::vector<int>::iterator it;\n"
|
||||||
" for( int i=0; i < 10; ++i ) v.push_back(i);\n"
|
" for( int i=0; i < 10; ++i ) v.push_back(i);\n"
|
||||||
" unsigned int total = 0;\n"
|
" unsigned int total = 0;\n"
|
||||||
" std::vector<int>::reverse_iterator rit;\n"
|
" std::vector<int>::reverse_iterator rit;\n"
|
||||||
" rit= v.rend();\n"
|
" rit= v.rend();\n"
|
||||||
" while( rit != v.rbegin() ) {\n"
|
" while( rit != v.rbegin() ) {\n"
|
||||||
" rit--;\n"
|
" rit--;\n"
|
||||||
" }\n"
|
" }\n"
|
||||||
" return 0;\n"
|
" return 0;\n"
|
||||||
"}\n");
|
"}\n");
|
||||||
ASSERT_EQUALS("[test.cpp:12]: (style) You should use ++ and -- as prefix whenever possible as these are more efficient than postfix operators\n", errout.str());
|
ASSERT_EQUALS("[test.cpp:12]: (style) You should use ++ and -- as prefix whenever possible as these are more efficient than postfix operators\n", errout.str());
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
Loading…
Reference in New Issue