diff options
author | Howard Hinnant <hhinnant@apple.com> | 2013-06-19 21:29:40 +0000 |
---|---|---|
committer | Howard Hinnant <hhinnant@apple.com> | 2013-06-19 21:29:40 +0000 |
commit | 07d3eccd26a600a6cad3bb6807880f46a76f269e (patch) | |
tree | 8f9a3056982d04fbb15a89146326e7a7834aabe5 /libcxx/test/containers/associative/map/map.cons | |
parent | 64f440518b3dc41da99ace80d9289bfa8d92aa15 (diff) | |
download | bcm5719-llvm-07d3eccd26a600a6cad3bb6807880f46a76f269e.tar.gz bcm5719-llvm-07d3eccd26a600a6cad3bb6807880f46a76f269e.zip |
Implement full support for non-pointer types in custom allocators. This is for the associative containers only. This work still needs to be done on the unordered and sequence containers. Fixes http://llvm.org/bugs/show_bug.cgi?id=15978
llvm-svn: 184358
Diffstat (limited to 'libcxx/test/containers/associative/map/map.cons')
18 files changed, 528 insertions, 1 deletions
diff --git a/libcxx/test/containers/associative/map/map.cons/alloc.pass.cpp b/libcxx/test/containers/associative/map/map.cons/alloc.pass.cpp index 1a77f60564c..95d71da664a 100644 --- a/libcxx/test/containers/associative/map/map.cons/alloc.pass.cpp +++ b/libcxx/test/containers/associative/map/map.cons/alloc.pass.cpp @@ -17,13 +17,26 @@ #include <cassert> #include "../../../test_allocator.h" +#include "../../../min_allocator.h" int main() { + { typedef std::less<int> C; typedef test_allocator<std::pair<const int, double> > A; std::map<int, double, C, A> m(A(5)); assert(m.empty()); assert(m.begin() == m.end()); assert(m.get_allocator() == A(5)); + } +#if __cplusplus >= 201103L + { + typedef std::less<int> C; + typedef min_allocator<std::pair<const int, double> > A; + std::map<int, double, C, A> m(A{}); + assert(m.empty()); + assert(m.begin() == m.end()); + assert(m.get_allocator() == A()); + } +#endif } diff --git a/libcxx/test/containers/associative/map/map.cons/assign_initializer_list.pass.cpp b/libcxx/test/containers/associative/map/map.cons/assign_initializer_list.pass.cpp index 2fdf5b294af..a583f0d597f 100644 --- a/libcxx/test/containers/associative/map/map.cons/assign_initializer_list.pass.cpp +++ b/libcxx/test/containers/associative/map/map.cons/assign_initializer_list.pass.cpp @@ -16,9 +16,12 @@ #include <map> #include <cassert> +#include "../../../min_allocator.h" + int main() { #ifndef _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS + { typedef std::pair<const int, double> V; std::map<int, double> m = { @@ -41,5 +44,32 @@ int main() assert(*m.begin() == V(1, 1)); assert(*next(m.begin()) == V(2, 1)); assert(*next(m.begin(), 2) == V(3, 1)); + } +#if __cplusplus >= 201103L + { + typedef std::pair<const int, double> V; + std::map<int, double, std::less<int>, min_allocator<V>> m = + { + {20, 1}, + }; + m = + { + {1, 1}, + {1, 1.5}, + {1, 2}, + {2, 1}, + {2, 1.5}, + {2, 2}, + {3, 1}, + {3, 1.5}, + {3, 2} + }; + assert(m.size() == 3); + assert(distance(m.begin(), m.end()) == 3); + assert(*m.begin() == V(1, 1)); + assert(*next(m.begin()) == V(2, 1)); + assert(*next(m.begin(), 2) == V(3, 1)); + } +#endif #endif // _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS } diff --git a/libcxx/test/containers/associative/map/map.cons/compare.pass.cpp b/libcxx/test/containers/associative/map/map.cons/compare.pass.cpp index 5648ff0fb66..2c4bb1a8cbc 100644 --- a/libcxx/test/containers/associative/map/map.cons/compare.pass.cpp +++ b/libcxx/test/containers/associative/map/map.cons/compare.pass.cpp @@ -17,12 +17,24 @@ #include <cassert> #include "../../../test_compare.h" +#include "../../../min_allocator.h" int main() { + { typedef test_compare<std::less<int> > C; std::map<int, double, C> m(C(3)); assert(m.empty()); assert(m.begin() == m.end()); assert(m.key_comp() == C(3)); + } +#if __cplusplus >= 201103L + { + typedef test_compare<std::less<int> > C; + std::map<int, double, C, min_allocator<std::pair<const int, double>>> m(C(3)); + assert(m.empty()); + assert(m.begin() == m.end()); + assert(m.key_comp() == C(3)); + } +#endif } diff --git a/libcxx/test/containers/associative/map/map.cons/compare_alloc.pass.cpp b/libcxx/test/containers/associative/map/map.cons/compare_alloc.pass.cpp index 26efa0dabc8..670acffc458 100644 --- a/libcxx/test/containers/associative/map/map.cons/compare_alloc.pass.cpp +++ b/libcxx/test/containers/associative/map/map.cons/compare_alloc.pass.cpp @@ -18,9 +18,11 @@ #include "../../../test_compare.h" #include "../../../test_allocator.h" +#include "../../../min_allocator.h" int main() { + { typedef test_compare<std::less<int> > C; typedef test_allocator<std::pair<const int, double> > A; std::map<int, double, C, A> m(C(4), A(5)); @@ -28,4 +30,16 @@ int main() assert(m.begin() == m.end()); assert(m.key_comp() == C(4)); assert(m.get_allocator() == A(5)); + } +#if __cplusplus >= 201103L + { + typedef test_compare<std::less<int> > C; + typedef min_allocator<std::pair<const int, double> > A; + std::map<int, double, C, A> m(C(4), A()); + assert(m.empty()); + assert(m.begin() == m.end()); + assert(m.key_comp() == C(4)); + assert(m.get_allocator() == A()); + } +#endif } diff --git a/libcxx/test/containers/associative/map/map.cons/copy.pass.cpp b/libcxx/test/containers/associative/map/map.cons/copy.pass.cpp index 01c0d89d5e4..ce20d69d7c9 100644 --- a/libcxx/test/containers/associative/map/map.cons/copy.pass.cpp +++ b/libcxx/test/containers/associative/map/map.cons/copy.pass.cpp @@ -18,6 +18,7 @@ #include "../../../test_compare.h" #include "../../../test_allocator.h" +#include "../../../min_allocator.h" int main() { @@ -91,4 +92,40 @@ int main() assert(*next(mo.begin(), 2) == V(3, 1)); } #endif // _LIBCPP_HAS_NO_ADVANCED_SFINAE +#if __cplusplus >= 201103L + { + typedef std::pair<const int, double> V; + V ar[] = + { + V(1, 1), + V(1, 1.5), + V(1, 2), + V(2, 1), + V(2, 1.5), + V(2, 2), + V(3, 1), + V(3, 1.5), + V(3, 2), + }; + typedef test_compare<std::less<int> > C; + typedef min_allocator<V> A; + std::map<int, double, C, A> mo(ar, ar+sizeof(ar)/sizeof(ar[0]), C(5), A()); + std::map<int, double, C, A> m = mo; + assert(m.get_allocator() == A()); + assert(m.key_comp() == C(5)); + assert(m.size() == 3); + assert(distance(m.begin(), m.end()) == 3); + assert(*m.begin() == V(1, 1)); + assert(*next(m.begin()) == V(2, 1)); + assert(*next(m.begin(), 2) == V(3, 1)); + + assert(mo.get_allocator() == A()); + assert(mo.key_comp() == C(5)); + assert(mo.size() == 3); + assert(distance(mo.begin(), mo.end()) == 3); + assert(*mo.begin() == V(1, 1)); + assert(*next(mo.begin()) == V(2, 1)); + assert(*next(mo.begin(), 2) == V(3, 1)); + } +#endif } diff --git a/libcxx/test/containers/associative/map/map.cons/copy_alloc.pass.cpp b/libcxx/test/containers/associative/map/map.cons/copy_alloc.pass.cpp index 27b1c9710cc..849240408ab 100644 --- a/libcxx/test/containers/associative/map/map.cons/copy_alloc.pass.cpp +++ b/libcxx/test/containers/associative/map/map.cons/copy_alloc.pass.cpp @@ -18,9 +18,11 @@ #include "../../../test_compare.h" #include "../../../test_allocator.h" +#include "../../../min_allocator.h" int main() { + { typedef std::pair<const int, double> V; V ar[] = { @@ -53,4 +55,41 @@ int main() assert(*mo.begin() == V(1, 1)); assert(*next(mo.begin()) == V(2, 1)); assert(*next(mo.begin(), 2) == V(3, 1)); + } +#if __cplusplus >= 201103L + { + typedef std::pair<const int, double> V; + V ar[] = + { + V(1, 1), + V(1, 1.5), + V(1, 2), + V(2, 1), + V(2, 1.5), + V(2, 2), + V(3, 1), + V(3, 1.5), + V(3, 2), + }; + typedef test_compare<std::less<int> > C; + typedef min_allocator<V> A; + std::map<int, double, C, A> mo(ar, ar+sizeof(ar)/sizeof(ar[0]), C(5), A()); + std::map<int, double, C, A> m(mo, A()); + assert(m.get_allocator() == A()); + assert(m.key_comp() == C(5)); + assert(m.size() == 3); + assert(distance(m.begin(), m.end()) == 3); + assert(*m.begin() == V(1, 1)); + assert(*next(m.begin()) == V(2, 1)); + assert(*next(m.begin(), 2) == V(3, 1)); + + assert(mo.get_allocator() == A()); + assert(mo.key_comp() == C(5)); + assert(mo.size() == 3); + assert(distance(mo.begin(), mo.end()) == 3); + assert(*mo.begin() == V(1, 1)); + assert(*next(mo.begin()) == V(2, 1)); + assert(*next(mo.begin(), 2) == V(3, 1)); + } +#endif } diff --git a/libcxx/test/containers/associative/map/map.cons/copy_assign.pass.cpp b/libcxx/test/containers/associative/map/map.cons/copy_assign.pass.cpp index 7422ec99a90..fefb35ce712 100644 --- a/libcxx/test/containers/associative/map/map.cons/copy_assign.pass.cpp +++ b/libcxx/test/containers/associative/map/map.cons/copy_assign.pass.cpp @@ -18,6 +18,7 @@ #include "../../../test_compare.h" #include "../../../test_allocator.h" +#include "../../../min_allocator.h" int main() { @@ -91,4 +92,76 @@ int main() assert(*next(mo.begin()) == V(2, 1)); assert(*next(mo.begin(), 2) == V(3, 1)); } +#if __cplusplus >= 201103L + { + typedef std::pair<const int, double> V; + V ar[] = + { + V(1, 1), + V(1, 1.5), + V(1, 2), + V(2, 1), + V(2, 1.5), + V(2, 2), + V(3, 1), + V(3, 1.5), + V(3, 2) + }; + typedef test_compare<std::less<int> > C; + typedef min_allocator<V> A; + std::map<int, double, C, A> mo(ar, ar+sizeof(ar)/sizeof(ar[0]), C(5), A()); + std::map<int, double, C, A> m(ar, ar+sizeof(ar)/sizeof(ar[0])/2, C(3), A()); + m = mo; + assert(m.get_allocator() == A()); + assert(m.key_comp() == C(5)); + assert(m.size() == 3); + assert(distance(m.begin(), m.end()) == 3); + assert(*m.begin() == V(1, 1)); + assert(*next(m.begin()) == V(2, 1)); + assert(*next(m.begin(), 2) == V(3, 1)); + + assert(mo.get_allocator() == A()); + assert(mo.key_comp() == C(5)); + assert(mo.size() == 3); + assert(distance(mo.begin(), mo.end()) == 3); + assert(*mo.begin() == V(1, 1)); + assert(*next(mo.begin()) == V(2, 1)); + assert(*next(mo.begin(), 2) == V(3, 1)); + } + { + typedef std::pair<const int, double> V; + V ar[] = + { + V(1, 1), + V(1, 1.5), + V(1, 2), + V(2, 1), + V(2, 1.5), + V(2, 2), + V(3, 1), + V(3, 1.5), + V(3, 2) + }; + typedef test_compare<std::less<int> > C; + typedef min_allocator<V> A; + std::map<int, double, C, A> mo(ar, ar+sizeof(ar)/sizeof(ar[0]), C(5), A()); + std::map<int, double, C, A> m(ar, ar+sizeof(ar)/sizeof(ar[0])/2, C(3), A()); + m = mo; + assert(m.get_allocator() == A()); + assert(m.key_comp() == C(5)); + assert(m.size() == 3); + assert(distance(m.begin(), m.end()) == 3); + assert(*m.begin() == V(1, 1)); + assert(*next(m.begin()) == V(2, 1)); + assert(*next(m.begin(), 2) == V(3, 1)); + + assert(mo.get_allocator() == A()); + assert(mo.key_comp() == C(5)); + assert(mo.size() == 3); + assert(distance(mo.begin(), mo.end()) == 3); + assert(*mo.begin() == V(1, 1)); + assert(*next(mo.begin()) == V(2, 1)); + assert(*next(mo.begin(), 2) == V(3, 1)); + } +#endif } diff --git a/libcxx/test/containers/associative/map/map.cons/default.pass.cpp b/libcxx/test/containers/associative/map/map.cons/default.pass.cpp index 8b5397c3def..49fc223ffad 100644 --- a/libcxx/test/containers/associative/map/map.cons/default.pass.cpp +++ b/libcxx/test/containers/associative/map/map.cons/default.pass.cpp @@ -16,9 +16,20 @@ #include <map> #include <cassert> +#include "../../../min_allocator.h" + int main() { + { std::map<int, double> m; assert(m.empty()); assert(m.begin() == m.end()); + } +#if __cplusplus >= 201103L + { + std::map<int, double, std::less<int>, min_allocator<std::pair<const int, double>>> m; + assert(m.empty()); + assert(m.begin() == m.end()); + } +#endif } diff --git a/libcxx/test/containers/associative/map/map.cons/default_recursive.pass.cpp b/libcxx/test/containers/associative/map/map.cons/default_recursive.pass.cpp index 452746c87bb..8b393d3c91c 100644 --- a/libcxx/test/containers/associative/map/map.cons/default_recursive.pass.cpp +++ b/libcxx/test/containers/associative/map/map.cons/default_recursive.pass.cpp @@ -19,7 +19,7 @@ struct X { - std::multimap<int, X> m; + std::map<int, X> m; }; #endif diff --git a/libcxx/test/containers/associative/map/map.cons/initializer_list.pass.cpp b/libcxx/test/containers/associative/map/map.cons/initializer_list.pass.cpp index 4acf2dcab51..63820beea13 100644 --- a/libcxx/test/containers/associative/map/map.cons/initializer_list.pass.cpp +++ b/libcxx/test/containers/associative/map/map.cons/initializer_list.pass.cpp @@ -16,9 +16,12 @@ #include <map> #include <cassert> +#include "../../../min_allocator.h" + int main() { #ifndef _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS + { typedef std::pair<const int, double> V; std::map<int, double> m = { @@ -37,5 +40,28 @@ int main() assert(*m.begin() == V(1, 1)); assert(*next(m.begin()) == V(2, 1)); assert(*next(m.begin(), 2) == V(3, 1)); + } +#if __cplusplus >= 201103L + { + typedef std::pair<const int, double> V; + std::map<int, double, std::less<int>, min_allocator<V>> m = + { + {1, 1}, + {1, 1.5}, + {1, 2}, + {2, 1}, + {2, 1.5}, + {2, 2}, + {3, 1}, + {3, 1.5}, + {3, 2} + }; + assert(m.size() == 3); + assert(distance(m.begin(), m.end()) == 3); + assert(*m.begin() == V(1, 1)); + assert(*next(m.begin()) == V(2, 1)); + assert(*next(m.begin(), 2) == V(3, 1)); + } +#endif #endif // _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS } diff --git a/libcxx/test/containers/associative/map/map.cons/initializer_list_compare.pass.cpp b/libcxx/test/containers/associative/map/map.cons/initializer_list_compare.pass.cpp index 723a03f49d9..0c3bd23a635 100644 --- a/libcxx/test/containers/associative/map/map.cons/initializer_list_compare.pass.cpp +++ b/libcxx/test/containers/associative/map/map.cons/initializer_list_compare.pass.cpp @@ -16,10 +16,12 @@ #include <map> #include <cassert> #include "../../../test_compare.h" +#include "../../../min_allocator.h" int main() { #ifndef _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS + { typedef std::pair<const int, double> V; typedef test_compare<std::less<int> > C; std::map<int, double, C> m({ @@ -39,5 +41,29 @@ int main() assert(*next(m.begin()) == V(2, 1)); assert(*next(m.begin(), 2) == V(3, 1)); assert(m.key_comp() == C(3)); + } +#if __cplusplus >= 201103L + { + typedef std::pair<const int, double> V; + typedef test_compare<std::less<int> > C; + std::map<int, double, C, min_allocator<std::pair<const int, double>>> m({ + {1, 1}, + {1, 1.5}, + {1, 2}, + {2, 1}, + {2, 1.5}, + {2, 2}, + {3, 1}, + {3, 1.5}, + {3, 2} + }, C(3)); + assert(m.size() == 3); + assert(distance(m.begin(), m.end()) == 3); + assert(*m.begin() == V(1, 1)); + assert(*next(m.begin()) == V(2, 1)); + assert(*next(m.begin(), 2) == V(3, 1)); + assert(m.key_comp() == C(3)); + } +#endif #endif // _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS } diff --git a/libcxx/test/containers/associative/map/map.cons/initializer_list_compare_alloc.pass.cpp b/libcxx/test/containers/associative/map/map.cons/initializer_list_compare_alloc.pass.cpp index f6300de20b9..14e0eb3d4f7 100644 --- a/libcxx/test/containers/associative/map/map.cons/initializer_list_compare_alloc.pass.cpp +++ b/libcxx/test/containers/associative/map/map.cons/initializer_list_compare_alloc.pass.cpp @@ -17,10 +17,12 @@ #include <cassert> #include "../../../test_compare.h" #include "../../../test_allocator.h" +#include "../../../min_allocator.h" int main() { #ifndef _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS + { typedef std::pair<const int, double> V; typedef test_compare<std::less<int> > C; typedef test_allocator<std::pair<const int, double> > A; @@ -42,5 +44,31 @@ int main() assert(*next(m.begin(), 2) == V(3, 1)); assert(m.key_comp() == C(3)); assert(m.get_allocator() == A(6)); + } +#if __cplusplus >= 201103L + { + typedef std::pair<const int, double> V; + typedef test_compare<std::less<int> > C; + typedef min_allocator<std::pair<const int, double> > A; + std::map<int, double, C, A> m({ + {1, 1}, + {1, 1.5}, + {1, 2}, + {2, 1}, + {2, 1.5}, + {2, 2}, + {3, 1}, + {3, 1.5}, + {3, 2} + }, C(3), A()); + assert(m.size() == 3); + assert(distance(m.begin(), m.end()) == 3); + assert(*m.begin() == V(1, 1)); + assert(*next(m.begin()) == V(2, 1)); + assert(*next(m.begin(), 2) == V(3, 1)); + assert(m.key_comp() == C(3)); + assert(m.get_allocator() == A()); + } +#endif #endif // _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS } diff --git a/libcxx/test/containers/associative/map/map.cons/iter_iter.pass.cpp b/libcxx/test/containers/associative/map/map.cons/iter_iter.pass.cpp index 00d3d8a2766..d981ccff889 100644 --- a/libcxx/test/containers/associative/map/map.cons/iter_iter.pass.cpp +++ b/libcxx/test/containers/associative/map/map.cons/iter_iter.pass.cpp @@ -17,8 +17,11 @@ #include <map> #include <cassert> +#include "../../../min_allocator.h" + int main() { + { typedef std::pair<const int, double> V; V ar[] = { @@ -38,4 +41,28 @@ int main() assert(*m.begin() == V(1, 1)); assert(*next(m.begin()) == V(2, 1)); assert(*next(m.begin(), 2) == V(3, 1)); + } +#if __cplusplus >= 201103L + { + typedef std::pair<const int, double> V; + V ar[] = + { + V(1, 1), + V(1, 1.5), + V(1, 2), + V(2, 1), + V(2, 1.5), + V(2, 2), + V(3, 1), + V(3, 1.5), + V(3, 2), + }; + std::map<int, double, std::less<int>, min_allocator<std::pair<const int, double>>> m(ar, ar+sizeof(ar)/sizeof(ar[0])); + assert(m.size() == 3); + assert(distance(m.begin(), m.end()) == 3); + assert(*m.begin() == V(1, 1)); + assert(*next(m.begin()) == V(2, 1)); + assert(*next(m.begin(), 2) == V(3, 1)); + } +#endif } diff --git a/libcxx/test/containers/associative/map/map.cons/iter_iter_comp.pass.cpp b/libcxx/test/containers/associative/map/map.cons/iter_iter_comp.pass.cpp index 6f851931ce9..0481de24ccd 100644 --- a/libcxx/test/containers/associative/map/map.cons/iter_iter_comp.pass.cpp +++ b/libcxx/test/containers/associative/map/map.cons/iter_iter_comp.pass.cpp @@ -18,9 +18,11 @@ #include <cassert> #include "../../../test_compare.h" +#include "../../../min_allocator.h" int main() { + { typedef std::pair<const int, double> V; V ar[] = { @@ -42,4 +44,30 @@ int main() assert(*m.begin() == V(1, 1)); assert(*next(m.begin()) == V(2, 1)); assert(*next(m.begin(), 2) == V(3, 1)); + } +#if __cplusplus >= 201103L + { + typedef std::pair<const int, double> V; + V ar[] = + { + V(1, 1), + V(1, 1.5), + V(1, 2), + V(2, 1), + V(2, 1.5), + V(2, 2), + V(3, 1), + V(3, 1.5), + V(3, 2), + }; + typedef test_compare<std::less<int> > C; + std::map<int, double, C, min_allocator<std::pair<const int, double>>> m(ar, ar+sizeof(ar)/sizeof(ar[0]), C(5)); + assert(m.key_comp() == C(5)); + assert(m.size() == 3); + assert(distance(m.begin(), m.end()) == 3); + assert(*m.begin() == V(1, 1)); + assert(*next(m.begin()) == V(2, 1)); + assert(*next(m.begin(), 2) == V(3, 1)); + } +#endif } diff --git a/libcxx/test/containers/associative/map/map.cons/iter_iter_comp_alloc.pass.cpp b/libcxx/test/containers/associative/map/map.cons/iter_iter_comp_alloc.pass.cpp index abee6d9f0b0..8fabdcc087d 100644 --- a/libcxx/test/containers/associative/map/map.cons/iter_iter_comp_alloc.pass.cpp +++ b/libcxx/test/containers/associative/map/map.cons/iter_iter_comp_alloc.pass.cpp @@ -20,9 +20,11 @@ #include "../../../test_compare.h" #include "../../../test_allocator.h" +#include "../../../min_allocator.h" int main() { + { typedef std::pair<const int, double> V; V ar[] = { @@ -46,4 +48,32 @@ int main() assert(*m.begin() == V(1, 1)); assert(*next(m.begin()) == V(2, 1)); assert(*next(m.begin(), 2) == V(3, 1)); + } +#if __cplusplus >= 201103L + { + typedef std::pair<const int, double> V; + V ar[] = + { + V(1, 1), + V(1, 1.5), + V(1, 2), + V(2, 1), + V(2, 1.5), + V(2, 2), + V(3, 1), + V(3, 1.5), + V(3, 2), + }; + typedef test_compare<std::less<int> > C; + typedef min_allocator<V> A; + std::map<int, double, C, A> m(ar, ar+sizeof(ar)/sizeof(ar[0]), C(5), A()); + assert(m.get_allocator() == A()); + assert(m.key_comp() == C(5)); + assert(m.size() == 3); + assert(distance(m.begin(), m.end()) == 3); + assert(*m.begin() == V(1, 1)); + assert(*next(m.begin()) == V(2, 1)); + assert(*next(m.begin(), 2) == V(3, 1)); + } +#endif } diff --git a/libcxx/test/containers/associative/map/map.cons/move.pass.cpp b/libcxx/test/containers/associative/map/map.cons/move.pass.cpp index b86dd6e382c..323a26548e9 100644 --- a/libcxx/test/containers/associative/map/map.cons/move.pass.cpp +++ b/libcxx/test/containers/associative/map/map.cons/move.pass.cpp @@ -18,6 +18,7 @@ #include "../../../test_compare.h" #include "../../../test_allocator.h" +#include "../../../min_allocator.h" int main() { @@ -68,5 +69,52 @@ int main() assert(mo.size() == 0); assert(distance(mo.begin(), mo.end()) == 0); } +#if __cplusplus >= 201103L + { + typedef test_compare<std::less<int> > C; + typedef min_allocator<V> A; + std::map<int, double, C, A> mo(C(5), A()); + std::map<int, double, C, A> m = std::move(mo); + assert(m.get_allocator() == A()); + assert(m.key_comp() == C(5)); + assert(m.size() == 0); + assert(distance(m.begin(), m.end()) == 0); + + assert(mo.get_allocator() == A()); + assert(mo.key_comp() == C(5)); + assert(mo.size() == 0); + assert(distance(mo.begin(), mo.end()) == 0); + } + { + V ar[] = + { + V(1, 1), + V(1, 1.5), + V(1, 2), + V(2, 1), + V(2, 1.5), + V(2, 2), + V(3, 1), + V(3, 1.5), + V(3, 2), + }; + typedef test_compare<std::less<int> > C; + typedef min_allocator<V> A; + std::map<int, double, C, A> mo(ar, ar+sizeof(ar)/sizeof(ar[0]), C(5), A()); + std::map<int, double, C, A> m = std::move(mo); + assert(m.get_allocator() == A()); + assert(m.key_comp() == C(5)); + assert(m.size() == 3); + assert(distance(m.begin(), m.end()) == 3); + assert(*m.begin() == V(1, 1)); + assert(*next(m.begin()) == V(2, 1)); + assert(*next(m.begin(), 2) == V(3, 1)); + + assert(mo.get_allocator() == A()); + assert(mo.key_comp() == C(5)); + assert(mo.size() == 0); + assert(distance(mo.begin(), mo.end()) == 0); + } +#endif #endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES } diff --git a/libcxx/test/containers/associative/map/map.cons/move_alloc.pass.cpp b/libcxx/test/containers/associative/map/map.cons/move_alloc.pass.cpp index c9675dbd645..2bb2c061258 100644 --- a/libcxx/test/containers/associative/map/map.cons/move_alloc.pass.cpp +++ b/libcxx/test/containers/associative/map/map.cons/move_alloc.pass.cpp @@ -19,6 +19,7 @@ #include "../../../MoveOnly.h" #include "../../../test_compare.h" #include "../../../test_allocator.h" +#include "../../../min_allocator.h" int main() { @@ -140,5 +141,46 @@ int main() assert(m3.key_comp() == C(5)); assert(m1.empty()); } +#if __cplusplus >= 201103L + { + typedef std::pair<MoveOnly, MoveOnly> V; + typedef std::pair<const MoveOnly, MoveOnly> VC; + typedef test_compare<std::less<MoveOnly> > C; + typedef min_allocator<VC> A; + typedef std::map<MoveOnly, MoveOnly, C, A> M; + typedef std::move_iterator<V*> I; + V a1[] = + { + V(1, 1), + V(1, 2), + V(1, 3), + V(2, 1), + V(2, 2), + V(2, 3), + V(3, 1), + V(3, 2), + V(3, 3) + }; + M m1(I(a1), I(a1+sizeof(a1)/sizeof(a1[0])), C(5), A()); + V a2[] = + { + V(1, 1), + V(1, 2), + V(1, 3), + V(2, 1), + V(2, 2), + V(2, 3), + V(3, 1), + V(3, 2), + V(3, 3) + }; + M m2(I(a2), I(a2+sizeof(a2)/sizeof(a2[0])), C(5), A()); + M m3(std::move(m1), A()); + assert(m3 == m2); + assert(m3.get_allocator() == A()); + assert(m3.key_comp() == C(5)); + assert(m1.empty()); + } +#endif #endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES } diff --git a/libcxx/test/containers/associative/map/map.cons/move_assign.pass.cpp b/libcxx/test/containers/associative/map/map.cons/move_assign.pass.cpp index e8b9a88d97e..2e6ede7bec7 100644 --- a/libcxx/test/containers/associative/map/map.cons/move_assign.pass.cpp +++ b/libcxx/test/containers/associative/map/map.cons/move_assign.pass.cpp @@ -19,6 +19,7 @@ #include "../../../MoveOnly.h" #include "../../../test_compare.h" #include "../../../test_allocator.h" +#include "../../../min_allocator.h" int main() { @@ -143,5 +144,47 @@ int main() assert(m3.key_comp() == C(5)); assert(m1.empty()); } +#if __cplusplus >= 201103L + { + typedef std::pair<MoveOnly, MoveOnly> V; + typedef std::pair<const MoveOnly, MoveOnly> VC; + typedef test_compare<std::less<MoveOnly> > C; + typedef min_allocator<VC> A; + typedef std::map<MoveOnly, MoveOnly, C, A> M; + typedef std::move_iterator<V*> I; + V a1[] = + { + V(1, 1), + V(1, 2), + V(1, 3), + V(2, 1), + V(2, 2), + V(2, 3), + V(3, 1), + V(3, 2), + V(3, 3) + }; + M m1(I(a1), I(a1+sizeof(a1)/sizeof(a1[0])), C(5), A()); + V a2[] = + { + V(1, 1), + V(1, 2), + V(1, 3), + V(2, 1), + V(2, 2), + V(2, 3), + V(3, 1), + V(3, 2), + V(3, 3) + }; + M m2(I(a2), I(a2+sizeof(a2)/sizeof(a2[0])), C(5), A()); + M m3(C(3), A()); + m3 = std::move(m1); + assert(m3 == m2); + assert(m3.get_allocator() == A()); + assert(m3.key_comp() == C(5)); + assert(m1.empty()); + } +#endif #endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES } |