diff options
Diffstat (limited to 'libcxx/test/containers/associative/set')
29 files changed, 1259 insertions, 3 deletions
diff --git a/libcxx/test/containers/associative/set/clear.pass.cpp b/libcxx/test/containers/associative/set/clear.pass.cpp index aa632c7f1d9..c6e01023f65 100644 --- a/libcxx/test/containers/associative/set/clear.pass.cpp +++ b/libcxx/test/containers/associative/set/clear.pass.cpp @@ -16,6 +16,8 @@ #include <set> #include <cassert> +#include "../../min_allocator.h" + int main() { { @@ -37,4 +39,25 @@ int main() m.clear(); assert(m.size() == 0); } +#if __cplusplus >= 201103L + { + typedef std::set<int, std::less<int>, min_allocator<int>> M; + typedef int V; + V ar[] = + { + 1, + 2, + 3, + 4, + 5, + 6, + 7, + 8 + }; + M m(ar, ar + sizeof(ar)/sizeof(ar[0])); + assert(m.size() == 8); + m.clear(); + assert(m.size() == 0); + } +#endif } diff --git a/libcxx/test/containers/associative/set/count.pass.cpp b/libcxx/test/containers/associative/set/count.pass.cpp index 4a678a198a7..7d7a31ad0db 100644 --- a/libcxx/test/containers/associative/set/count.pass.cpp +++ b/libcxx/test/containers/associative/set/count.pass.cpp @@ -16,11 +16,49 @@ #include <set> #include <cassert> +#include "../../min_allocator.h" + int main() { - typedef int V; - typedef std::set<int> M; { + typedef int V; + typedef std::set<int> M; + typedef M::size_type R; + V ar[] = + { + 5, + 6, + 7, + 8, + 9, + 10, + 11, + 12 + }; + const M m(ar, ar+sizeof(ar)/sizeof(ar[0])); + R r = m.count(5); + assert(r == 1); + r = m.count(6); + assert(r == 1); + r = m.count(7); + assert(r == 1); + r = m.count(8); + assert(r == 1); + r = m.count(9); + assert(r == 1); + r = m.count(10); + assert(r == 1); + r = m.count(11); + assert(r == 1); + r = m.count(12); + assert(r == 1); + r = m.count(4); + assert(r == 0); + } +#if __cplusplus >= 201103L + { + typedef int V; + typedef std::set<int, std::less<int>, min_allocator<int>> M; typedef M::size_type R; V ar[] = { @@ -53,4 +91,5 @@ int main() r = m.count(4); assert(r == 0); } +#endif } diff --git a/libcxx/test/containers/associative/set/emplace.pass.cpp b/libcxx/test/containers/associative/set/emplace.pass.cpp index e322ff1df6a..69fdbeeb6b2 100644 --- a/libcxx/test/containers/associative/set/emplace.pass.cpp +++ b/libcxx/test/containers/associative/set/emplace.pass.cpp @@ -19,6 +19,7 @@ #include "../../Emplaceable.h" #include "../../DefaultOnly.h" +#include "../../min_allocator.h" int main() { @@ -73,5 +74,17 @@ int main() assert(m.size() == 1); assert(*r.first == 2); } +#if __cplusplus >= 201103L + { + typedef std::set<int, std::less<int>, min_allocator<int>> M; + typedef std::pair<M::iterator, bool> R; + M m; + R r = m.emplace(M::value_type(2)); + assert(r.second); + assert(r.first == m.begin()); + assert(m.size() == 1); + assert(*r.first == 2); + } +#endif #endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES } diff --git a/libcxx/test/containers/associative/set/emplace_hint.pass.cpp b/libcxx/test/containers/associative/set/emplace_hint.pass.cpp index be5d73dac93..8e7fbbc4033 100644 --- a/libcxx/test/containers/associative/set/emplace_hint.pass.cpp +++ b/libcxx/test/containers/associative/set/emplace_hint.pass.cpp @@ -19,6 +19,7 @@ #include "../../Emplaceable.h" #include "../../DefaultOnly.h" +#include "../../min_allocator.h" int main() { @@ -67,5 +68,16 @@ int main() assert(m.size() == 1); assert(*r == 2); } +#if __cplusplus >= 201103L + { + typedef std::set<int, std::less<int>, min_allocator<int>> M; + typedef M::iterator R; + M m; + R r = m.emplace_hint(m.cend(), M::value_type(2)); + assert(r == m.begin()); + assert(m.size() == 1); + assert(*r == 2); + } +#endif #endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES } diff --git a/libcxx/test/containers/associative/set/empty.pass.cpp b/libcxx/test/containers/associative/set/empty.pass.cpp index 615bc61dd44..305ae39ff90 100644 --- a/libcxx/test/containers/associative/set/empty.pass.cpp +++ b/libcxx/test/containers/associative/set/empty.pass.cpp @@ -16,8 +16,11 @@ #include <set> #include <cassert> +#include "../../min_allocator.h" + int main() { + { typedef std::set<int> M; M m; assert(m.empty()); @@ -25,4 +28,16 @@ int main() assert(!m.empty()); m.clear(); assert(m.empty()); + } +#if __cplusplus >= 201103L + { + typedef std::set<int, std::less<int>, min_allocator<int>> M; + M m; + assert(m.empty()); + m.insert(M::value_type(1)); + assert(!m.empty()); + m.clear(); + assert(m.empty()); + } +#endif } diff --git a/libcxx/test/containers/associative/set/equal_range.pass.cpp b/libcxx/test/containers/associative/set/equal_range.pass.cpp index 7b17a471371..95a933ef436 100644 --- a/libcxx/test/containers/associative/set/equal_range.pass.cpp +++ b/libcxx/test/containers/associative/set/equal_range.pass.cpp @@ -17,8 +17,11 @@ #include <set> #include <cassert> +#include "../../min_allocator.h" + int main() { + { typedef int V; typedef std::set<int> M; { @@ -153,4 +156,75 @@ int main() assert(r.first == next(m.begin(), 8)); assert(r.second == next(m.begin(), 8)); } + } +#if __cplusplus >= 201103L + { + typedef int V; + typedef std::set<int, std::less<int>, min_allocator<int>> M; + typedef std::pair<M::iterator, M::iterator> R; + V ar[] = + { + 5, + 7, + 9, + 11, + 13, + 15, + 17, + 19 + }; + M m(ar, ar+sizeof(ar)/sizeof(ar[0])); + R r = m.equal_range(5); + assert(r.first == next(m.begin(), 0)); + assert(r.second == next(m.begin(), 1)); + r = m.equal_range(7); + assert(r.first == next(m.begin(), 1)); + assert(r.second == next(m.begin(), 2)); + r = m.equal_range(9); + assert(r.first == next(m.begin(), 2)); + assert(r.second == next(m.begin(), 3)); + r = m.equal_range(11); + assert(r.first == next(m.begin(), 3)); + assert(r.second == next(m.begin(), 4)); + r = m.equal_range(13); + assert(r.first == next(m.begin(), 4)); + assert(r.second == next(m.begin(), 5)); + r = m.equal_range(15); + assert(r.first == next(m.begin(), 5)); + assert(r.second == next(m.begin(), 6)); + r = m.equal_range(17); + assert(r.first == next(m.begin(), 6)); + assert(r.second == next(m.begin(), 7)); + r = m.equal_range(19); + assert(r.first == next(m.begin(), 7)); + assert(r.second == next(m.begin(), 8)); + r = m.equal_range(4); + assert(r.first == next(m.begin(), 0)); + assert(r.second == next(m.begin(), 0)); + r = m.equal_range(6); + assert(r.first == next(m.begin(), 1)); + assert(r.second == next(m.begin(), 1)); + r = m.equal_range(8); + assert(r.first == next(m.begin(), 2)); + assert(r.second == next(m.begin(), 2)); + r = m.equal_range(10); + assert(r.first == next(m.begin(), 3)); + assert(r.second == next(m.begin(), 3)); + r = m.equal_range(12); + assert(r.first == next(m.begin(), 4)); + assert(r.second == next(m.begin(), 4)); + r = m.equal_range(14); + assert(r.first == next(m.begin(), 5)); + assert(r.second == next(m.begin(), 5)); + r = m.equal_range(16); + assert(r.first == next(m.begin(), 6)); + assert(r.second == next(m.begin(), 6)); + r = m.equal_range(18); + assert(r.first == next(m.begin(), 7)); + assert(r.second == next(m.begin(), 7)); + r = m.equal_range(20); + assert(r.first == next(m.begin(), 8)); + assert(r.second == next(m.begin(), 8)); + } +#endif } diff --git a/libcxx/test/containers/associative/set/erase_iter.pass.cpp b/libcxx/test/containers/associative/set/erase_iter.pass.cpp index 949e973961d..f05d4819e07 100644 --- a/libcxx/test/containers/associative/set/erase_iter.pass.cpp +++ b/libcxx/test/containers/associative/set/erase_iter.pass.cpp @@ -16,6 +16,8 @@ #include <set> #include <cassert> +#include "../../min_allocator.h" + int main() { { @@ -96,4 +98,84 @@ int main() assert(i == m.begin()); assert(i == m.end()); } +#if __cplusplus >= 201103L + { + typedef std::set<int, std::less<int>, min_allocator<int>> M; + typedef int V; + typedef M::iterator I; + V ar[] = + { + 1, + 2, + 3, + 4, + 5, + 6, + 7, + 8 + }; + M m(ar, ar + sizeof(ar)/sizeof(ar[0])); + assert(m.size() == 8); + I i = m.erase(next(m.cbegin(), 3)); + assert(m.size() == 7); + assert(i == next(m.begin(), 3)); + assert(*next(m.begin(), 0) == 1); + assert(*next(m.begin(), 1) == 2); + assert(*next(m.begin(), 2) == 3); + assert(*next(m.begin(), 3) == 5); + assert(*next(m.begin(), 4) == 6); + assert(*next(m.begin(), 5) == 7); + assert(*next(m.begin(), 6) == 8); + + i = m.erase(next(m.cbegin(), 0)); + assert(m.size() == 6); + assert(i == m.begin()); + assert(*next(m.begin(), 0) == 2); + assert(*next(m.begin(), 1) == 3); + assert(*next(m.begin(), 2) == 5); + assert(*next(m.begin(), 3) == 6); + assert(*next(m.begin(), 4) == 7); + assert(*next(m.begin(), 5) == 8); + + i = m.erase(next(m.cbegin(), 5)); + assert(m.size() == 5); + assert(i == m.end()); + assert(*next(m.begin(), 0) == 2); + assert(*next(m.begin(), 1) == 3); + assert(*next(m.begin(), 2) == 5); + assert(*next(m.begin(), 3) == 6); + assert(*next(m.begin(), 4) == 7); + + i = m.erase(next(m.cbegin(), 1)); + assert(m.size() == 4); + assert(i == next(m.begin())); + assert(*next(m.begin(), 0) == 2); + assert(*next(m.begin(), 1) == 5); + assert(*next(m.begin(), 2) == 6); + assert(*next(m.begin(), 3) == 7); + + i = m.erase(next(m.cbegin(), 2)); + assert(m.size() == 3); + assert(i == next(m.begin(), 2)); + assert(*next(m.begin(), 0) == 2); + assert(*next(m.begin(), 1) == 5); + assert(*next(m.begin(), 2) == 7); + + i = m.erase(next(m.cbegin(), 2)); + assert(m.size() == 2); + assert(i == next(m.begin(), 2)); + assert(*next(m.begin(), 0) == 2); + assert(*next(m.begin(), 1) == 5); + + i = m.erase(next(m.cbegin(), 0)); + assert(m.size() == 1); + assert(i == next(m.begin(), 0)); + assert(*next(m.begin(), 0) == 5); + + i = m.erase(m.cbegin()); + assert(m.size() == 0); + assert(i == m.begin()); + assert(i == m.end()); + } +#endif } diff --git a/libcxx/test/containers/associative/set/erase_iter_iter.pass.cpp b/libcxx/test/containers/associative/set/erase_iter_iter.pass.cpp index 283b8b57a2f..953d1be8bd4 100644 --- a/libcxx/test/containers/associative/set/erase_iter_iter.pass.cpp +++ b/libcxx/test/containers/associative/set/erase_iter_iter.pass.cpp @@ -16,6 +16,8 @@ #include <set> #include <cassert> +#include "../../min_allocator.h" + int main() { { @@ -76,4 +78,64 @@ int main() assert(m.size() == 0); assert(i == m.end()); } +#if __cplusplus >= 201103L + { + typedef std::set<int, std::less<int>, min_allocator<int>> M; + typedef int V; + typedef M::iterator I; + V ar[] = + { + 1, + 2, + 3, + 4, + 5, + 6, + 7, + 8 + }; + M m(ar, ar + sizeof(ar)/sizeof(ar[0])); + assert(m.size() == 8); + I i = m.erase(next(m.cbegin(), 5), next(m.cbegin(), 5)); + assert(m.size() == 8); + assert(i == next(m.begin(), 5)); + assert(*next(m.begin(), 0) == 1); + assert(*next(m.begin(), 1) == 2); + assert(*next(m.begin(), 2) == 3); + assert(*next(m.begin(), 3) == 4); + assert(*next(m.begin(), 4) == 5); + assert(*next(m.begin(), 5) == 6); + assert(*next(m.begin(), 6) == 7); + assert(*next(m.begin(), 7) == 8); + + i = m.erase(next(m.cbegin(), 3), next(m.cbegin(), 4)); + assert(m.size() == 7); + assert(i == next(m.begin(), 3)); + assert(*next(m.begin(), 0) == 1); + assert(*next(m.begin(), 1) == 2); + assert(*next(m.begin(), 2) == 3); + assert(*next(m.begin(), 3) == 5); + assert(*next(m.begin(), 4) == 6); + assert(*next(m.begin(), 5) == 7); + assert(*next(m.begin(), 6) == 8); + + i = m.erase(next(m.cbegin(), 2), next(m.cbegin(), 5)); + assert(m.size() == 4); + assert(i == next(m.begin(), 2)); + assert(*next(m.begin(), 0) == 1); + assert(*next(m.begin(), 1) == 2); + assert(*next(m.begin(), 2) == 7); + assert(*next(m.begin(), 3) == 8); + + i = m.erase(next(m.cbegin(), 0), next(m.cbegin(), 2)); + assert(m.size() == 2); + assert(i == next(m.begin(), 0)); + assert(*next(m.begin(), 0) == 7); + assert(*next(m.begin(), 1) == 8); + + i = m.erase(m.cbegin(), m.cend()); + assert(m.size() == 0); + assert(i == m.end()); + } +#endif } diff --git a/libcxx/test/containers/associative/set/erase_key.pass.cpp b/libcxx/test/containers/associative/set/erase_key.pass.cpp index 61455b6c94c..12ee0af980e 100644 --- a/libcxx/test/containers/associative/set/erase_key.pass.cpp +++ b/libcxx/test/containers/associative/set/erase_key.pass.cpp @@ -16,6 +16,8 @@ #include <set> #include <cassert> +#include "../../min_allocator.h" + int main() { { @@ -107,4 +109,95 @@ int main() assert(m.size() == 0); assert(i == 1); } +#if __cplusplus >= 201103L + { + typedef std::set<int, std::less<int>, min_allocator<int>> M; + typedef int V; + typedef M::size_type I; + V ar[] = + { + 1, + 2, + 3, + 4, + 5, + 6, + 7, + 8 + }; + M m(ar, ar + sizeof(ar)/sizeof(ar[0])); + assert(m.size() == 8); + I i = m.erase(9); + assert(m.size() == 8); + assert(i == 0); + assert(*next(m.begin(), 0) == 1); + assert(*next(m.begin(), 1) == 2); + assert(*next(m.begin(), 2) == 3); + assert(*next(m.begin(), 3) == 4); + assert(*next(m.begin(), 4) == 5); + assert(*next(m.begin(), 5) == 6); + assert(*next(m.begin(), 6) == 7); + assert(*next(m.begin(), 7) == 8); + + i = m.erase(4); + assert(m.size() == 7); + assert(i == 1); + assert(*next(m.begin(), 0) == 1); + assert(*next(m.begin(), 1) == 2); + assert(*next(m.begin(), 2) == 3); + assert(*next(m.begin(), 3) == 5); + assert(*next(m.begin(), 4) == 6); + assert(*next(m.begin(), 5) == 7); + assert(*next(m.begin(), 6) == 8); + + i = m.erase(1); + assert(m.size() == 6); + assert(i == 1); + assert(*next(m.begin(), 0) == 2); + assert(*next(m.begin(), 1) == 3); + assert(*next(m.begin(), 2) == 5); + assert(*next(m.begin(), 3) == 6); + assert(*next(m.begin(), 4) == 7); + assert(*next(m.begin(), 5) == 8); + + i = m.erase(8); + assert(m.size() == 5); + assert(i == 1); + assert(*next(m.begin(), 0) == 2); + assert(*next(m.begin(), 1) == 3); + assert(*next(m.begin(), 2) == 5); + assert(*next(m.begin(), 3) == 6); + assert(*next(m.begin(), 4) == 7); + + i = m.erase(3); + assert(m.size() == 4); + assert(i == 1); + assert(*next(m.begin(), 0) == 2); + assert(*next(m.begin(), 1) == 5); + assert(*next(m.begin(), 2) == 6); + assert(*next(m.begin(), 3) == 7); + + i = m.erase(6); + assert(m.size() == 3); + assert(i == 1); + assert(*next(m.begin(), 0) == 2); + assert(*next(m.begin(), 1) == 5); + assert(*next(m.begin(), 2) == 7); + + i = m.erase(7); + assert(m.size() == 2); + assert(i == 1); + assert(*next(m.begin(), 0) == 2); + assert(*next(m.begin(), 1) == 5); + + i = m.erase(2); + assert(m.size() == 1); + assert(i == 1); + assert(*next(m.begin(), 0) == 5); + + i = m.erase(5); + assert(m.size() == 0); + assert(i == 1); + } +#endif } diff --git a/libcxx/test/containers/associative/set/find.pass.cpp b/libcxx/test/containers/associative/set/find.pass.cpp index 96ab73b37b5..b661898a861 100644 --- a/libcxx/test/containers/associative/set/find.pass.cpp +++ b/libcxx/test/containers/associative/set/find.pass.cpp @@ -17,8 +17,11 @@ #include <set> #include <cassert> +#include "../../min_allocator.h" + int main() { + { typedef int V; typedef std::set<int> M; { @@ -87,4 +90,77 @@ int main() r = m.find(4); assert(r == next(m.begin(), 8)); } + } +#if __cplusplus >= 201103L + { + typedef int V; + typedef std::set<int, std::less<int>, min_allocator<int>> M; + { + typedef M::iterator R; + V ar[] = + { + 5, + 6, + 7, + 8, + 9, + 10, + 11, + 12 + }; + M m(ar, ar+sizeof(ar)/sizeof(ar[0])); + R r = m.find(5); + assert(r == m.begin()); + r = m.find(6); + assert(r == next(m.begin())); + r = m.find(7); + assert(r == next(m.begin(), 2)); + r = m.find(8); + assert(r == next(m.begin(), 3)); + r = m.find(9); + assert(r == next(m.begin(), 4)); + r = m.find(10); + assert(r == next(m.begin(), 5)); + r = m.find(11); + assert(r == next(m.begin(), 6)); + r = m.find(12); + assert(r == next(m.begin(), 7)); + r = m.find(4); + assert(r == next(m.begin(), 8)); + } + { + typedef M::const_iterator R; + V ar[] = + { + 5, + 6, + 7, + 8, + 9, + 10, + 11, + 12 + }; + const M m(ar, ar+sizeof(ar)/sizeof(ar[0])); + R r = m.find(5); + assert(r == m.begin()); + r = m.find(6); + assert(r == next(m.begin())); + r = m.find(7); + assert(r == next(m.begin(), 2)); + r = m.find(8); + assert(r == next(m.begin(), 3)); + r = m.find(9); + assert(r == next(m.begin(), 4)); + r = m.find(10); + assert(r == next(m.begin(), 5)); + r = m.find(11); + assert(r == next(m.begin(), 6)); + r = m.find(12); + assert(r == next(m.begin(), 7)); + r = m.find(4); + assert(r == next(m.begin(), 8)); + } + } +#endif } diff --git a/libcxx/test/containers/associative/set/insert_cv.pass.cpp b/libcxx/test/containers/associative/set/insert_cv.pass.cpp index 9cbb61618c1..eabd1a8722a 100644 --- a/libcxx/test/containers/associative/set/insert_cv.pass.cpp +++ b/libcxx/test/containers/associative/set/insert_cv.pass.cpp @@ -16,6 +16,8 @@ #include <set> #include <cassert> +#include "../../min_allocator.h" + int main() { { @@ -46,4 +48,34 @@ int main() assert(m.size() == 3); assert(*r.first == 3); } +#if __cplusplus >= 201103L + { + typedef std::set<int, std::less<int>, min_allocator<int>> M; + typedef std::pair<M::iterator, bool> R; + M m; + R r = m.insert(M::value_type(2)); + assert(r.second); + assert(r.first == m.begin()); + assert(m.size() == 1); + assert(*r.first == 2); + + r = m.insert(M::value_type(1)); + assert(r.second); + assert(r.first == m.begin()); + assert(m.size() == 2); + assert(*r.first == 1); + + r = m.insert(M::value_type(3)); + assert(r.second); + assert(r.first == prev(m.end())); + assert(m.size() == 3); + assert(*r.first == 3); + + r = m.insert(M::value_type(3)); + assert(!r.second); + assert(r.first == prev(m.end())); + assert(m.size() == 3); + assert(*r.first == 3); + } +#endif } diff --git a/libcxx/test/containers/associative/set/insert_initializer_list.pass.cpp b/libcxx/test/containers/associative/set/insert_initializer_list.pass.cpp index e9245cd46b2..d75e8a8bcbd 100644 --- a/libcxx/test/containers/associative/set/insert_initializer_list.pass.cpp +++ b/libcxx/test/containers/associative/set/insert_initializer_list.pass.cpp @@ -16,9 +16,12 @@ #include <set> #include <cassert> +#include "../../min_allocator.h" + int main() { #ifndef _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS + { typedef std::set<int> C; typedef C::value_type V; C m = {10, 8}; @@ -34,5 +37,25 @@ int main() assert(*++i == V(6)); assert(*++i == V(8)); assert(*++i == V(10)); + } +#if __cplusplus >= 201103L + { + typedef std::set<int, std::less<int>, min_allocator<int>> C; + typedef C::value_type V; + C m = {10, 8}; + m.insert({1, 2, 3, 4, 5, 6}); + assert(m.size() == 8); + assert(distance(m.begin(), m.end()) == m.size()); + C::const_iterator i = m.cbegin(); + assert(*i == V(1)); + assert(*++i == V(2)); + assert(*++i == V(3)); + assert(*++i == V(4)); + assert(*++i == V(5)); + assert(*++i == V(6)); + assert(*++i == V(8)); + assert(*++i == V(10)); + } +#endif #endif // _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS } diff --git a/libcxx/test/containers/associative/set/insert_iter_cv.pass.cpp b/libcxx/test/containers/associative/set/insert_iter_cv.pass.cpp index 78ce18337c9..d86d40e8909 100644 --- a/libcxx/test/containers/associative/set/insert_iter_cv.pass.cpp +++ b/libcxx/test/containers/associative/set/insert_iter_cv.pass.cpp @@ -16,6 +16,8 @@ #include <set> #include <cassert> +#include "../../min_allocator.h" + int main() { { @@ -42,4 +44,30 @@ int main() assert(m.size() == 3); assert(*r == 3); } +#if __cplusplus >= 201103L + { + typedef std::set<int, std::less<int>, min_allocator<int>> M; + typedef M::iterator R; + M m; + R r = m.insert(m.cend(), M::value_type(2)); + assert(r == m.begin()); + assert(m.size() == 1); + assert(*r == 2); + + r = m.insert(m.cend(), M::value_type(1)); + assert(r == m.begin()); + assert(m.size() == 2); + assert(*r == 1); + + r = m.insert(m.cend(), M::value_type(3)); + assert(r == prev(m.end())); + assert(m.size() == 3); + assert(*r == 3); + + r = m.insert(m.cend(), M::value_type(3)); + assert(r == prev(m.end())); + assert(m.size() == 3); + assert(*r == 3); + } +#endif } diff --git a/libcxx/test/containers/associative/set/insert_iter_iter.pass.cpp b/libcxx/test/containers/associative/set/insert_iter_iter.pass.cpp index 3bc3a61544d..d99dbe365ac 100644 --- a/libcxx/test/containers/associative/set/insert_iter_iter.pass.cpp +++ b/libcxx/test/containers/associative/set/insert_iter_iter.pass.cpp @@ -18,6 +18,7 @@ #include <cassert> #include "test_iterators.h" +#include "../../min_allocator.h" int main() { @@ -44,4 +45,29 @@ int main() assert(*next(m.begin()) == 2); assert(*next(m.begin(), 2) == 3); } +#if __cplusplus >= 201103L + { + 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(input_iterator<const V*>(ar), + input_iterator<const V*>(ar + sizeof(ar)/sizeof(ar[0]))); + assert(m.size() == 3); + assert(*m.begin() == 1); + assert(*next(m.begin()) == 2); + assert(*next(m.begin(), 2) == 3); + } +#endif } diff --git a/libcxx/test/containers/associative/set/insert_iter_rv.pass.cpp b/libcxx/test/containers/associative/set/insert_iter_rv.pass.cpp index fdf9f05972c..cf2dcbf91bb 100644 --- a/libcxx/test/containers/associative/set/insert_iter_rv.pass.cpp +++ b/libcxx/test/containers/associative/set/insert_iter_rv.pass.cpp @@ -17,6 +17,7 @@ #include <cassert> #include "../../MoveOnly.h" +#include "../../min_allocator.h" int main() { @@ -45,5 +46,31 @@ int main() assert(m.size() == 3); assert(*r == 3); } +#if __cplusplus >= 201103L + { + typedef std::set<MoveOnly, std::less<MoveOnly>, min_allocator<MoveOnly>> M; + typedef M::iterator R; + M m; + R r = m.insert(m.cend(), M::value_type(2)); + assert(r == m.begin()); + assert(m.size() == 1); + assert(*r == 2); + + r = m.insert(m.cend(), M::value_type(1)); + assert(r == m.begin()); + assert(m.size() == 2); + assert(*r == 1); + + r = m.insert(m.cend(), M::value_type(3)); + assert(r == prev(m.end())); + assert(m.size() == 3); + assert(*r == 3); + + r = m.insert(m.cend(), M::value_type(3)); + assert(r == prev(m.end())); + assert(m.size() == 3); + assert(*r == 3); + } +#endif #endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES } diff --git a/libcxx/test/containers/associative/set/insert_rv.pass.cpp b/libcxx/test/containers/associative/set/insert_rv.pass.cpp index c7e868d7911..0b58af6cad0 100644 --- a/libcxx/test/containers/associative/set/insert_rv.pass.cpp +++ b/libcxx/test/containers/associative/set/insert_rv.pass.cpp @@ -17,6 +17,7 @@ #include <cassert> #include "../../MoveOnly.h" +#include "../../min_allocator.h" int main() { @@ -49,5 +50,35 @@ int main() assert(m.size() == 3); assert(*r.first == 3); } +#if __cplusplus >= 201103L + { + typedef std::set<MoveOnly, std::less<MoveOnly>, min_allocator<MoveOnly>> M; + typedef std::pair<M::iterator, bool> R; + M m; + R r = m.insert(M::value_type(2)); + assert(r.second); + assert(r.first == m.begin()); + assert(m.size() == 1); + assert(*r.first == 2); + + r = m.insert(M::value_type(1)); + assert(r.second); + assert(r.first == m.begin()); + assert(m.size() == 2); + assert(*r.first == 1); + + r = m.insert(M::value_type(3)); + assert(r.second); + assert(r.first == prev(m.end())); + assert(m.size() == 3); + assert(*r.first == 3); + + r = m.insert(M::value_type(3)); + assert(!r.second); + assert(r.first == prev(m.end())); + assert(m.size() == 3); + assert(*r.first == 3); + } +#endif #endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES } diff --git a/libcxx/test/containers/associative/set/iterator.pass.cpp b/libcxx/test/containers/associative/set/iterator.pass.cpp index eb401951aaa..b509aea0cb7 100644 --- a/libcxx/test/containers/associative/set/iterator.pass.cpp +++ b/libcxx/test/containers/associative/set/iterator.pass.cpp @@ -29,6 +29,8 @@ #include <set> #include <cassert> +#include "../../min_allocator.h" + int main() { { @@ -104,9 +106,89 @@ int main() assert(std::distance(m.cbegin(), m.cend()) == m.size()); assert(std::distance(m.rbegin(), m.rend()) == m.size()); assert(std::distance(m.crbegin(), m.crend()) == m.size()); - std::set<int, double>::const_iterator i; + std::set<int>::const_iterator i; + i = m.begin(); + for (int j = 1; j <= m.size(); ++j, ++i) + assert(*i == j); + } +#if __cplusplus >= 201103L + { + typedef int V; + V ar[] = + { + 1, + 1, + 1, + 2, + 2, + 2, + 3, + 3, + 3, + 4, + 4, + 4, + 5, + 5, + 5, + 6, + 6, + 6, + 7, + 7, + 7, + 8, + 8, + 8 + }; + std::set<int, std::less<int>, min_allocator<int>> m(ar, ar+sizeof(ar)/sizeof(ar[0])); + assert(std::distance(m.begin(), m.end()) == m.size()); + assert(std::distance(m.rbegin(), m.rend()) == m.size()); + std::set<int, std::less<int>, min_allocator<int>>::iterator i; + i = m.begin(); + std::set<int, std::less<int>, min_allocator<int>>::const_iterator k = i; + assert(i == k); + for (int j = 1; j <= m.size(); ++j, ++i) + assert(*i == j); + } + { + typedef int V; + V ar[] = + { + 1, + 1, + 1, + 2, + 2, + 2, + 3, + 3, + 3, + 4, + 4, + 4, + 5, + 5, + 5, + 6, + 6, + 6, + 7, + 7, + 7, + 8, + 8, + 8 + }; + const std::set<int, std::less<int>, min_allocator<int>> m(ar, ar+sizeof(ar)/sizeof(ar[0])); + assert(std::distance(m.begin(), m.end()) == m.size()); + assert(std::distance(m.cbegin(), m.cend()) == m.size()); + assert(std::distance(m.rbegin(), m.rend()) == m.size()); + assert(std::distance(m.crbegin(), m.crend()) == m.size()); + std::set<int, std::less<int>, min_allocator<int>>::const_iterator i; i = m.begin(); for (int j = 1; j <= m.size(); ++j, ++i) assert(*i == j); } +#endif } diff --git a/libcxx/test/containers/associative/set/lower_bound.pass.cpp b/libcxx/test/containers/associative/set/lower_bound.pass.cpp index 8703c8a16b7..072a5879157 100644 --- a/libcxx/test/containers/associative/set/lower_bound.pass.cpp +++ b/libcxx/test/containers/associative/set/lower_bound.pass.cpp @@ -17,8 +17,11 @@ #include <set> #include <cassert> +#include "../../min_allocator.h" + int main() { + { typedef int V; typedef std::set<int> M; { @@ -119,4 +122,109 @@ int main() r = m.lower_bound(20); assert(r == next(m.begin(), 8)); } + } +#if __cplusplus >= 201103L + { + typedef int V; + typedef std::set<int, std::less<int>, min_allocator<int>> M; + { + typedef M::iterator R; + V ar[] = + { + 5, + 7, + 9, + 11, + 13, + 15, + 17, + 19 + }; + M m(ar, ar+sizeof(ar)/sizeof(ar[0])); + R r = m.lower_bound(5); + assert(r == m.begin()); + r = m.lower_bound(7); + assert(r == next(m.begin())); + r = m.lower_bound(9); + assert(r == next(m.begin(), 2)); + r = m.lower_bound(11); + assert(r == next(m.begin(), 3)); + r = m.lower_bound(13); + assert(r == next(m.begin(), 4)); + r = m.lower_bound(15); + assert(r == next(m.begin(), 5)); + r = m.lower_bound(17); + assert(r == next(m.begin(), 6)); + r = m.lower_bound(19); + assert(r == next(m.begin(), 7)); + r = m.lower_bound(4); + assert(r == next(m.begin(), 0)); + r = m.lower_bound(6); + assert(r == next(m.begin(), 1)); + r = m.lower_bound(8); + assert(r == next(m.begin(), 2)); + r = m.lower_bound(10); + assert(r == next(m.begin(), 3)); + r = m.lower_bound(12); + assert(r == next(m.begin(), 4)); + r = m.lower_bound(14); + assert(r == next(m.begin(), 5)); + r = m.lower_bound(16); + assert(r == next(m.begin(), 6)); + r = m.lower_bound(18); + assert(r == next(m.begin(), 7)); + r = m.lower_bound(20); + assert(r == next(m.begin(), 8)); + } + { + typedef M::const_iterator R; + V ar[] = + { + 5, + 7, + 9, + 11, + 13, + 15, + 17, + 19 + }; + const M m(ar, ar+sizeof(ar)/sizeof(ar[0])); + R r = m.lower_bound(5); + assert(r == m.begin()); + r = m.lower_bound(7); + assert(r == next(m.begin())); + r = m.lower_bound(9); + assert(r == next(m.begin(), 2)); + r = m.lower_bound(11); + assert(r == next(m.begin(), 3)); + r = m.lower_bound(13); + assert(r == next(m.begin(), 4)); + r = m.lower_bound(15); + assert(r == next(m.begin(), 5)); + r = m.lower_bound(17); + assert(r == next(m.begin(), 6)); + r = m.lower_bound(19); + assert(r == next(m.begin(), 7)); + r = m.lower_bound(4); + assert(r == next(m.begin(), 0)); + r = m.lower_bound(6); + assert(r == next(m.begin(), 1)); + r = m.lower_bound(8); + assert(r == next(m.begin(), 2)); + r = m.lower_bound(10); + assert(r == next(m.begin(), 3)); + r = m.lower_bound(12); + assert(r == next(m.begin(), 4)); + r = m.lower_bound(14); + assert(r == next(m.begin(), 5)); + r = m.lower_bound(16); + assert(r == next(m.begin(), 6)); + r = m.lower_bound(18); + assert(r == next(m.begin(), 7)); + r = m.lower_bound(20); + assert(r == next(m.begin(), 8)); + } + } +#endif } diff --git a/libcxx/test/containers/associative/set/max_size.pass.cpp b/libcxx/test/containers/associative/set/max_size.pass.cpp index 493c78514a8..b744b9eb16a 100644 --- a/libcxx/test/containers/associative/set/max_size.pass.cpp +++ b/libcxx/test/containers/associative/set/max_size.pass.cpp @@ -16,9 +16,20 @@ #include <set> #include <cassert> +#include "../../min_allocator.h" + int main() { + { typedef std::set<int> M; M m; assert(m.max_size() != 0); + } +#if __cplusplus >= 201103L + { + typedef std::set<int, std::less<int>, min_allocator<int>> M; + M m; + assert(m.max_size() != 0); + } +#endif } diff --git a/libcxx/test/containers/associative/set/set.cons/assign_initializer_list.pass.cpp b/libcxx/test/containers/associative/set/set.cons/assign_initializer_list.pass.cpp index b37e0d4740e..26f38e94b19 100644 --- a/libcxx/test/containers/associative/set/set.cons/assign_initializer_list.pass.cpp +++ b/libcxx/test/containers/associative/set/set.cons/assign_initializer_list.pass.cpp @@ -16,9 +16,12 @@ #include <set> #include <cassert> +#include "../../../min_allocator.h" + int main() { #ifndef _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS + { typedef std::set<int> C; typedef C::value_type V; C m = {10, 8}; @@ -32,5 +35,23 @@ int main() assert(*++i == V(4)); assert(*++i == V(5)); assert(*++i == V(6)); + } +#if __cplusplus >= 201103L + { + typedef std::set<int, std::less<int>, min_allocator<int>> C; + typedef C::value_type V; + C m = {10, 8}; + m = {1, 2, 3, 4, 5, 6}; + assert(m.size() == 6); + assert(distance(m.begin(), m.end()) == 6); + C::const_iterator i = m.cbegin(); + assert(*i == V(1)); + assert(*++i == V(2)); + assert(*++i == V(3)); + assert(*++i == V(4)); + assert(*++i == V(5)); + assert(*++i == V(6)); + } +#endif #endif // _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS } diff --git a/libcxx/test/containers/associative/set/set.cons/default.pass.cpp b/libcxx/test/containers/associative/set/set.cons/default.pass.cpp index 955a0d37df4..300b4fc6873 100644 --- a/libcxx/test/containers/associative/set/set.cons/default.pass.cpp +++ b/libcxx/test/containers/associative/set/set.cons/default.pass.cpp @@ -16,9 +16,20 @@ #include <set> #include <cassert> +#include "../../../min_allocator.h" + int main() { + { std::set<int> m; assert(m.empty()); assert(m.begin() == m.end()); + } +#if __cplusplus >= 201103L + { + std::set<int, std::less<int>, min_allocator<int>> m; + assert(m.empty()); + assert(m.begin() == m.end()); + } +#endif } diff --git a/libcxx/test/containers/associative/set/set.cons/initializer_list.pass.cpp b/libcxx/test/containers/associative/set/set.cons/initializer_list.pass.cpp index badb107ab86..7d981a11a85 100644 --- a/libcxx/test/containers/associative/set/set.cons/initializer_list.pass.cpp +++ b/libcxx/test/containers/associative/set/set.cons/initializer_list.pass.cpp @@ -16,9 +16,12 @@ #include <set> #include <cassert> +#include "../../../min_allocator.h" + int main() { #ifndef _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS + { typedef std::set<int> C; typedef C::value_type V; C m = {1, 2, 3, 4, 5, 6}; @@ -31,5 +34,22 @@ int main() assert(*++i == V(4)); assert(*++i == V(5)); assert(*++i == V(6)); + } +#if __cplusplus >= 201103L + { + typedef std::set<int, std::less<int>, min_allocator<int>> C; + typedef C::value_type V; + C m = {1, 2, 3, 4, 5, 6}; + assert(m.size() == 6); + assert(distance(m.begin(), m.end()) == 6); + C::const_iterator i = m.cbegin(); + assert(*i == V(1)); + assert(*++i == V(2)); + assert(*++i == V(3)); + assert(*++i == V(4)); + assert(*++i == V(5)); + assert(*++i == V(6)); + } +#endif #endif // _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS } diff --git a/libcxx/test/containers/associative/set/set.cons/iter_iter.pass.cpp b/libcxx/test/containers/associative/set/set.cons/iter_iter.pass.cpp index ff068503e5b..3248257fe2a 100644 --- a/libcxx/test/containers/associative/set/set.cons/iter_iter.pass.cpp +++ b/libcxx/test/containers/associative/set/set.cons/iter_iter.pass.cpp @@ -18,9 +18,11 @@ #include <cassert> #include "test_iterators.h" +#include "../../../min_allocator.h" int main() { + { typedef int V; V ar[] = { @@ -41,4 +43,29 @@ int main() assert(*m.begin() == 1); assert(*next(m.begin()) == 2); assert(*next(m.begin(), 2) == 3); + } +#if __cplusplus >= 201103L + { + typedef int V; + V ar[] = + { + 1, + 1, + 1, + 2, + 2, + 2, + 3, + 3, + 3 + }; + std::set<V, std::less<int>, min_allocator<int>> m(input_iterator<const int*>(ar), + input_iterator<const int*>(ar+sizeof(ar)/sizeof(ar[0]))); + assert(m.size() == 3); + assert(distance(m.begin(), m.end()) == 3); + assert(*m.begin() == 1); + assert(*next(m.begin()) == 2); + assert(*next(m.begin(), 2) == 3); + } +#endif } diff --git a/libcxx/test/containers/associative/set/set.cons/move.pass.cpp b/libcxx/test/containers/associative/set/set.cons/move.pass.cpp index 350513ab995..2d1b37f4e07 100644 --- a/libcxx/test/containers/associative/set/set.cons/move.pass.cpp +++ b/libcxx/test/containers/associative/set/set.cons/move.pass.cpp @@ -18,6 +18,7 @@ #include "../../../test_compare.h" #include "../../../test_allocator.h" +#include "../../../min_allocator.h" int main() { @@ -69,5 +70,38 @@ int main() assert(mo.size() == 0); assert(distance(mo.begin(), mo.end()) == 0); } +#if __cplusplus >= 201103L + { + typedef int V; + V ar[] = + { + 1, + 1, + 1, + 2, + 2, + 2, + 3, + 3, + 3 + }; + typedef test_compare<std::less<int> > C; + typedef min_allocator<V> A; + std::set<int, C, A> mo(ar, ar+sizeof(ar)/sizeof(ar[0]), C(5), A()); + std::set<int, 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() == 1); + assert(*next(m.begin()) == 2); + assert(*next(m.begin(), 2) == 3); + + 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/set/set.cons/move_assign.pass.cpp b/libcxx/test/containers/associative/set/set.cons/move_assign.pass.cpp index 15bcb6d64e2..3e82e28d516 100644 --- a/libcxx/test/containers/associative/set/set.cons/move_assign.pass.cpp +++ b/libcxx/test/containers/associative/set/set.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() { @@ -140,5 +141,46 @@ int main() assert(m3.key_comp() == C(5)); assert(m1.empty()); } +#if __cplusplus >= 201103L + { + typedef MoveOnly V; + typedef test_compare<std::less<MoveOnly> > C; + typedef min_allocator<V> A; + typedef std::set<MoveOnly, C, A> M; + typedef std::move_iterator<V*> I; + V a1[] = + { + V(1), + V(1), + V(1), + V(2), + V(2), + V(2), + V(3), + V(3), + V(3) + }; + M m1(I(a1), I(a1+sizeof(a1)/sizeof(a1[0])), C(5), A()); + V a2[] = + { + V(1), + V(1), + V(1), + V(2), + V(2), + V(2), + V(3), + V(3), + V(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 } diff --git a/libcxx/test/containers/associative/set/set.special/member_swap.pass.cpp b/libcxx/test/containers/associative/set/set.special/member_swap.pass.cpp index 0ac283729ed..aa38fe03577 100644 --- a/libcxx/test/containers/associative/set/set.special/member_swap.pass.cpp +++ b/libcxx/test/containers/associative/set/set.special/member_swap.pass.cpp @@ -16,8 +16,11 @@ #include <set> #include <cassert> +#include "../../../min_allocator.h" + int main() { + { typedef int V; typedef std::set<int> M; { @@ -104,4 +107,95 @@ int main() assert(m1 == m2_save); assert(m2 == m1_save); } + } +#if __cplusplus >= 201103L + { + typedef int V; + typedef std::set<int, std::less<int>, min_allocator<int>> M; + { + V ar1[] = + { + }; + V ar2[] = + { + }; + M m1(ar1, ar1+sizeof(ar1)/sizeof(ar1[0])); + M m2(ar2, ar2+sizeof(ar2)/sizeof(ar2[0])); + M m1_save = m1; + M m2_save = m2; + m1.swap(m2); + assert(m1 == m2_save); + assert(m2 == m1_save); + } + { + V ar1[] = + { + }; + V ar2[] = + { + 5, + 6, + 7, + 8, + 9, + 10, + 11, + 12 + }; + M m1(ar1, ar1+sizeof(ar1)/sizeof(ar1[0])); + M m2(ar2, ar2+sizeof(ar2)/sizeof(ar2[0])); + M m1_save = m1; + M m2_save = m2; + m1.swap(m2); + assert(m1 == m2_save); + assert(m2 == m1_save); + } + { + V ar1[] = + { + 1, + 2, + 3, + 4 + }; + V ar2[] = + { + }; + M m1(ar1, ar1+sizeof(ar1)/sizeof(ar1[0])); + M m2(ar2, ar2+sizeof(ar2)/sizeof(ar2[0])); + M m1_save = m1; + M m2_save = m2; + m1.swap(m2); + assert(m1 == m2_save); + assert(m2 == m1_save); + } + { + V ar1[] = + { + 1, + 2, + 3, + 4 + }; + V ar2[] = + { + 5, + 6, + 7, + 8, + 9, + 10, + 11, + 12 + }; + M m1(ar1, ar1+sizeof(ar1)/sizeof(ar1[0])); + M m2(ar2, ar2+sizeof(ar2)/sizeof(ar2[0])); + M m1_save = m1; + M m2_save = m2; + m1.swap(m2); + assert(m1 == m2_save); + assert(m2 == m1_save); + } + } +#endif } diff --git a/libcxx/test/containers/associative/set/size.pass.cpp b/libcxx/test/containers/associative/set/size.pass.cpp index e2083031191..e1b6b6ce7c8 100644 --- a/libcxx/test/containers/associative/set/size.pass.cpp +++ b/libcxx/test/containers/associative/set/size.pass.cpp @@ -16,8 +16,11 @@ #include <set> #include <cassert> +#include "../../min_allocator.h" + int main() { + { typedef std::set<int> M; M m; assert(m.size() == 0); @@ -33,4 +36,24 @@ int main() assert(m.size() == 1); m.erase(m.begin()); assert(m.size() == 0); + } +#if __cplusplus >= 201103L + { + typedef std::set<int, std::less<int>, min_allocator<int>> M; + M m; + assert(m.size() == 0); + m.insert(M::value_type(2)); + assert(m.size() == 1); + m.insert(M::value_type(1)); + assert(m.size() == 2); + m.insert(M::value_type(3)); + assert(m.size() == 3); + m.erase(m.begin()); + assert(m.size() == 2); + m.erase(m.begin()); + assert(m.size() == 1); + m.erase(m.begin()); + assert(m.size() == 0); + } +#endif } diff --git a/libcxx/test/containers/associative/set/types.pass.cpp b/libcxx/test/containers/associative/set/types.pass.cpp index 5a6b2c3d4cd..04b9ead0381 100644 --- a/libcxx/test/containers/associative/set/types.pass.cpp +++ b/libcxx/test/containers/associative/set/types.pass.cpp @@ -32,8 +32,11 @@ #include <set> #include <type_traits> +#include "../../min_allocator.h" + int main() { + { static_assert((std::is_same<std::set<int>::key_type, int>::value), ""); static_assert((std::is_same<std::set<int>::value_type, int>::value), ""); static_assert((std::is_same<std::set<int>::key_compare, std::less<int> >::value), ""); @@ -45,4 +48,20 @@ int main() static_assert((std::is_same<std::set<int>::const_pointer, const int*>::value), ""); static_assert((std::is_same<std::set<int>::size_type, std::size_t>::value), ""); static_assert((std::is_same<std::set<int>::difference_type, std::ptrdiff_t>::value), ""); + } +#if __cplusplus >= 201103L + { + static_assert((std::is_same<std::set<int, std::less<int>, min_allocator<int>>::key_type, int>::value), ""); + static_assert((std::is_same<std::set<int, std::less<int>, min_allocator<int>>::value_type, int>::value), ""); + static_assert((std::is_same<std::set<int, std::less<int>, min_allocator<int>>::key_compare, std::less<int> >::value), ""); + static_assert((std::is_same<std::set<int, std::less<int>, min_allocator<int>>::value_compare, std::less<int> >::value), ""); + static_assert((std::is_same<std::set<int, std::less<int>, min_allocator<int>>::allocator_type, min_allocator<int> >::value), ""); + static_assert((std::is_same<std::set<int, std::less<int>, min_allocator<int>>::reference, int&>::value), ""); + static_assert((std::is_same<std::set<int, std::less<int>, min_allocator<int>>::const_reference, const int&>::value), ""); + static_assert((std::is_same<std::set<int, std::less<int>, min_allocator<int>>::pointer, min_pointer<int>>::value), ""); + static_assert((std::is_same<std::set<int, std::less<int>, min_allocator<int>>::const_pointer, min_pointer<const int>>::value), ""); + static_assert((std::is_same<std::set<int, std::less<int>, min_allocator<int>>::size_type, std::size_t>::value), ""); + static_assert((std::is_same<std::set<int, std::less<int>, min_allocator<int>>::difference_type, std::ptrdiff_t>::value), ""); + } +#endif } diff --git a/libcxx/test/containers/associative/set/upper_bound.pass.cpp b/libcxx/test/containers/associative/set/upper_bound.pass.cpp index 8f5713308c0..3d000d88e57 100644 --- a/libcxx/test/containers/associative/set/upper_bound.pass.cpp +++ b/libcxx/test/containers/associative/set/upper_bound.pass.cpp @@ -17,8 +17,11 @@ #include <set> #include <cassert> +#include "../../min_allocator.h" + int main() { + { typedef int V; typedef std::set<int> M; { @@ -119,4 +122,109 @@ int main() r = m.upper_bound(20); assert(r == next(m.begin(), 8)); } + } +#if __cplusplus >= 201103L + { + typedef int V; + typedef std::set<int, std::less<int>, min_allocator<int>> M; + { + typedef M::iterator R; + V ar[] = + { + 5, + 7, + 9, + 11, + 13, + 15, + 17, + 19 + }; + M m(ar, ar+sizeof(ar)/sizeof(ar[0])); + R r = m.upper_bound(5); + assert(r == next(m.begin(), 1)); + r = m.upper_bound(7); + assert(r == next(m.begin(), 2)); + r = m.upper_bound(9); + assert(r == next(m.begin(), 3)); + r = m.upper_bound(11); + assert(r == next(m.begin(), 4)); + r = m.upper_bound(13); + assert(r == next(m.begin(), 5)); + r = m.upper_bound(15); + assert(r == next(m.begin(), 6)); + r = m.upper_bound(17); + assert(r == next(m.begin(), 7)); + r = m.upper_bound(19); + assert(r == next(m.begin(), 8)); + r = m.upper_bound(4); + assert(r == next(m.begin(), 0)); + r = m.upper_bound(6); + assert(r == next(m.begin(), 1)); + r = m.upper_bound(8); + assert(r == next(m.begin(), 2)); + r = m.upper_bound(10); + assert(r == next(m.begin(), 3)); + r = m.upper_bound(12); + assert(r == next(m.begin(), 4)); + r = m.upper_bound(14); + assert(r == next(m.begin(), 5)); + r = m.upper_bound(16); + assert(r == next(m.begin(), 6)); + r = m.upper_bound(18); + assert(r == next(m.begin(), 7)); + r = m.upper_bound(20); + assert(r == next(m.begin(), 8)); + } + { + typedef M::const_iterator R; + V ar[] = + { + 5, + 7, + 9, + 11, + 13, + 15, + 17, + 19 + }; + const M m(ar, ar+sizeof(ar)/sizeof(ar[0])); + R r = m.upper_bound(5); + assert(r == next(m.begin(), 1)); + r = m.upper_bound(7); + assert(r == next(m.begin(), 2)); + r = m.upper_bound(9); + assert(r == next(m.begin(), 3)); + r = m.upper_bound(11); + assert(r == next(m.begin(), 4)); + r = m.upper_bound(13); + assert(r == next(m.begin(), 5)); + r = m.upper_bound(15); + assert(r == next(m.begin(), 6)); + r = m.upper_bound(17); + assert(r == next(m.begin(), 7)); + r = m.upper_bound(19); + assert(r == next(m.begin(), 8)); + r = m.upper_bound(4); + assert(r == next(m.begin(), 0)); + r = m.upper_bound(6); + assert(r == next(m.begin(), 1)); + r = m.upper_bound(8); + assert(r == next(m.begin(), 2)); + r = m.upper_bound(10); + assert(r == next(m.begin(), 3)); + r = m.upper_bound(12); + assert(r == next(m.begin(), 4)); + r = m.upper_bound(14); + assert(r == next(m.begin(), 5)); + r = m.upper_bound(16); + assert(r == next(m.begin(), 6)); + r = m.upper_bound(18); + assert(r == next(m.begin(), 7)); + r = m.upper_bound(20); + assert(r == next(m.begin(), 8)); + } + } +#endif } |