1 //===----------------------------------------------------------------------===//
3 // The LLVM Compiler Infrastructure
5 // This file is dual licensed under the MIT and the University of Illinois Open
6 // Source Licenses. See LICENSE.TXT for details.
8 //===----------------------------------------------------------------------===//
12 // template <class Value, class Hash = hash<Value>, class Pred = equal_to<Value>,
13 // class Alloc = allocator<Value>>
14 // class unordered_set
16 // explicit unordered_set(const allocator_type& __a);
18 #include <unordered_set>
21 #include "test_macros.h"
22 #include "../../../NotConstructible.h"
23 #include "../../../test_compare.h"
24 #include "../../../test_hash.h"
25 #include "test_allocator.h"
26 #include "min_allocator.h"
31 typedef std::unordered_set<NotConstructible,
32 test_hash<std::hash<NotConstructible> >,
33 test_compare<std::equal_to<NotConstructible> >,
34 test_allocator<NotConstructible>
36 C c(test_allocator<NotConstructible>(10));
37 LIBCPP_ASSERT(c.bucket_count() == 0);
38 assert(c.hash_function() == test_hash<std::hash<NotConstructible> >());
39 assert(c.key_eq() == test_compare<std::equal_to<NotConstructible> >());
40 assert(c.get_allocator() == test_allocator<NotConstructible>(10));
41 assert(c.size() == 0);
43 assert(std::distance(c.begin(), c.end()) == 0);
44 assert(c.load_factor() == 0);
45 assert(c.max_load_factor() == 1);
47 #if TEST_STD_VER >= 11
49 typedef std::unordered_set<NotConstructible,
50 test_hash<std::hash<NotConstructible> >,
51 test_compare<std::equal_to<NotConstructible> >,
52 min_allocator<NotConstructible>
54 C c(min_allocator<NotConstructible>{});
55 LIBCPP_ASSERT(c.bucket_count() == 0);
56 assert(c.hash_function() == test_hash<std::hash<NotConstructible> >());
57 assert(c.key_eq() == test_compare<std::equal_to<NotConstructible> >());
58 assert(c.get_allocator() == min_allocator<NotConstructible>());
59 assert(c.size() == 0);
61 assert(std::distance(c.begin(), c.end()) == 0);
62 assert(c.load_factor() == 0);
63 assert(c.max_load_factor() == 1);
67 typedef NotConstructible T;
68 typedef test_hash<std::hash<T>> HF;
69 typedef test_compare<std::equal_to<T>> Comp;
70 typedef test_allocator<T> A;
71 typedef std::unordered_set<T, HF, Comp, A> C;
75 LIBCPP_ASSERT(c.bucket_count() == 3);
76 assert(c.hash_function() == HF());
77 assert(c.key_eq() == Comp ());
78 assert(c.get_allocator() == a);
79 assert(!(c.get_allocator() == A()));
80 assert(c.size() == 0);
82 assert(std::distance(c.begin(), c.end()) == 0);
83 assert(c.load_factor() == 0);
84 assert(c.max_load_factor() == 1);
87 typedef NotConstructible T;
88 typedef test_hash<std::hash<T>> HF;
89 typedef test_compare<std::equal_to<T>> Comp;
90 typedef test_allocator<T> A;
91 typedef std::unordered_set<T, HF, Comp, A> C;
96 LIBCPP_ASSERT(c.bucket_count() == 4);
97 assert(c.hash_function() == hf);
98 assert(!(c.hash_function() == HF()));
99 assert(c.key_eq() == Comp ());
100 assert(c.get_allocator() == a);
101 assert(!(c.get_allocator() == A()));
102 assert(c.size() == 0);
104 assert(std::distance(c.begin(), c.end()) == 0);
105 assert(c.load_factor() == 0);
106 assert(c.max_load_factor() == 1);