Added regression test for #4816

Ran AStyle
This commit is contained in:
PKEuS 2015-07-23 20:53:50 +02:00
parent 795e5de903
commit e95800bed4
2 changed files with 2103 additions and 2089 deletions

View File

@ -72,6 +72,7 @@ private:
TEST_CASE(eraseAssignByFunctionCall); TEST_CASE(eraseAssignByFunctionCall);
TEST_CASE(eraseErase); TEST_CASE(eraseErase);
TEST_CASE(eraseByValue); TEST_CASE(eraseByValue);
TEST_CASE(eraseIf);
TEST_CASE(eraseOnVector); TEST_CASE(eraseOnVector);
TEST_CASE(pushback1); TEST_CASE(pushback1);
@ -1037,6 +1038,19 @@ private:
ASSERT_EQUALS("", errout.str()); ASSERT_EQUALS("", errout.str());
} }
void eraseIf() {
// #4816
check("void func(std::list<std::string> strlist) {\n"
" for (std::list<std::string>::iterator str = strlist.begin(); str != strlist.end(); str++) {\n"
" if (func2(*str)) {\n"
" strlist.erase(str);\n"
" if (strlist.empty())\n"
" return;\n"
" }\n"
" }\n"
"}");
ASSERT_EQUALS("[test.cpp:2] -> [test.cpp:4]: (error) Iterator 'str' used after element has been erased.\n", errout.str());
}
void eraseOnVector() { void eraseOnVector() {
check("void f(const std::vector<int>& m_ImplementationMap) {\n" check("void f(const std::vector<int>& m_ImplementationMap) {\n"

File diff suppressed because it is too large Load Diff