diff options
author | Marshall Clow <mclow.lists@gmail.com> | 2016-08-17 05:58:40 +0000 |
---|---|---|
committer | Marshall Clow <mclow.lists@gmail.com> | 2016-08-17 05:58:40 +0000 |
commit | 2a10c960fa33b7048b48107823f5879cf301dece (patch) | |
tree | 055ff7b53c98af2ffcc7abc42a03e4aa1b42f502 /libcxx/test/std/containers/associative/multimap | |
parent | 14f383e9c4b776d415cbc66902d8492dbcc0c0e1 (diff) | |
download | bcm5719-llvm-2a10c960fa33b7048b48107823f5879cf301dece.tar.gz bcm5719-llvm-2a10c960fa33b7048b48107823f5879cf301dece.zip |
Support allocators with explicit conversion constructors. Fixes bug #29000
llvm-svn: 278904
Diffstat (limited to 'libcxx/test/std/containers/associative/multimap')
7 files changed, 161 insertions, 1 deletions
diff --git a/libcxx/test/std/containers/associative/multimap/multimap.cons/alloc.pass.cpp b/libcxx/test/std/containers/associative/multimap/multimap.cons/alloc.pass.cpp index 69660fcd277..40930f0c9c1 100644 --- a/libcxx/test/std/containers/associative/multimap/multimap.cons/alloc.pass.cpp +++ b/libcxx/test/std/containers/associative/multimap/multimap.cons/alloc.pass.cpp @@ -38,5 +38,13 @@ int main() assert(m.begin() == m.end()); assert(m.get_allocator() == A()); } + { + typedef std::less<int> C; + typedef explicit_allocator<std::pair<const int, double> > A; + std::multimap<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/std/containers/associative/multimap/multimap.cons/compare_alloc.pass.cpp b/libcxx/test/std/containers/associative/multimap/multimap.cons/compare_alloc.pass.cpp index 83653289249..fc6cef89f90 100644 --- a/libcxx/test/std/containers/associative/multimap/multimap.cons/compare_alloc.pass.cpp +++ b/libcxx/test/std/containers/associative/multimap/multimap.cons/compare_alloc.pass.cpp @@ -41,5 +41,14 @@ int main() assert(m.key_comp() == C(4)); assert(m.get_allocator() == A()); } + { + typedef test_compare<std::less<int> > C; + typedef explicit_allocator<std::pair<const int, double> > A; + std::multimap<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/std/containers/associative/multimap/multimap.cons/copy_alloc.pass.cpp b/libcxx/test/std/containers/associative/multimap/multimap.cons/copy_alloc.pass.cpp index 46b9459cad2..cccebfb5484 100644 --- a/libcxx/test/std/containers/associative/multimap/multimap.cons/copy_alloc.pass.cpp +++ b/libcxx/test/std/containers/associative/multimap/multimap.cons/copy_alloc.pass.cpp @@ -73,5 +73,30 @@ int main() assert(mo.get_allocator() == A()); assert(mo.key_comp() == C(5)); } + { + 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 explicit_allocator<V> A; + std::multimap<int, double, C, A> mo(ar, ar+sizeof(ar)/sizeof(ar[0]), C(5), A{}); + std::multimap<int, double, C, A> m(mo, A{}); + assert(m == mo); + assert(m.get_allocator() == A{}); + assert(m.key_comp() == C(5)); + + assert(mo.get_allocator() == A{}); + assert(mo.key_comp() == C(5)); + } #endif } diff --git a/libcxx/test/std/containers/associative/multimap/multimap.cons/default.pass.cpp b/libcxx/test/std/containers/associative/multimap/multimap.cons/default.pass.cpp index d39cc1d0ee8..af1b22bc909 100644 --- a/libcxx/test/std/containers/associative/multimap/multimap.cons/default.pass.cpp +++ b/libcxx/test/std/containers/associative/multimap/multimap.cons/default.pass.cpp @@ -32,6 +32,20 @@ int main() assert(m.begin() == m.end()); } { + typedef explicit_allocator<std::pair<const int, double>> A; + { + std::multimap<int, double, std::less<int>, A> m; + assert(m.empty()); + assert(m.begin() == m.end()); + } + { + A a; + std::multimap<int, double, std::less<int>, A> m(a); + assert(m.empty()); + assert(m.begin() == m.end()); + } + } + { std::multimap<int, double> m = {}; assert(m.empty()); assert(m.begin() == m.end()); diff --git a/libcxx/test/std/containers/associative/multimap/multimap.cons/initializer_list_compare_alloc.pass.cpp b/libcxx/test/std/containers/associative/multimap/multimap.cons/initializer_list_compare_alloc.pass.cpp index f5d3463aec4..8d12a059b89 100644 --- a/libcxx/test/std/containers/associative/multimap/multimap.cons/initializer_list_compare_alloc.pass.cpp +++ b/libcxx/test/std/containers/associative/multimap/multimap.cons/initializer_list_compare_alloc.pass.cpp @@ -92,7 +92,7 @@ int main() assert(m.key_comp() == Cmp(4)); assert(m.get_allocator() == A()); } -#if _LIBCPP_STD_VER > 11 +#if TEST_STD_VER > 11 { typedef test_compare<std::less<int> > C; typedef std::pair<const int, double> V; @@ -125,5 +125,39 @@ int main() assert(m.get_allocator() == a); } #endif + { + typedef test_compare<std::less<int> > Cmp; + typedef explicit_allocator<std::pair<const int, double> > A; + typedef std::multimap<int, double, Cmp, A> C; + typedef C::value_type V; + C m( + { + {1, 1}, + {1, 1.5}, + {1, 2}, + {2, 1}, + {2, 1.5}, + {2, 2}, + {3, 1}, + {3, 1.5}, + {3, 2} + }, + Cmp(4), A{} + ); + assert(m.size() == 9); + assert(distance(m.begin(), m.end()) == 9); + C::const_iterator i = m.cbegin(); + assert(*i == V(1, 1)); + assert(*++i == V(1, 1.5)); + assert(*++i == V(1, 2)); + assert(*++i == V(2, 1)); + assert(*++i == V(2, 1.5)); + assert(*++i == V(2, 2)); + assert(*++i == V(3, 1)); + assert(*++i == V(3, 1.5)); + assert(*++i == V(3, 2)); + assert(m.key_comp() == Cmp(4)); + assert(m.get_allocator() == A{}); + } #endif } diff --git a/libcxx/test/std/containers/associative/multimap/multimap.cons/iter_iter_comp_alloc.pass.cpp b/libcxx/test/std/containers/associative/multimap/multimap.cons/iter_iter_comp_alloc.pass.cpp index 31bf72dac96..b0e70c44475 100644 --- a/libcxx/test/std/containers/associative/multimap/multimap.cons/iter_iter_comp_alloc.pass.cpp +++ b/libcxx/test/std/containers/associative/multimap/multimap.cons/iter_iter_comp_alloc.pass.cpp @@ -87,5 +87,36 @@ int main() assert(*next(m.begin(), 7) == V(3, 1.5)); assert(*next(m.begin(), 8) == V(3, 2)); } + { + 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 explicit_allocator<V> A; + std::multimap<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() == 9); + assert(distance(m.begin(), m.end()) == 9); + assert(*m.begin() == V(1, 1)); + assert(*next(m.begin()) == V(1, 1.5)); + assert(*next(m.begin(), 2) == V(1, 2)); + assert(*next(m.begin(), 3) == V(2, 1)); + assert(*next(m.begin(), 4) == V(2, 1.5)); + assert(*next(m.begin(), 5) == V(2, 2)); + assert(*next(m.begin(), 6) == V(3, 1)); + assert(*next(m.begin(), 7) == V(3, 1.5)); + assert(*next(m.begin(), 8) == V(3, 2)); + } #endif } diff --git a/libcxx/test/std/containers/associative/multimap/multimap.cons/move_alloc.pass.cpp b/libcxx/test/std/containers/associative/multimap/multimap.cons/move_alloc.pass.cpp index 41771f62aae..6ce7127ea7c 100644 --- a/libcxx/test/std/containers/associative/multimap/multimap.cons/move_alloc.pass.cpp +++ b/libcxx/test/std/containers/associative/multimap/multimap.cons/move_alloc.pass.cpp @@ -229,6 +229,45 @@ int main() assert(m3.key_comp() == C(5)); assert(m1.empty()); } + { + typedef std::pair<MoveOnly, MoveOnly> V; + typedef std::pair<const MoveOnly, MoveOnly> VC; + typedef test_compare<std::less<MoveOnly> > C; + typedef explicit_allocator<VC> A; + typedef std::multimap<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 } |