Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add test to cover deque::erase(iter, iter) and avoiding self-move-assigns #1203

Merged
merged 1 commit into from
Aug 22, 2020
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 25 additions & 0 deletions tests/std/tests/Dev10_881629_vector_erase_return_value/test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,28 @@ void test_case_devcom_776568() {
assert(it == c.end());
}

template <template <class...> class Container>
void test_case_gh_1118() {
Container<CheckSelfMoveAssign> c;
c.emplace_back(1);
c.emplace_back(2);
c.emplace_back(3);

const auto after = c.begin() + 2;
StephanTLavavej marked this conversation as resolved.
Show resolved Hide resolved
auto it = c.erase(c.begin() + 1, c.begin() + 1);
assert(after->i == 3); // asserts that the iterator was not invalidated by iterator debugging
assert(it == c.begin() + 1);

// asserts that no elements were self-move-assigned:
it = c.begin();
for (int idx = 1; idx <= 3; ++idx) {
assert(it->i == idx);
++it;
}

assert(it == c.end());
}

int main() {
{
vector<int> v(1, 1729);
Expand Down Expand Up @@ -200,4 +222,7 @@ int main() {

test_case_devcom_776568<vector>();
test_case_devcom_776568<deque>();

test_case_gh_1118<vector>();
test_case_gh_1118<deque>();
}