stl: added test case, dereferencing an iterator that has been erased

This commit is contained in:
Daniel Marjamäki 2009-05-02 19:58:57 +02:00
parent 7803466079
commit e11449bd58
1 changed files with 12 additions and 0 deletions

View File

@ -46,6 +46,7 @@ private:
TEST_CASE(eraseReturn); TEST_CASE(eraseReturn);
TEST_CASE(eraseGoto); TEST_CASE(eraseGoto);
TEST_CASE(eraseAssign); TEST_CASE(eraseAssign);
TEST_CASE(eraseDereference);
TEST_CASE(pushback1); TEST_CASE(pushback1);
TEST_CASE(pushback2); TEST_CASE(pushback2);
@ -254,6 +255,17 @@ private:
ASSERT_EQUALS("", errout.str()); ASSERT_EQUALS("", errout.str());
} }
void eraseDereference()
{
check("void f(std::vector<ints> &ints)\n"
"{\n"
" std::vector<int>::iterator iter;\n"
" iter = ints.begin() + 2;\n"
" ints.erase(iter);\n"
" std::cout << (*iter) << std::endl;\n"
"}\n");
TODO_ASSERT_EQUALS("[test.cpp:6]: (error) Dereferencing invalid iterator\n", errout.str());
}