diff options
Diffstat (limited to 'libcxx/test/std/containers/associative')
4 files changed, 104 insertions, 42 deletions
diff --git a/libcxx/test/std/containers/associative/map/map.access/max_size.pass.cpp b/libcxx/test/std/containers/associative/map/map.access/max_size.pass.cpp index c67d8b1f674..82a817a1f4a 100644 --- a/libcxx/test/std/containers/associative/map/map.access/max_size.pass.cpp +++ b/libcxx/test/std/containers/associative/map/map.access/max_size.pass.cpp @@ -13,23 +13,39 @@ // size_type max_size() const; -#include <map> #include <cassert> +#include <limits> +#include <map> +#include <type_traits> -#include "min_allocator.h" +#include "test_allocator.h" +#include "test_macros.h" int main() { - { - typedef std::map<int, double> M; - M m; - assert(m.max_size() != 0); + typedef std::pair<const int, int> KV; + { + typedef limited_allocator<KV, 10> A; + typedef std::map<int, int, std::less<int>, A> C; + C c; + assert(c.max_size() <= 10); + LIBCPP_ASSERT(c.max_size() == 10); + } + { + typedef limited_allocator<KV, (size_t)-1> A; + typedef std::map<int, int, std::less<int>, A> C; + const C::difference_type max_dist = + std::numeric_limits<C::difference_type>::max(); + C c; + assert(c.max_size() <= max_dist); + LIBCPP_ASSERT(c.max_size() == max_dist); } -#if TEST_STD_VER >= 11 { - typedef std::map<int, double, std::less<int>, min_allocator<std::pair<const int, double>>> M; - M m; - assert(m.max_size() != 0); + typedef std::map<char, int> C; + const C::difference_type max_dist = + std::numeric_limits<C::difference_type>::max(); + C c; + assert(c.max_size() <= max_dist); + assert(c.max_size() <= alloc_max_size(c.get_allocator())); } -#endif } diff --git a/libcxx/test/std/containers/associative/multimap/max_size.pass.cpp b/libcxx/test/std/containers/associative/multimap/max_size.pass.cpp index b7cf226d8f1..8d5ec1148a2 100644 --- a/libcxx/test/std/containers/associative/multimap/max_size.pass.cpp +++ b/libcxx/test/std/containers/associative/multimap/max_size.pass.cpp @@ -13,23 +13,39 @@ // size_type max_size() const; -#include <map> #include <cassert> +#include <limits> +#include <map> +#include <type_traits> -#include "min_allocator.h" +#include "test_allocator.h" +#include "test_macros.h" int main() { - { - typedef std::multimap<int, double> M; - M m; - assert(m.max_size() != 0); + typedef std::pair<const int, int> KV; + { + typedef limited_allocator<KV, 10> A; + typedef std::multimap<int, int, std::less<int>, A> C; + C c; + assert(c.max_size() <= 10); + LIBCPP_ASSERT(c.max_size() == 10); + } + { + typedef limited_allocator<KV, (size_t)-1> A; + typedef std::multimap<int, int, std::less<int>, A> C; + const C::difference_type max_dist = + std::numeric_limits<C::difference_type>::max(); + C c; + assert(c.max_size() <= max_dist); + LIBCPP_ASSERT(c.max_size() == max_dist); } -#if TEST_STD_VER >= 11 { - typedef std::multimap<int, double, std::less<int>, min_allocator<std::pair<const int, double>>> M; - M m; - assert(m.max_size() != 0); + typedef std::multimap<char, int> C; + const C::difference_type max_dist = + std::numeric_limits<C::difference_type>::max(); + C c; + assert(c.max_size() <= max_dist); + assert(c.max_size() <= alloc_max_size(c.get_allocator())); } -#endif } diff --git a/libcxx/test/std/containers/associative/multiset/max_size.pass.cpp b/libcxx/test/std/containers/associative/multiset/max_size.pass.cpp index 79492c9b1c4..8ca34ba8273 100644 --- a/libcxx/test/std/containers/associative/multiset/max_size.pass.cpp +++ b/libcxx/test/std/containers/associative/multiset/max_size.pass.cpp @@ -13,23 +13,38 @@ // size_type max_size() const; -#include <set> #include <cassert> +#include <limits> +#include <set> +#include <type_traits> -#include "min_allocator.h" +#include "test_allocator.h" +#include "test_macros.h" int main() { { - typedef std::multiset<int> M; - M m; - assert(m.max_size() != 0); + typedef limited_allocator<int, 10> A; + typedef std::multiset<int, std::less<int>, A> C; + C c; + assert(c.max_size() <= 10); + LIBCPP_ASSERT(c.max_size() == 10); + } + { + typedef limited_allocator<int, (size_t)-1> A; + typedef std::multiset<int, std::less<int>, A> C; + const C::difference_type max_dist = + std::numeric_limits<C::difference_type>::max(); + C c; + assert(c.max_size() <= max_dist); + LIBCPP_ASSERT(c.max_size() == max_dist); } -#if TEST_STD_VER >= 11 { - typedef std::multiset<int, std::less<int>, min_allocator<int>> M; - M m; - assert(m.max_size() != 0); + typedef std::multiset<char> C; + const C::difference_type max_dist = + std::numeric_limits<C::difference_type>::max(); + C c; + assert(c.max_size() <= max_dist); + assert(c.max_size() <= alloc_max_size(c.get_allocator())); } -#endif } diff --git a/libcxx/test/std/containers/associative/set/max_size.pass.cpp b/libcxx/test/std/containers/associative/set/max_size.pass.cpp index 9df6a4157e1..c894eb51b1e 100644 --- a/libcxx/test/std/containers/associative/set/max_size.pass.cpp +++ b/libcxx/test/std/containers/associative/set/max_size.pass.cpp @@ -13,23 +13,38 @@ // size_type max_size() const; -#include <set> #include <cassert> +#include <limits> +#include <set> +#include <type_traits> -#include "min_allocator.h" +#include "test_allocator.h" +#include "test_macros.h" int main() { { - typedef std::set<int> M; - M m; - assert(m.max_size() != 0); + typedef limited_allocator<int, 10> A; + typedef std::set<int, std::less<int>, A> C; + C c; + assert(c.max_size() <= 10); + LIBCPP_ASSERT(c.max_size() == 10); + } + { + typedef limited_allocator<int, (size_t)-1> A; + typedef std::set<int, std::less<int>, A> C; + const C::difference_type max_dist = + std::numeric_limits<C::difference_type>::max(); + C c; + assert(c.max_size() <= max_dist); + LIBCPP_ASSERT(c.max_size() == max_dist); } -#if TEST_STD_VER >= 11 { - typedef std::set<int, std::less<int>, min_allocator<int>> M; - M m; - assert(m.max_size() != 0); + typedef std::set<char> C; + const C::difference_type max_dist = + std::numeric_limits<C::difference_type>::max(); + C c; + assert(c.max_size() <= max_dist); + assert(c.max_size() <= alloc_max_size(c.get_allocator())); } -#endif } |

