diff options
Diffstat (limited to 'test/std/containers/associative/map')
-rw-r--r-- | test/std/containers/associative/map/map.modifiers/insert_iter_rv.pass.cpp | 33 | ||||
-rw-r--r-- | test/std/containers/associative/map/map.modifiers/insert_rv.pass.cpp | 38 |
2 files changed, 69 insertions, 2 deletions
diff --git a/test/std/containers/associative/map/map.modifiers/insert_iter_rv.pass.cpp b/test/std/containers/associative/map/map.modifiers/insert_iter_rv.pass.cpp index 42b41fd7b867..9db1e5c70732 100644 --- a/test/std/containers/associative/map/map.modifiers/insert_iter_rv.pass.cpp +++ b/test/std/containers/associative/map/map.modifiers/insert_iter_rv.pass.cpp @@ -19,6 +19,7 @@ #include "MoveOnly.h" #include "min_allocator.h" +#include "test_macros.h" int main() { @@ -52,7 +53,7 @@ int main() assert(r->first == 3); assert(r->second == 3); } -#if __cplusplus >= 201103L +#if TEST_STD_VER >= 11 { typedef std::map<int, MoveOnly, std::less<int>, min_allocator<std::pair<const int, MoveOnly>>> M; typedef std::pair<int, MoveOnly> P; @@ -83,5 +84,35 @@ int main() assert(r->second == 3); } #endif +#if TEST_STD_VER > 14 + { + typedef std::map<int, MoveOnly> M; + typedef M::iterator R; + M m; + R r = m.insert(m.end(), {2, MoveOnly(2)}); + assert(r == m.begin()); + assert(m.size() == 1); + assert(r->first == 2); + assert(r->second == 2); + + r = m.insert(m.end(), {1, MoveOnly(1)}); + assert(r == m.begin()); + assert(m.size() == 2); + assert(r->first == 1); + assert(r->second == 1); + + r = m.insert(m.end(), {3, MoveOnly(3)}); + assert(r == prev(m.end())); + assert(m.size() == 3); + assert(r->first == 3); + assert(r->second == 3); + + r = m.insert(m.end(), {3, MoveOnly(3)}); + assert(r == prev(m.end())); + assert(m.size() == 3); + assert(r->first == 3); + assert(r->second == 3); + } #endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES +#endif } diff --git a/test/std/containers/associative/map/map.modifiers/insert_rv.pass.cpp b/test/std/containers/associative/map/map.modifiers/insert_rv.pass.cpp index a9d3277e6d94..23eb84d687ff 100644 --- a/test/std/containers/associative/map/map.modifiers/insert_rv.pass.cpp +++ b/test/std/containers/associative/map/map.modifiers/insert_rv.pass.cpp @@ -11,6 +11,7 @@ // class map +// pair<iterator, bool> insert( value_type&& v); // C++17 and later // template <class P> // pair<iterator, bool> insert(P&& p); @@ -19,6 +20,7 @@ #include "MoveOnly.h" #include "min_allocator.h" +#include "test_macros.h" int main() { @@ -55,7 +57,7 @@ int main() assert(r.first->first == 3); assert(r.first->second == 3); } -#if __cplusplus >= 201103L +#if TEST_STD_VER >= 11 { typedef std::map<int, MoveOnly, std::less<int>, min_allocator<std::pair<const int, MoveOnly>>> M; typedef std::pair<M::iterator, bool> R; @@ -89,5 +91,39 @@ int main() assert(r.first->second == 3); } #endif +#if TEST_STD_VER > 14 + { + typedef std::map<int, MoveOnly> M; + typedef std::pair<M::iterator, bool> R; + M m; + R r = m.insert({2, MoveOnly(2)}); + assert(r.second); + assert(r.first == m.begin()); + assert(m.size() == 1); + assert(r.first->first == 2); + assert(r.first->second == 2); + + r = m.insert({1, MoveOnly(1)}); + assert(r.second); + assert(r.first == m.begin()); + assert(m.size() == 2); + assert(r.first->first == 1); + assert(r.first->second == 1); + + r = m.insert({3, MoveOnly(3)}); + assert(r.second); + assert(r.first == prev(m.end())); + assert(m.size() == 3); + assert(r.first->first == 3); + assert(r.first->second == 3); + + r = m.insert({3, MoveOnly(3)}); + assert(!r.second); + assert(r.first == prev(m.end())); + assert(m.size() == 3); + assert(r.first->first == 3); + assert(r.first->second == 3); + } +#endif #endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES } |