diff options
| author | Mingming Liu <mingmingl@google.com> | 2025-09-10 15:25:31 -0700 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2025-09-10 15:25:31 -0700 |
| commit | 1417dafa1db9cb1b2b09438aa9f53ea5ab6e36e2 (patch) | |
| tree | 57f4b1f313c8cf74eed8819870f39c36ea263c68 /libcxx/test/std/containers | |
| parent | 898b813bc8a6d0276bf0f4769f5f2f64b34e632d (diff) | |
| parent | b8cefcb601ddaa18482555c4ff363c01a270c2fe (diff) | |
Merge branch 'main' into users/mingmingl-llvm/samplefdo-profile-formatusers/mingmingl-llvm/samplefdo-profile-format
Diffstat (limited to 'libcxx/test/std/containers')
32 files changed, 430 insertions, 122 deletions
diff --git a/libcxx/test/std/containers/associative/map/map.cons/copy_assign.pass.cpp b/libcxx/test/std/containers/associative/map/map.cons/copy_assign.pass.cpp index e01a10b679ac..56c6cdd7e1e9 100644 --- a/libcxx/test/std/containers/associative/map/map.cons/copy_assign.pass.cpp +++ b/libcxx/test/std/containers/associative/map/map.cons/copy_assign.pass.cpp @@ -70,7 +70,7 @@ template <class Alloc, class AllocatorInvariant = NoOp> void test_alloc(const Alloc& lhs_alloc = Alloc(), const Alloc& rhs_alloc = Alloc(), AllocatorInvariant check_alloc_invariant = NoOp()) { - { // Test empty/non-empy map combinations + { // Test empty/non-empty map combinations { // assign from a non-empty container into an empty one using V = std::pair<const int, int>; using Map = std::map<int, int, std::less<int>, Alloc>; @@ -225,7 +225,7 @@ void test_alloc(const Alloc& lhs_alloc = Alloc(), } check_alloc_invariant(); } - { // Make a somewhat larget set to exercise the algorithm a bit + { // Make a somewhat larger set to exercise the algorithm a bit using V = std::pair<const int, int>; using Map = std::map<int, int, std::less<int>, Alloc>; diff --git a/libcxx/test/std/containers/associative/map/map.modifiers/insert_iter_iter.pass.cpp b/libcxx/test/std/containers/associative/map/map.modifiers/insert_iter_iter.pass.cpp index 0baff65f6193..dfbeb33698e6 100644 --- a/libcxx/test/std/containers/associative/map/map.modifiers/insert_iter_iter.pass.cpp +++ b/libcxx/test/std/containers/associative/map/map.modifiers/insert_iter_iter.pass.cpp @@ -13,64 +13,188 @@ // template <class InputIterator> // void insert(InputIterator first, InputIterator last); -#include <map> +#include <array> #include <cassert> +#include <map> -#include "test_macros.h" #include "test_iterators.h" #include "min_allocator.h" -int main(int, char**) { - { - typedef std::map<int, double> M; - typedef std::pair<int, double> P; - P ar[] = { - P(1, 1), - P(1, 1.5), - P(1, 2), - P(2, 1), - P(2, 1.5), - P(2, 2), - P(3, 1), - P(3, 1.5), - P(3, 2), - }; - M m; - m.insert(cpp17_input_iterator<P*>(ar), cpp17_input_iterator<P*>(ar + sizeof(ar) / sizeof(ar[0]))); - assert(m.size() == 3); - assert(m.begin()->first == 1); - assert(m.begin()->second == 1); - assert(std::next(m.begin())->first == 2); - assert(std::next(m.begin())->second == 1); - assert(std::next(m.begin(), 2)->first == 3); - assert(std::next(m.begin(), 2)->second == 1); +template <class Iter, class Alloc> +void test_alloc() { + { // Check that an empty range works correctly + { // Without elements in the container + using Map = std::map<int, int, std::less<int>, Alloc>; + + std::array<std::pair<const int, int>, 0> arr; + + Map map; + map.insert(Iter(arr.data()), Iter(arr.data() + arr.size())); + assert(map.size() == 0); + assert(map.begin() == map.end()); + } + { // With 1 element in the container + using Map = std::map<int, int, std::less<int>, Alloc>; + using Pair = std::pair<const int, int>; + + std::array<Pair, 0> arr; + + Map map; + map.insert(Pair(0, 0)); + map.insert(Iter(arr.data()), Iter(arr.data() + arr.size())); + assert(map.size() == 1); + assert(*std::next(map.begin(), 0) == Pair(0, 0)); + assert(std::next(map.begin(), 1) == map.end()); + } + { // With multiple elements in the container + using Map = std::map<int, int, std::less<int>, Alloc>; + using Pair = std::pair<const int, int>; + + std::array<Pair, 0> arr; + + Map map; + map.insert(Pair(0, 0)); + map.insert(Pair(1, 1)); + map.insert(Pair(2, 2)); + map.insert(Iter(arr.data()), Iter(arr.data() + arr.size())); + assert(map.size() == 3); + assert(*std::next(map.begin(), 0) == Pair(0, 0)); + assert(*std::next(map.begin(), 1) == Pair(1, 1)); + assert(*std::next(map.begin(), 2) == Pair(2, 2)); + assert(std::next(map.begin(), 3) == map.end()); + } } -#if TEST_STD_VER >= 11 - { - typedef std::map<int, double, std::less<int>, min_allocator<std::pair<const int, double>>> M; - typedef std::pair<int, double> P; - P ar[] = { - P(1, 1), - P(1, 1.5), - P(1, 2), - P(2, 1), - P(2, 1.5), - P(2, 2), - P(3, 1), - P(3, 1.5), - P(3, 2), - }; - M m; - m.insert(cpp17_input_iterator<P*>(ar), cpp17_input_iterator<P*>(ar + sizeof(ar) / sizeof(ar[0]))); - assert(m.size() == 3); - assert(m.begin()->first == 1); - assert(m.begin()->second == 1); - assert(std::next(m.begin())->first == 2); - assert(std::next(m.begin())->second == 1); - assert(std::next(m.begin(), 2)->first == 3); - assert(std::next(m.begin(), 2)->second == 1); + { // Check that 1 element is inserted correctly + { // Without elements in the container + using Map = std::map<int, int, std::less<int>, Alloc>; + using Pair = std::pair<const int, int>; + + Pair arr[] = {Pair(1, 1)}; + + Map map; + map.insert(Iter(std::begin(arr)), Iter(std::end(arr))); + assert(map.size() == 1); + assert(*std::next(map.begin(), 0) == Pair(1, 1)); + assert(std::next(map.begin(), 1) == map.end()); + } + { // With 1 element in the container - a different key + using Map = std::map<int, int, std::less<int>, Alloc>; + using Pair = std::pair<const int, int>; + + Pair arr[] = {Pair(1, 1)}; + + Map map; + map.insert(Pair(0, 0)); + map.insert(Iter(std::begin(arr)), Iter(std::end(arr))); + assert(map.size() == 2); + assert(*std::next(map.begin(), 0) == Pair(0, 0)); + assert(*std::next(map.begin(), 1) == Pair(1, 1)); + assert(std::next(map.begin(), 2) == map.end()); + } + { // With 1 element in the container - the same key + using Map = std::map<int, int, std::less<int>, Alloc>; + using Pair = std::pair<const int, int>; + + Pair arr[] = {Pair(1, 1)}; + + Map map; + map.insert(Pair(1, 2)); + map.insert(Iter(std::begin(arr)), Iter(std::end(arr))); + assert(map.size() == 1); + assert(*std::next(map.begin(), 0) == Pair(1, 2)); + assert(std::next(map.begin(), 1) == map.end()); + } + { // With multiple elements in the container + using Map = std::map<int, int, std::less<int>, Alloc>; + using Pair = std::pair<const int, int>; + + Pair arr[] = {Pair(1, 1)}; + + Map map; + map.insert(Pair(0, 0)); + map.insert(Pair(1, 1)); + map.insert(Pair(2, 2)); + map.insert(Iter(std::begin(arr)), Iter(std::end(arr))); + assert(map.size() == 3); + assert(*std::next(map.begin(), 0) == Pair(0, 0)); + assert(*std::next(map.begin(), 1) == Pair(1, 1)); + assert(*std::next(map.begin(), 2) == Pair(2, 2)); + assert(std::next(map.begin(), 3) == map.end()); + } } -#endif + { // Check that multiple elements are inserted correctly + { // Without elements in the container + using Map = std::map<int, int, std::less<int>, Alloc>; + using Pair = std::pair<const int, int>; + + Pair arr[] = {Pair(1, 1), Pair(1, 1), Pair(3, 3)}; + + Map map; + map.insert(Iter(std::begin(arr)), Iter(std::end(arr))); + assert(map.size() == 2); + assert(*std::next(map.begin(), 0) == Pair(1, 1)); + assert(*std::next(map.begin(), 1) == Pair(3, 3)); + assert(std::next(map.begin(), 2) == map.end()); + } + { // With 1 element in the container - a different key + using Map = std::map<int, int, std::less<int>, Alloc>; + using Pair = std::pair<const int, int>; + + Pair arr[] = {Pair(1, 1), Pair(1, 1), Pair(3, 3)}; + + Map map; + map.insert(Pair(0, 0)); + map.insert(Iter(std::begin(arr)), Iter(std::end(arr))); + assert(map.size() == 3); + assert(*std::next(map.begin(), 0) == Pair(0, 0)); + assert(*std::next(map.begin(), 1) == Pair(1, 1)); + assert(*std::next(map.begin(), 2) == Pair(3, 3)); + assert(std::next(map.begin(), 3) == map.end()); + } + { // With 1 element in the container - the same key + using Map = std::map<int, int, std::less<int>, Alloc>; + using Pair = std::pair<const int, int>; + + Pair arr[] = {Pair(1, 1), Pair(2, 2), Pair(3, 3)}; + + Map map; + map.insert(Pair(1, 1)); + map.insert(Iter(std::begin(arr)), Iter(std::end(arr))); + assert(map.size() == 3); + assert(*std::next(map.begin(), 0) == Pair(1, 1)); + assert(*std::next(map.begin(), 1) == Pair(2, 2)); + assert(*std::next(map.begin(), 2) == Pair(3, 3)); + assert(std::next(map.begin(), 3) == map.end()); + } + { // With multiple elements in the container + using Map = std::map<int, int, std::less<int>, Alloc>; + using Pair = std::pair<const int, int>; + + Pair arr[] = {Pair(1, 1), Pair(3, 3), Pair(4, 4)}; + + Map map; + map.insert(Pair(0, 0)); + map.insert(Pair(1, 1)); + map.insert(Pair(2, 2)); + map.insert(Iter(std::begin(arr)), Iter(std::end(arr))); + assert(map.size() == 5); + assert(*std::next(map.begin(), 0) == Pair(0, 0)); + assert(*std::next(map.begin(), 1) == Pair(1, 1)); + assert(*std::next(map.begin(), 2) == Pair(2, 2)); + assert(*std::next(map.begin(), 3) == Pair(3, 3)); + assert(*std::next(map.begin(), 4) == Pair(4, 4)); + assert(std::next(map.begin(), 5) == map.end()); + } + } +} + +void test() { + test_alloc<cpp17_input_iterator<std::pair<const int, int>*>, std::allocator<std::pair<const int, int> > >(); + test_alloc<cpp17_input_iterator<std::pair<const int, int>*>, min_allocator<std::pair<const int, int> > >(); +} + +int main(int, char**) { + test(); return 0; } diff --git a/libcxx/test/std/containers/associative/multimap/multimap.cons/copy_assign.pass.cpp b/libcxx/test/std/containers/associative/multimap/multimap.cons/copy_assign.pass.cpp index 5830283e9b0c..e52da3a4a631 100644 --- a/libcxx/test/std/containers/associative/multimap/multimap.cons/copy_assign.pass.cpp +++ b/libcxx/test/std/containers/associative/multimap/multimap.cons/copy_assign.pass.cpp @@ -68,7 +68,7 @@ template <class Alloc, class AllocatorInvariant = NoOp> void test_alloc(const Alloc& lhs_alloc = Alloc(), const Alloc& rhs_alloc = Alloc(), AllocatorInvariant check_alloc_invariant = NoOp()) { - { // Test empty/non-empy multimap combinations + { // Test empty/non-empty multimap combinations { // assign from a non-empty container into an empty one using V = std::pair<const int, int>; using Map = std::multimap<int, int, std::less<int>, Alloc>; @@ -223,7 +223,7 @@ void test_alloc(const Alloc& lhs_alloc = Alloc(), } check_alloc_invariant(); } - { // Make a somewhat larget set to exercise the algorithm a bit + { // Make a somewhat larger set to exercise the algorithm a bit using V = std::pair<const int, int>; using Map = std::multimap<int, int, std::less<int>, Alloc>; diff --git a/libcxx/test/std/containers/associative/multiset/emplace.pass.cpp b/libcxx/test/std/containers/associative/multiset/emplace.pass.cpp index bddfd8f62143..97cae1c56521 100644 --- a/libcxx/test/std/containers/associative/multiset/emplace.pass.cpp +++ b/libcxx/test/std/containers/associative/multiset/emplace.pass.cpp @@ -15,12 +15,12 @@ // template <class... Args> // iterator emplace(Args&&... args); -#include <set> #include <cassert> +#include <set> -#include "test_macros.h" #include "../../Emplaceable.h" #include "DefaultOnly.h" +#include "MoveOnly.h" #include "min_allocator.h" int main(int, char**) { @@ -77,6 +77,12 @@ int main(int, char**) { assert(m.size() == 1); assert(*r == 2); } + { // We're unwrapping pairs for `{,multi}map`. Make sure we're not trying to do that for multiset. + using Set = std::multiset<std::pair<MoveOnly, MoveOnly>>; + Set set; + auto iter = set.emplace(std::pair<MoveOnly, MoveOnly>(2, 4)); + assert(set.begin() == iter); + } return 0; } diff --git a/libcxx/test/std/containers/associative/multiset/multiset.cons/copy_assign.pass.cpp b/libcxx/test/std/containers/associative/multiset/multiset.cons/copy_assign.pass.cpp index 8511f05ab57e..0a5fe62eed69 100644 --- a/libcxx/test/std/containers/associative/multiset/multiset.cons/copy_assign.pass.cpp +++ b/libcxx/test/std/containers/associative/multiset/multiset.cons/copy_assign.pass.cpp @@ -68,7 +68,7 @@ template <class Alloc, class AllocatorInvariant = NoOp> void test_alloc(const Alloc& lhs_alloc = Alloc(), const Alloc& rhs_alloc = Alloc(), AllocatorInvariant check_alloc_invariant = NoOp()) { - { // Test empty/non-empy multiset combinations + { // Test empty/non-empty multiset combinations { // assign from a non-empty container into an empty one using Set = std::multiset<int, std::less<int>, Alloc>; @@ -216,7 +216,7 @@ void test_alloc(const Alloc& lhs_alloc = Alloc(), assert(std::next(orig.begin(), 3) == orig.end()); } check_alloc_invariant(); - { // Make a somewhat larget multiset to exercise the algorithm a bit + { // Make a somewhat larger multiset to exercise the algorithm a bit using Set = std::multiset<int, std::less<int>, Alloc>; Set orig(rhs_alloc); diff --git a/libcxx/test/std/containers/associative/set/emplace.pass.cpp b/libcxx/test/std/containers/associative/set/emplace.pass.cpp index e038de77d48a..e5a9f9590aad 100644 --- a/libcxx/test/std/containers/associative/set/emplace.pass.cpp +++ b/libcxx/test/std/containers/associative/set/emplace.pass.cpp @@ -15,12 +15,12 @@ // template <class... Args> // pair<iterator, bool> emplace(Args&&... args); -#include <set> #include <cassert> +#include <set> -#include "test_macros.h" #include "../../Emplaceable.h" #include "DefaultOnly.h" +#include "MoveOnly.h" #include "min_allocator.h" int main(int, char**) { @@ -84,6 +84,13 @@ int main(int, char**) { assert(m.size() == 1); assert(*r.first == 2); } + { // We're unwrapping pairs for `{,multi}map`. Make sure we're not trying to do that for set. + using Set = std::set<std::pair<MoveOnly, MoveOnly>>; + Set set; + auto res = set.emplace(std::pair<MoveOnly, MoveOnly>(2, 4)); + assert(std::get<1>(res)); + assert(set.begin() == std::get<0>(res)); + } return 0; } diff --git a/libcxx/test/std/containers/associative/set/insert_iter_iter.pass.cpp b/libcxx/test/std/containers/associative/set/insert_iter_iter.pass.cpp index 6c9707ca31a8..8576c63a72de 100644 --- a/libcxx/test/std/containers/associative/set/insert_iter_iter.pass.cpp +++ b/libcxx/test/std/containers/associative/set/insert_iter_iter.pass.cpp @@ -13,38 +13,178 @@ // template <class InputIterator> // void insert(InputIterator first, InputIterator last); -#include <set> +#include <array> #include <cassert> +#include <set> -#include "test_macros.h" -#include "test_iterators.h" #include "min_allocator.h" +#include "test_iterators.h" -int main(int, char**) { - { - typedef std::set<int> M; - typedef int V; - V ar[] = {1, 1, 1, 2, 2, 2, 3, 3, 3}; - M m; - m.insert(cpp17_input_iterator<const V*>(ar), cpp17_input_iterator<const V*>(ar + sizeof(ar) / sizeof(ar[0]))); - assert(m.size() == 3); - assert(*m.begin() == 1); - assert(*std::next(m.begin()) == 2); - assert(*std::next(m.begin(), 2) == 3); +template <class Iter, class Alloc> +void test_alloc() { + { // Check that an empty range works correctly + { // Without elements in the container + using Map = std::set<int, std::less<int>, Alloc>; + + std::array<int, 0> arr; + + Map map; + map.insert(Iter(arr.data()), Iter(arr.data() + arr.size())); + assert(map.size() == 0); + assert(map.begin() == map.end()); + } + { // With 1 element in the container + using Map = std::set<int, std::less<int>, Alloc>; + + std::array<int, 0> arr; + + Map map; + map.insert(0); + map.insert(Iter(arr.data()), Iter(arr.data() + arr.size())); + assert(map.size() == 1); + assert(*std::next(map.begin(), 0) == 0); + assert(std::next(map.begin(), 1) == map.end()); + } + { // With multiple elements in the container + using Map = std::set<int, std::less<int>, Alloc>; + + std::array<int, 0> arr; + + Map map; + map.insert(0); + map.insert(1); + map.insert(2); + map.insert(Iter(arr.data()), Iter(arr.data() + arr.size())); + assert(map.size() == 3); + assert(*std::next(map.begin(), 0) == 0); + assert(*std::next(map.begin(), 1) == 1); + assert(*std::next(map.begin(), 2) == 2); + assert(std::next(map.begin(), 3) == map.end()); + } } -#if TEST_STD_VER >= 11 - { - typedef std::set<int, std::less<int>, min_allocator<int>> M; - typedef int V; - V ar[] = {1, 1, 1, 2, 2, 2, 3, 3, 3}; - M m; - m.insert(cpp17_input_iterator<const V*>(ar), cpp17_input_iterator<const V*>(ar + sizeof(ar) / sizeof(ar[0]))); - assert(m.size() == 3); - assert(*m.begin() == 1); - assert(*std::next(m.begin()) == 2); - assert(*std::next(m.begin(), 2) == 3); + { // Check that 1 element is inserted correctly + { // Without elements in the container + using Map = std::set<int, std::less<int>, Alloc>; + + int arr[] = {1}; + + Map map; + map.insert(Iter(std::begin(arr)), Iter(std::end(arr))); + assert(map.size() == 1); + assert(*std::next(map.begin(), 0) == 1); + assert(std::next(map.begin(), 1) == map.end()); + } + { // With 1 element in the container - a different key + using Map = std::set<int, std::less<int>, Alloc>; + + int arr[] = {1}; + + Map map; + map.insert(0); + map.insert(Iter(std::begin(arr)), Iter(std::end(arr))); + assert(map.size() == 2); + assert(*std::next(map.begin(), 0) == 0); + assert(*std::next(map.begin(), 1) == 1); + assert(std::next(map.begin(), 2) == map.end()); + } + { // With 1 element in the container - the same key + using Map = std::set<int, std::less<int>, Alloc>; + + int arr[] = {1}; + + Map map; + map.insert(1); + map.insert(Iter(std::begin(arr)), Iter(std::end(arr))); + assert(map.size() == 1); + assert(*std::next(map.begin(), 0) == 1); + assert(std::next(map.begin(), 1) == map.end()); + } + { // With multiple elements in the container + using Map = std::set<int, std::less<int>, Alloc>; + + int arr[] = {1}; + + Map map; + map.insert(0); + map.insert(1); + map.insert(2); + map.insert(Iter(std::begin(arr)), Iter(std::end(arr))); + assert(map.size() == 3); + assert(*std::next(map.begin(), 0) == 0); + assert(*std::next(map.begin(), 1) == 1); + assert(*std::next(map.begin(), 2) == 2); + assert(std::next(map.begin(), 3) == map.end()); + } + } + { // Check that multiple elements are inserted correctly + { // Without elements in the container + using Map = std::set<int, std::less<int>, Alloc>; + + int arr[] = {1, 1, 3}; + + Map map; + map.insert(Iter(std::begin(arr)), Iter(std::end(arr))); + assert(map.size() == 2); + assert(*std::next(map.begin(), 0) == 1); + assert(*std::next(map.begin(), 1) == 3); + assert(std::next(map.begin(), 2) == map.end()); + } + { // With 1 element in the container - a different key + using Map = std::set<int, std::less<int>, Alloc>; + + int arr[] = {1, 1, 3}; + + Map map; + map.insert(0); + map.insert(Iter(std::begin(arr)), Iter(std::end(arr))); + assert(map.size() == 3); + assert(*std::next(map.begin(), 0) == 0); + assert(*std::next(map.begin(), 1) == 1); + assert(*std::next(map.begin(), 2) == 3); + assert(std::next(map.begin(), 3) == map.end()); + } + { // With 1 element in the container - the same key + using Map = std::set<int, std::less<int>, Alloc>; + + int arr[] = {1, 2, 3}; + + Map map; + map.insert(1); + map.insert(Iter(std::begin(arr)), Iter(std::end(arr))); + assert(map.size() == 3); + assert(*std::next(map.begin(), 0) == 1); + assert(*std::next(map.begin(), 1) == 2); + assert(*std::next(map.begin(), 2) == 3); + assert(std::next(map.begin(), 3) == map.end()); + } + { // With multiple elements in the container + using Map = std::set<int, std::less<int>, Alloc>; + + int arr[] = {1, 3, 4}; + + Map map; + map.insert(0); + map.insert(1); + map.insert(2); + map.insert(Iter(std::begin(arr)), Iter(std::end(arr))); + assert(map.size() == 5); + assert(*std::next(map.begin(), 0) == 0); + assert(*std::next(map.begin(), 1) == 1); + assert(*std::next(map.begin(), 2) == 2); + assert(*std::next(map.begin(), 3) == 3); + assert(*std::next(map.begin(), 4) == 4); + assert(std::next(map.begin(), 5) == map.end()); + } } -#endif +} + +void test() { + test_alloc<cpp17_input_iterator<int*>, std::allocator<int> >(); + test_alloc<cpp17_input_iterator<int*>, min_allocator<int> >(); +} + +int main(int, char**) { + test(); return 0; } diff --git a/libcxx/test/std/containers/associative/set/set.cons/copy_assign.pass.cpp b/libcxx/test/std/containers/associative/set/set.cons/copy_assign.pass.cpp index 85bc4e761f2c..dd1dbc86190f 100644 --- a/libcxx/test/std/containers/associative/set/set.cons/copy_assign.pass.cpp +++ b/libcxx/test/std/containers/associative/set/set.cons/copy_assign.pass.cpp @@ -70,7 +70,7 @@ template <class Alloc, class AllocatorInvariant = NoOp> void test_alloc(const Alloc& lhs_alloc = Alloc(), const Alloc& rhs_alloc = Alloc(), AllocatorInvariant check_alloc_invariant = NoOp()) { - { // Test empty/non-empy set combinations + { // Test empty/non-empty set combinations { // assign from a non-empty container into an empty one using Set = std::set<int, std::less<int>, Alloc>; @@ -218,7 +218,7 @@ void test_alloc(const Alloc& lhs_alloc = Alloc(), assert(std::next(orig.begin(), 3) == orig.end()); } check_alloc_invariant(); - { // Make a somewhat larget set to exercise the algorithm a bit + { // Make a somewhat larger set to exercise the algorithm a bit using Set = std::set<int, std::less<int>, Alloc>; Set orig(rhs_alloc); diff --git a/libcxx/test/std/containers/container.adaptors/flat.map/flat.map.cons/move_assign_noexcept.compile.pass.cpp b/libcxx/test/std/containers/container.adaptors/flat.map/flat.map.cons/move_assign_noexcept.compile.pass.cpp index 18d332cf27b5..c727f7e51eb2 100644 --- a/libcxx/test/std/containers/container.adaptors/flat.map/flat.map.cons/move_assign_noexcept.compile.pass.cpp +++ b/libcxx/test/std/containers/container.adaptors/flat.map/flat.map.cons/move_assign_noexcept.compile.pass.cpp @@ -51,7 +51,7 @@ struct MoveThrowsComp { void test() { { - using C = std::flat_map<int, int>; + using C [[maybe_unused]] = std::flat_map<int, int>; LIBCPP_STATIC_ASSERT(std::is_nothrow_move_assignable_v<C>); } { @@ -73,7 +73,7 @@ void test() { static_assert(!std::is_nothrow_move_assignable_v<C>); } { - using C = + using C [[maybe_unused]] = std::flat_map<MoveOnly, int, std::less<MoveOnly>, @@ -82,7 +82,7 @@ void test() { LIBCPP_STATIC_ASSERT(std::is_nothrow_move_assignable_v<C>); } { - using C = + using C [[maybe_unused]] = std::flat_map<int, MoveOnly, std::less<int>, @@ -92,7 +92,7 @@ void test() { } { // Test with a comparator that throws on move-assignment. - using C = std::flat_map<int, int, MoveThrowsComp>; + using C [[maybe_unused]] = std::flat_map<int, int, MoveThrowsComp>; LIBCPP_STATIC_ASSERT(!std::is_nothrow_move_assignable_v<C>); } { diff --git a/libcxx/test/std/containers/container.adaptors/flat.map/flat.map.erasure/erase_if_exceptions.pass.cpp b/libcxx/test/std/containers/container.adaptors/flat.map/flat.map.erasure/erase_if_exceptions.pass.cpp index 48fdec42db3f..c0e31dc38426 100644 --- a/libcxx/test/std/containers/container.adaptors/flat.map/flat.map.erasure/erase_if_exceptions.pass.cpp +++ b/libcxx/test/std/containers/container.adaptors/flat.map/flat.map.erasure/erase_if_exceptions.pass.cpp @@ -66,7 +66,8 @@ struct ErasurePredicate { }; int main(int, char**) { - const std::pair<int, int> expected[] = {{1, 1}, {2, 2}, {3, 3}, {4, 4}, {5, 5}, {6, 6}, {7, 7}, {8, 8}}; + [[maybe_unused]] const std::pair<int, int> expected[] = { + {1, 1}, {2, 2}, {3, 3}, {4, 4}, {5, 5}, {6, 6}, {7, 7}, {8, 8}}; { using M = std::flat_map<ThrowingAssignment, int, ThrowingComparator>; for (int first_throw = 1; first_throw < 99; ++first_throw) { diff --git a/libcxx/test/std/containers/container.adaptors/flat.multimap/flat.multimap.cons/move_assign_noexcept.compile.pass.cpp b/libcxx/test/std/containers/container.adaptors/flat.multimap/flat.multimap.cons/move_assign_noexcept.compile.pass.cpp index 1aa40759fada..5f86bb336f13 100644 --- a/libcxx/test/std/containers/container.adaptors/flat.multimap/flat.multimap.cons/move_assign_noexcept.compile.pass.cpp +++ b/libcxx/test/std/containers/container.adaptors/flat.multimap/flat.multimap.cons/move_assign_noexcept.compile.pass.cpp @@ -51,7 +51,7 @@ struct MoveThrowsComp { void test() { { - using C = std::flat_multimap<int, int>; + using C [[maybe_unused]] = std::flat_multimap<int, int>; LIBCPP_STATIC_ASSERT(std::is_nothrow_move_assignable_v<C>); } { @@ -73,7 +73,7 @@ void test() { static_assert(!std::is_nothrow_move_assignable_v<C>); } { - using C = + using C [[maybe_unused]] = std::flat_multimap<MoveOnly, int, std::less<MoveOnly>, @@ -82,7 +82,7 @@ void test() { LIBCPP_STATIC_ASSERT(std::is_nothrow_move_assignable_v<C>); } { - using C = + using C [[maybe_unused]] = std::flat_multimap<int, MoveOnly, std::less<int>, @@ -92,7 +92,7 @@ void test() { } { // Test with a comparator that throws on move-assignment. - using C = std::flat_multimap<int, int, MoveThrowsComp>; + using C [[maybe_unused]] = std::flat_multimap<int, int, MoveThrowsComp>; LIBCPP_STATIC_ASSERT(!std::is_nothrow_move_assignable_v<C>); } { diff --git a/libcxx/test/std/containers/container.adaptors/flat.multimap/flat.multimap.erasure/erase_if_exceptions.pass.cpp b/libcxx/test/std/containers/container.adaptors/flat.multimap/flat.multimap.erasure/erase_if_exceptions.pass.cpp index 13b57202f786..95f7e11626a4 100644 --- a/libcxx/test/std/containers/container.adaptors/flat.multimap/flat.multimap.erasure/erase_if_exceptions.pass.cpp +++ b/libcxx/test/std/containers/container.adaptors/flat.multimap/flat.multimap.erasure/erase_if_exceptions.pass.cpp @@ -68,7 +68,8 @@ struct ErasurePredicate { }; int main(int, char**) { - const std::pair<int, int> expected[] = {{1, 1}, {2, 2}, {3, 3}, {3, 3}, {5, 5}, {6, 6}, {7, 7}, {8, 8}}; + [[maybe_unused]] const std::pair<int, int> expected[] = { + {1, 1}, {2, 2}, {3, 3}, {3, 3}, {5, 5}, {6, 6}, {7, 7}, {8, 8}}; { using M = std::flat_multimap<ThrowingAssignment, int, ThrowingComparator>; for (int first_throw = 1; first_throw < 99; ++first_throw) { diff --git a/libcxx/test/std/containers/container.adaptors/flat.set/flat.set.erasure/erase_if_exceptions.pass.cpp b/libcxx/test/std/containers/container.adaptors/flat.set/flat.set.erasure/erase_if_exceptions.pass.cpp index 37b4a40f0165..11cc12aaeabf 100644 --- a/libcxx/test/std/containers/container.adaptors/flat.set/flat.set.erasure/erase_if_exceptions.pass.cpp +++ b/libcxx/test/std/containers/container.adaptors/flat.set/flat.set.erasure/erase_if_exceptions.pass.cpp @@ -66,7 +66,7 @@ struct ErasurePredicate { }; void test() { - const int expected[] = {1, 2, 3, 4, 5, 6, 7, 8}; + [[maybe_unused]] const int expected[] = {1, 2, 3, 4, 5, 6, 7, 8}; { using M = std::flat_set<ThrowingAssignment, ThrowingComparator>; for (int first_throw = 1; first_throw < 99; ++first_throw) { diff --git a/libcxx/test/std/containers/sequences/array/array.cons/initialization.pass.cpp b/libcxx/test/std/containers/sequences/array/array.cons/initialization.pass.cpp index 0bca4299c851..6d5427f3e363 100644 --- a/libcxx/test/std/containers/sequences/array/array.cons/initialization.pass.cpp +++ b/libcxx/test/std/containers/sequences/array/array.cons/initialization.pass.cpp @@ -20,7 +20,7 @@ struct NoDefault { struct test_initialization { template <typename T> TEST_CONSTEXPR_CXX14 void operator()() const { - // Check default initalization + // Check default initialization { std::array<T, 0> a0; (void)a0; diff --git a/libcxx/test/std/containers/sequences/deque/deque.cons/from_range.pass.cpp b/libcxx/test/std/containers/sequences/deque/deque.cons/from_range.pass.cpp index cfc07ab7bc79..3b3632a3d3c6 100644 --- a/libcxx/test/std/containers/sequences/deque/deque.cons/from_range.pass.cpp +++ b/libcxx/test/std/containers/sequences/deque/deque.cons/from_range.pass.cpp @@ -28,7 +28,7 @@ int main(int, char**) { static_assert(test_constraints<std::deque, int, double>()); // TODO(varconst): `deque`'s constructors currently aren't exception-safe. - // See https://github.com/llvm/llvm-project/issues/62056. + // See https://llvm.org/PR62056. //test_exception_safety_throwing_copy<std::deque>(); //test_exception_safety_throwing_allocator<std::deque, int>(); diff --git a/libcxx/test/std/containers/sequences/forwardlist/types.pass.cpp b/libcxx/test/std/containers/sequences/forwardlist/types.pass.cpp index d2e48b351fc7..58b73415f1a7 100644 --- a/libcxx/test/std/containers/sequences/forwardlist/types.pass.cpp +++ b/libcxx/test/std/containers/sequences/forwardlist/types.pass.cpp @@ -24,8 +24,6 @@ // ... // }; -// XFAIL: FROZEN-CXX03-HEADERS-FIXME - #include <forward_list> #include <type_traits> diff --git a/libcxx/test/std/containers/sequences/list/types.pass.cpp b/libcxx/test/std/containers/sequences/list/types.pass.cpp index 755c8bf4df29..7075f6eff0b2 100644 --- a/libcxx/test/std/containers/sequences/list/types.pass.cpp +++ b/libcxx/test/std/containers/sequences/list/types.pass.cpp @@ -21,8 +21,6 @@ // typedef typename allocator_type::pointer pointer; // typedef typename allocator_type::const_pointer const_pointer; -// XFAIL: FROZEN-CXX03-HEADERS-FIXME - #include <list> #include <type_traits> diff --git a/libcxx/test/std/containers/sequences/vector.bool/shrink_to_fit.pass.cpp b/libcxx/test/std/containers/sequences/vector.bool/shrink_to_fit.pass.cpp index 30efe047054a..665867a7bad4 100644 --- a/libcxx/test/std/containers/sequences/vector.bool/shrink_to_fit.pass.cpp +++ b/libcxx/test/std/containers/sequences/vector.bool/shrink_to_fit.pass.cpp @@ -80,7 +80,7 @@ TEST_CONSTEXPR_CXX20 bool tests() { } #if TEST_STD_VER >= 23 -// https://github.com/llvm/llvm-project/issues/95161 +// https://llvm.org/PR95161 constexpr bool test_increasing_allocator() { std::vector<bool, increasing_allocator<bool>> v; v.push_back(1); diff --git a/libcxx/test/std/containers/sequences/vector.bool/small_allocator_size.pass.cpp b/libcxx/test/std/containers/sequences/vector.bool/small_allocator_size.pass.cpp index 95e4c18cc798..0136fb063160 100644 --- a/libcxx/test/std/containers/sequences/vector.bool/small_allocator_size.pass.cpp +++ b/libcxx/test/std/containers/sequences/vector.bool/small_allocator_size.pass.cpp @@ -12,7 +12,7 @@ // XFAIL: FROZEN-CXX03-HEADERS-FIXME // This test ensures that std::vector<bool> handles allocator types with small size types -// properly. Related issue: https://github.com/llvm/llvm-project/issues/121713. +// properly. Related issue: https://llvm.org/PR121713. #include <cassert> #include <cstddef> diff --git a/libcxx/test/std/containers/sequences/vector/vector.capacity/max_size.pass.cpp b/libcxx/test/std/containers/sequences/vector/vector.capacity/max_size.pass.cpp index a3f44f33028e..af57e5ffc5cf 100644 --- a/libcxx/test/std/containers/sequences/vector/vector.capacity/max_size.pass.cpp +++ b/libcxx/test/std/containers/sequences/vector/vector.capacity/max_size.pass.cpp @@ -66,7 +66,7 @@ TEST_CONSTEXPR_CXX20 bool tests() { #if TEST_STD_VER >= 11 - // Test with various allocators and diffrent size_type + // Test with various allocators and different size_type { test(std::vector<int>()); test(std::vector<short, std::allocator<short> >()); diff --git a/libcxx/test/std/containers/sequences/vector/vector.capacity/shrink_to_fit.pass.cpp b/libcxx/test/std/containers/sequences/vector/vector.capacity/shrink_to_fit.pass.cpp index 48eb6ed85d47..bbea48364c1f 100644 --- a/libcxx/test/std/containers/sequences/vector/vector.capacity/shrink_to_fit.pass.cpp +++ b/libcxx/test/std/containers/sequences/vector/vector.capacity/shrink_to_fit.pass.cpp @@ -74,7 +74,7 @@ TEST_CONSTEXPR_CXX20 bool tests() { } #if TEST_STD_VER >= 23 -// https://github.com/llvm/llvm-project/issues/95161 +// https://llvm.org/PR95161 constexpr bool test_increasing_allocator() { std::vector<int, increasing_allocator<int>> v; v.push_back(1); diff --git a/libcxx/test/std/containers/sequences/vector/vector.capacity/shrink_to_fit_exceptions.pass.cpp b/libcxx/test/std/containers/sequences/vector/vector.capacity/shrink_to_fit_exceptions.pass.cpp index 521a25fdeda0..0bc3387e26b8 100644 --- a/libcxx/test/std/containers/sequences/vector/vector.capacity/shrink_to_fit_exceptions.pass.cpp +++ b/libcxx/test/std/containers/sequences/vector/vector.capacity/shrink_to_fit_exceptions.pass.cpp @@ -39,7 +39,7 @@ void test_allocation_exception_for_strong_guarantee(std::vector<T, Alloc>& v, co } catch (...) { } - // As shrink_to_fit may swallow any exceptions, we place the checks outisde the catch block. + // As shrink_to_fit may swallow any exceptions, we place the checks outside the catch block. assert(v.data() == old_data); assert(v.size() == old_size); assert(v.capacity() == old_cap); diff --git a/libcxx/test/std/containers/sequences/vector/vector.cons/construct_iter_iter.pass.cpp b/libcxx/test/std/containers/sequences/vector/vector.cons/construct_iter_iter.pass.cpp index 6549735f7b51..1a6364a8018b 100644 --- a/libcxx/test/std/containers/sequences/vector/vector.cons/construct_iter_iter.pass.cpp +++ b/libcxx/test/std/containers/sequences/vector/vector.cons/construct_iter_iter.pass.cpp @@ -79,7 +79,7 @@ TEST_CONSTEXPR_CXX20 void basic_test_cases() { test<std::vector<int, safe_allocator<int> > >( random_access_iterator<const int*>(a), random_access_iterator<const int*>(an)); - // Regression test for https://github.com/llvm/llvm-project/issues/46841 + // Regression test for https://llvm.org/PR47497 { std::vector<int> v1({}, forward_iterator<const int*>{}); std::vector<int> v2(forward_iterator<const int*>{}, {}); diff --git a/libcxx/test/std/containers/sequences/vector/vector.cons/construct_iter_iter_alloc.pass.cpp b/libcxx/test/std/containers/sequences/vector/vector.cons/construct_iter_iter_alloc.pass.cpp index 019f427c006a..d1eff51011c4 100644 --- a/libcxx/test/std/containers/sequences/vector/vector.cons/construct_iter_iter_alloc.pass.cpp +++ b/libcxx/test/std/containers/sequences/vector/vector.cons/construct_iter_iter_alloc.pass.cpp @@ -90,7 +90,7 @@ TEST_CONSTEXPR_CXX20 void basic_tests() { test<std::vector<int, safe_allocator<int> > >(a, an, alloc); } - // Regression test for https://github.com/llvm/llvm-project/issues/46841 + // Regression test for https://llvm.org/PR47497 { min_allocator<int> alloc; std::vector<int, min_allocator<int> > v1({}, forward_iterator<const int*>{}, alloc); diff --git a/libcxx/test/std/containers/unord/unord.multimap/unord.multimap.modifiers/erase_range.pass.cpp b/libcxx/test/std/containers/unord/unord.multimap/unord.multimap.modifiers/erase_range.pass.cpp index f8a2bdd3fee7..a8a9f5fdbb42 100644 --- a/libcxx/test/std/containers/unord/unord.multimap/unord.multimap.modifiers/erase_range.pass.cpp +++ b/libcxx/test/std/containers/unord/unord.multimap/unord.multimap.modifiers/erase_range.pass.cpp @@ -91,6 +91,20 @@ int main(int, char**) { assert(c.size() == 0); assert(k == c.end()); } + { // Make sure we're properly destroying the elements when erasing + { // When erasing part of a bucket + std::unordered_multimap<int, std::string> map; + map.insert(std::make_pair(1, "This is a long string to make sure ASan can detect a memory leak")); + map.insert(std::make_pair(1, "This is another long string to make sure ASan can detect a memory leak")); + map.erase(++map.begin(), map.end()); + } + { // When erasing the whole bucket + std::unordered_multimap<int, std::string> map; + map.insert(std::make_pair(1, "This is a long string to make sure ASan can detect a memory leak")); + map.insert(std::make_pair(1, "This is another long string to make sure ASan can detect a memory leak")); + map.erase(map.begin(), map.end()); + } + } #if TEST_STD_VER >= 11 { typedef std::unordered_multimap<int, diff --git a/libcxx/test/std/containers/unord/unord.multiset/emplace.pass.cpp b/libcxx/test/std/containers/unord/unord.multiset/emplace.pass.cpp index 886ddd74efd4..434f205f90b9 100644 --- a/libcxx/test/std/containers/unord/unord.multiset/emplace.pass.cpp +++ b/libcxx/test/std/containers/unord/unord.multiset/emplace.pass.cpp @@ -17,11 +17,11 @@ // template <class... Args> // iterator emplace(Args&&... args); -#include <unordered_set> #include <cassert> +#include <unordered_set> -#include "test_macros.h" #include "../../Emplaceable.h" +#include "MoveOnly.h" #include "min_allocator.h" int main(int, char**) { @@ -59,6 +59,15 @@ int main(int, char**) { assert(c.size() == 3); assert(*r == Emplaceable(5, 6)); } + { // We're unwrapping pairs for `unordered_{,multi}map`. Make sure we're not trying to do that for unordered_multiset. + struct PairHasher { + size_t operator()(const std::pair<MoveOnly, MoveOnly>& val) const { return std::hash<MoveOnly>()(val.first); } + }; + using Set = std::unordered_multiset<std::pair<MoveOnly, MoveOnly>, PairHasher>; + Set set; + auto iter = set.emplace(std::pair<MoveOnly, MoveOnly>(2, 4)); + assert(set.begin() == iter); + } return 0; } diff --git a/libcxx/test/std/containers/unord/unord.set/emplace.pass.cpp b/libcxx/test/std/containers/unord/unord.set/emplace.pass.cpp index 8972f03f2d2a..24e85a1ab7f5 100644 --- a/libcxx/test/std/containers/unord/unord.set/emplace.pass.cpp +++ b/libcxx/test/std/containers/unord/unord.set/emplace.pass.cpp @@ -17,11 +17,11 @@ // template <class... Args> // pair<iterator, bool> emplace(Args&&... args); -#include <unordered_set> #include <cassert> +#include <unordered_set> -#include "test_macros.h" #include "../../Emplaceable.h" +#include "MoveOnly.h" #include "min_allocator.h" int main(int, char**) { @@ -65,6 +65,16 @@ int main(int, char**) { assert(*r.first == Emplaceable(5, 6)); assert(!r.second); } + { // We're unwrapping pairs for `unordered_{,multi}map`. Make sure we're not trying to do that for unordered_set. + struct PairHasher { + size_t operator()(const std::pair<MoveOnly, MoveOnly>& val) const { return std::hash<MoveOnly>()(val.first); } + }; + using Set = std::unordered_set<std::pair<MoveOnly, MoveOnly>, PairHasher>; + Set set; + auto res = set.emplace(std::pair<MoveOnly, MoveOnly>(2, 4)); + assert(std::get<1>(res)); + assert(set.begin() == std::get<0>(res)); + } return 0; } diff --git a/libcxx/test/std/containers/views/mdspan/aligned_accessor/access.pass.cpp b/libcxx/test/std/containers/views/mdspan/aligned_accessor/access.pass.cpp index deca1226e47c..91a910899abc 100644 --- a/libcxx/test/std/containers/views/mdspan/aligned_accessor/access.pass.cpp +++ b/libcxx/test/std/containers/views/mdspan/aligned_accessor/access.pass.cpp @@ -23,7 +23,7 @@ #include "test_macros.h" // We are not using MinimalElementType.h because MinimalElementType is not -// default consructible and uninitialized storage does not work in constexpr. +// default constructible and uninitialized storage does not work in constexpr. // Same as MinimalElementType but with a defaulted default constructor struct MyMinimalElementType { diff --git a/libcxx/test/std/containers/views/mdspan/aligned_accessor/offset.pass.cpp b/libcxx/test/std/containers/views/mdspan/aligned_accessor/offset.pass.cpp index 66c30da787a8..3ed8cd752017 100644 --- a/libcxx/test/std/containers/views/mdspan/aligned_accessor/offset.pass.cpp +++ b/libcxx/test/std/containers/views/mdspan/aligned_accessor/offset.pass.cpp @@ -23,7 +23,7 @@ #include "test_macros.h" // We are not using MinimalElementType.h because MinimalElementType is not -// default consructible and uninitialized storage does not work in constexpr. +// default constructible and uninitialized storage does not work in constexpr. // Same as MinimalElementType but with a defaulted default constructor struct MyMinimalElementType { diff --git a/libcxx/test/std/containers/views/mdspan/mdspan/conversion.pass.cpp b/libcxx/test/std/containers/views/mdspan/mdspan/conversion.pass.cpp index 63a673f87b41..b587d904a061 100644 --- a/libcxx/test/std/containers/views/mdspan/mdspan/conversion.pass.cpp +++ b/libcxx/test/std/containers/views/mdspan/mdspan/conversion.pass.cpp @@ -232,7 +232,7 @@ int main(int, char**) { test<t, o, t, t, t, t, t, t, conv_test_accessor_c<int, t, t, o, o>>(conv_test_accessor_nc<int, t, o>()); // FIXME: these tests trigger what appears to be a compiler bug on MINGW32 with --target=x86_64-w64-windows-gnu // https://godbolt.org/z/KK8aj5bs7 -// Bug report: https://github.com/llvm/llvm-project/issues/64077 +// Bug report: https://llvm.org/PR64077 #ifndef __MINGW32__ test<t, t, t, o, t, t, t, t, conv_test_accessor_c<int, o, t, t, t>>(conv_test_accessor_nc<int, t, t>()); test<t, t, t, t, t, t, t, t, conv_test_accessor_c<int, o, o, o, o>>(conv_test_accessor_nc<int, t, o>()); diff --git a/libcxx/test/std/containers/views/views.span/span.cons/copy.pass.cpp b/libcxx/test/std/containers/views/views.span/span.cons/copy.pass.cpp index d3990fd60a45..aa284c58171f 100644 --- a/libcxx/test/std/containers/views/views.span/span.cons/copy.pass.cpp +++ b/libcxx/test/std/containers/views/views.span/span.cons/copy.pass.cpp @@ -95,7 +95,7 @@ constexpr bool test_all() { test<std::string>(); test<const std::string>(); - // Regression test for https://github.com/llvm/llvm-project/issues/104496 + // Regression test for https://llvm.org/PR104496 { struct Incomplete; std::span<Incomplete> x; diff --git a/libcxx/test/std/containers/views/views.span/span.cons/initializer_list.pass.cpp b/libcxx/test/std/containers/views/views.span/span.cons/initializer_list.pass.cpp index bc76e23fea3c..b413b71ec945 100644 --- a/libcxx/test/std/containers/views/views.span/span.cons/initializer_list.pass.cpp +++ b/libcxx/test/std/containers/views/views.span/span.cons/initializer_list.pass.cpp @@ -34,7 +34,7 @@ static_assert(!ConstElementType<std::span<int>>); static_assert(ConstElementType<std::span<const int, 94>>); static_assert(!ConstElementType<std::span<int, 94>>); -// Constructor constraings +// Constructor constraints template <typename I, typename T, std::size_t... N> concept HasInitializerListCtr = requires(I il) { std::span<T, N...>{il}; }; |
