1 //===----------------------------------------------------------------------===// 2 // 3 // The LLVM Compiler Infrastructure 4 // 5 // This file is dual licensed under the MIT and the University of Illinois Open 6 // Source Licenses. See LICENSE.TXT for details. 7 // 8 //===----------------------------------------------------------------------===// 9 10 // <unordered_set> 11 12 // template <class Value, class Hash = hash<Value>, class Pred = equal_to<Value>, 13 // class Alloc = allocator<Value>> 14 // class unordered_multiset 15 16 // unordered_multiset(); 17 18 #include <unordered_set> 19 #include <cassert> 20 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" 27 28 int main() 29 { 30 { 31 typedef std::unordered_multiset<NotConstructible, 32 test_hash<std::hash<NotConstructible> >, 33 test_compare<std::equal_to<NotConstructible> >, 34 test_allocator<NotConstructible> 35 > C; 36 C c; 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>())); 41 assert(c.size() == 0); 42 assert(c.empty()); 43 assert(std::distance(c.begin(), c.end()) == 0); 44 assert(c.load_factor() == 0); 45 assert(c.max_load_factor() == 1); 46 } 47 #if TEST_STD_VER >= 11 48 { 49 typedef std::unordered_multiset<NotConstructible, 50 test_hash<std::hash<NotConstructible> >, 51 test_compare<std::equal_to<NotConstructible> >, 52 min_allocator<NotConstructible> 53 > C; 54 C c; 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); 60 assert(c.empty()); 61 assert(std::distance(c.begin(), c.end()) == 0); 62 assert(c.load_factor() == 0); 63 assert(c.max_load_factor() == 1); 64 } 65 { 66 typedef explicit_allocator<NotConstructible> A; 67 typedef std::unordered_multiset<NotConstructible, 68 test_hash<std::hash<NotConstructible> >, 69 test_compare<std::equal_to<NotConstructible> >, 70 A 71 > C; 72 { 73 C c; 74 LIBCPP_ASSERT(c.bucket_count() == 0); 75 assert(c.hash_function() == test_hash<std::hash<NotConstructible> >()); 76 assert(c.key_eq() == test_compare<std::equal_to<NotConstructible> >()); 77 assert(c.get_allocator() == A()); 78 assert(c.size() == 0); 79 assert(c.empty()); 80 assert(std::distance(c.begin(), c.end()) == 0); 81 assert(c.load_factor() == 0); 82 assert(c.max_load_factor() == 1); 83 } 84 { 85 A a; 86 C c(a); 87 LIBCPP_ASSERT(c.bucket_count() == 0); 88 assert(c.hash_function() == test_hash<std::hash<NotConstructible> >()); 89 assert(c.key_eq() == test_compare<std::equal_to<NotConstructible> >()); 90 assert(c.get_allocator() == a); 91 assert(c.size() == 0); 92 assert(c.empty()); 93 assert(std::distance(c.begin(), c.end()) == 0); 94 assert(c.load_factor() == 0); 95 assert(c.max_load_factor() == 1); 96 } 97 } 98 { 99 std::unordered_multiset<int> c = {}; 100 LIBCPP_ASSERT(c.bucket_count() == 0); 101 assert(c.size() == 0); 102 assert(c.empty()); 103 assert(std::distance(c.begin(), c.end()) == 0); 104 assert(c.load_factor() == 0); 105 assert(c.max_load_factor() == 1); 106 } 107 #endif 108 } 109