diff options
author | Marshall Clow <mclow.lists@gmail.com> | 2014-02-08 04:03:14 +0000 |
---|---|---|
committer | Marshall Clow <mclow.lists@gmail.com> | 2014-02-08 04:03:14 +0000 |
commit | 74cf6ff5e523fa972af797a7a05f9d9b3dddfb5a (patch) | |
tree | 0257a93fc4a9ee7911e7fa76aa482475b5a887ae /libcxx/test | |
parent | 57420b320cd989b49e6a458b129b3262834ad589 (diff) | |
download | bcm5719-llvm-74cf6ff5e523fa972af797a7a05f9d9b3dddfb5a.tar.gz bcm5719-llvm-74cf6ff5e523fa972af797a7a05f9d9b3dddfb5a.zip |
Fix for PR18735 - self-assignment for map/multimap gives incorrect results in C++03
llvm-svn: 201021
Diffstat (limited to 'libcxx/test')
8 files changed, 143 insertions, 0 deletions
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 ac05e291067..a1bcb30f429 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 @@ -59,6 +59,21 @@ int main() } { typedef std::pair<const int, double> V; + const V ar[] = + { + V(1, 1), + V(2, 1), + V(3, 1), + }; + std::map<int, double> m(ar, ar+sizeof(ar)/sizeof(ar[0])); + std::map<int, double> *p = &m; + m = *p; + + assert(m.size() == 3); + assert(std::equal(m.begin(), m.end(), ar)); + } + { + typedef std::pair<const int, double> V; V ar[] = { V(1, 1), diff --git a/libcxx/test/containers/associative/multimap/multimap.cons/copy_assign.pass.cpp b/libcxx/test/containers/associative/multimap/multimap.cons/copy_assign.pass.cpp index f00f0fed166..2bdc4d6a70a 100644 --- a/libcxx/test/containers/associative/multimap/multimap.cons/copy_assign.pass.cpp +++ b/libcxx/test/containers/associative/multimap/multimap.cons/copy_assign.pass.cpp @@ -50,6 +50,26 @@ int main() } { typedef std::pair<const int, double> V; + const 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::multimap<int, double> m(ar, ar+sizeof(ar)/sizeof(ar[0])); + std::multimap<int, double> *p = &m; + m = *p; + assert(m.size() == sizeof(ar)/sizeof(ar[0])); + assert(std::equal(m.begin(), m.end(), ar)); + } + { + typedef std::pair<const int, double> V; V ar[] = { V(1, 1), diff --git a/libcxx/test/containers/associative/multiset/multiset.cons/copy_assign.pass.cpp b/libcxx/test/containers/associative/multiset/multiset.cons/copy_assign.pass.cpp index 19bdd713e9f..cca636325ff 100644 --- a/libcxx/test/containers/associative/multiset/multiset.cons/copy_assign.pass.cpp +++ b/libcxx/test/containers/associative/multiset/multiset.cons/copy_assign.pass.cpp @@ -70,6 +70,26 @@ int main() } { typedef int V; + const V ar[] = + { + 1, + 1, + 1, + 2, + 2, + 2, + 3, + 3, + 3 + }; + std::multiset<int> m(ar, ar+sizeof(ar)/sizeof(ar[0])); + std::multiset<int> *p = &m; + m = *p; + assert(m.size() == 9); + assert(std::equal(m.begin(), m.end(), ar)); + } + { + typedef int V; V ar[] = { 1, diff --git a/libcxx/test/containers/associative/set/set.cons/copy_assign.pass.cpp b/libcxx/test/containers/associative/set/set.cons/copy_assign.pass.cpp index ae83eb3c9f8..7f0f0447625 100644 --- a/libcxx/test/containers/associative/set/set.cons/copy_assign.pass.cpp +++ b/libcxx/test/containers/associative/set/set.cons/copy_assign.pass.cpp @@ -58,6 +58,21 @@ int main() } { typedef int V; + const V ar[] = + { + 1, + 2, + 3 + }; + std::set<int> m(ar, ar+sizeof(ar)/sizeof(ar[0])); + std::set<int> *p = &m; + m = *p; + + assert(m.size() == 3); + assert(std::equal(m.begin(), m.end(), ar)); + } + { + typedef int V; V ar[] = { 1, diff --git a/libcxx/test/containers/unord/unord.map/unord.map.cnstr/assign_copy.pass.cpp b/libcxx/test/containers/unord/unord.map/unord.map.cnstr/assign_copy.pass.cpp index 928377b3a04..622ce5061c1 100644 --- a/libcxx/test/containers/unord/unord.map/unord.map.cnstr/assign_copy.pass.cpp +++ b/libcxx/test/containers/unord/unord.map/unord.map.cnstr/assign_copy.pass.cpp @@ -73,6 +73,24 @@ int main() assert(c.max_load_factor() == 1); } { + typedef std::unordered_map<int, std::string> C; + typedef std::pair<const int, std::string> P; + const P a[] = + { + P(1, "one"), + P(2, "two"), + P(3, "three"), + P(4, "four"), + P(1, "four"), + P(2, "four"), + }; + C c(a, a + sizeof(a)/sizeof(a[0])); + C *p = &c; + c = *p; + assert(c.size() == 4); + assert(std::is_permutation(c.begin(), c.end(), a)); + } + { typedef other_allocator<std::pair<const int, std::string> > A; typedef std::unordered_map<int, std::string, test_hash<std::hash<int> >, diff --git a/libcxx/test/containers/unord/unord.multimap/unord.multimap.cnstr/assign_copy.pass.cpp b/libcxx/test/containers/unord/unord.multimap/unord.multimap.cnstr/assign_copy.pass.cpp index 4f47c781e4b..df566b396f9 100644 --- a/libcxx/test/containers/unord/unord.multimap/unord.multimap.cnstr/assign_copy.pass.cpp +++ b/libcxx/test/containers/unord/unord.multimap/unord.multimap.cnstr/assign_copy.pass.cpp @@ -87,6 +87,24 @@ int main() assert(c.max_load_factor() == 1); } { + typedef std::unordered_multimap<int, std::string> C; + typedef std::pair<const int, std::string> P; + const P a[] = + { + P(1, "one"), + P(2, "two"), + P(3, "three"), + P(4, "four"), + P(1, "four"), + P(2, "four"), + }; + C c(a, a+sizeof(a)/sizeof(a[0])); + C *p = &c; + c = *p; + assert(c.size() == 6); + assert(std::is_permutation(c.begin(), c.end(), a)); + } + { typedef other_allocator<std::pair<const int, std::string> > A; typedef std::unordered_multimap<int, std::string, test_hash<std::hash<int> >, diff --git a/libcxx/test/containers/unord/unord.multiset/unord.multiset.cnstr/assign_copy.pass.cpp b/libcxx/test/containers/unord/unord.multiset/unord.multiset.cnstr/assign_copy.pass.cpp index f63499485c6..2042f69fd77 100644 --- a/libcxx/test/containers/unord/unord.multiset/unord.multiset.cnstr/assign_copy.pass.cpp +++ b/libcxx/test/containers/unord/unord.multiset/unord.multiset.cnstr/assign_copy.pass.cpp @@ -80,6 +80,25 @@ int main() assert(c.max_load_factor() == 1); } { + typedef std::unordered_multiset<int> C; + typedef int P; + P a[] = + { + P(1), + P(2), + P(3), + P(4), + P(1), + P(2) + }; + C c(a, a + sizeof(a)/sizeof(a[0])); + C *p = &c; + c = *p; + + assert(c.size() == 6); + assert(std::is_permutation(c.begin(), c.end(), a)); + } + { typedef other_allocator<int> A; typedef std::unordered_multiset<int, test_hash<std::hash<int> >, diff --git a/libcxx/test/containers/unord/unord.set/unord.set.cnstr/assign_copy.pass.cpp b/libcxx/test/containers/unord/unord.set/unord.set.cnstr/assign_copy.pass.cpp index a1f8c488200..6925e304541 100644 --- a/libcxx/test/containers/unord/unord.set/unord.set.cnstr/assign_copy.pass.cpp +++ b/libcxx/test/containers/unord/unord.set/unord.set.cnstr/assign_copy.pass.cpp @@ -72,6 +72,24 @@ int main() assert(c.max_load_factor() == 1); } { + typedef std::unordered_set<int> C; + typedef int P; + P a[] = + { + P(1), + P(2), + P(3), + P(4), + P(1), + P(2) + }; + C c(a, a + sizeof(a)/sizeof(a[0])); + C *p = &c; + c = *p; + assert(c.size() == 4); + assert(std::is_permutation(c.begin(), c.end(), a)); + } + { typedef other_allocator<int> A; typedef std::unordered_set<int, test_hash<std::hash<int> >, |