Skip to content

Commit

Permalink
slot_map tests: Exercise operator[], at(), and find_unchecked().
Browse files Browse the repository at this point in the history
Thanks to @p-groake's WG21-SG14#145 for the suggestion.
  • Loading branch information
Quuxplusone committed Feb 17, 2019
1 parent 039f3c1 commit 5fd60b8
Showing 1 changed file with 5 additions and 0 deletions.
5 changes: 5 additions & 0 deletions SG14_test/slot_map_test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -155,7 +155,11 @@ static void BasicTests(T t1, T t2)
assert(num_removed == 1);
assert(sm.size() == 1);
assert(sm.find(k1) == sm.end()); // find an expired key
try { (void)sm.at(k1); assert(false); } catch (const std::out_of_range&) {}
assert(sm.find(k2) == sm.begin()); // find a non-expired key
assert(sm.at(k2) == *sm.begin());
assert(sm.find_unchecked(k2) == sm.begin());
assert(sm[k2] == *sm.begin());
assert(sm.erase(k1) == 0); // erase an expired key
sm.swap(sm2);
assert(sm.empty());
Expand All @@ -181,6 +185,7 @@ static void FullContainerStressTest(TGen t)
for (int i = 0; i < total; ++i) {
assert(sm.size() == static_cast<typename SM::size_type>(total - i));
assert(sm.find(keys[i]) != sm.end());
assert(sm.find_unchecked(keys[i]) != sm.end());
for (int j = 0; j < i; ++j) {
assert(sm.find(keys[j]) == sm.end());
}
Expand Down

0 comments on commit 5fd60b8

Please sign in to comment.