================ Comment at: test/std/containers/associative/map/map.modifiers/try.emplace.pass.cpp:73 @@ +72,3 @@ + + Moveable mv1(3, 3.0); + r = m.try_emplace(2, std::move(mv1)); ---------------- EricWF wrote: > For the sake of covering corner cases could we test every inserted value? > This applies for `insert_or_assign` as well. > > ``` > for (int i=0; i < 20; i += 2) { > Movable mv1(i, (double)i); > r = m.try_emplace(2, std::move(mv1)); > assert(m.size() == 10); > assert(!r.second); // was not inserted > assert(!mv1.moved()); // was not moved from > assert(r.first->first == 2); // key > } > ``` This doesn't really buy us anything, because it won't look at the value (`mv1`) unless the key doesn't exist. So this code is not testing every inserted value.
I think that this is what you meant: for (int i=0; i < 20; i += 2) { Movable mv1(i, (double)i); r = m.try_emplace(i, std::move(mv1)); assert(m.size() == 10); assert(!r.second); // was not inserted assert(!mv1.moved()); // was not moved from assert(r.first->first == i); // key } ================ Comment at: test/std/containers/associative/map/map.modifiers/try.emplace.pass.cpp:80 @@ +79,3 @@ + + r = m.try_emplace(3, std::move(mv1)); + assert(m.size() == 11); ---------------- EricWF wrote: > We should test the cases where insertion happens at the front and at the back. If you want; though the behavior that we're checking for here is "was this inserted?" and "was the value moved from?", which are dependent upon "Did the value exist in the map before", as opposed to the position in the map. http://reviews.llvm.org/D10669 _______________________________________________ cfe-commits mailing list cfe-commits@cs.uiuc.edu http://lists.cs.uiuc.edu/mailman/listinfo/cfe-commits