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_set 15 16 // unordered_set(size_type n, const hasher& hf, const key_equal& eql, const allocator_type& a); 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_set<NotConstructible, 32 test_hash<std::hash<NotConstructible> >, 33 test_compare<std::equal_to<NotConstructible> >, 34 test_allocator<NotConstructible> 35 > C; 36 C c(7, 37 test_hash<std::hash<NotConstructible> >(8), 38 test_compare<std::equal_to<NotConstructible> >(9), 39 test_allocator<NotConstructible>(10) 40 ); 41 LIBCPP_ASSERT(c.bucket_count() == 7); 42 assert(c.hash_function() == test_hash<std::hash<NotConstructible> >(8)); 43 assert(c.key_eq() == test_compare<std::equal_to<NotConstructible> >(9)); 44 assert(c.get_allocator() == (test_allocator<NotConstructible>(10))); 45 assert(c.size() == 0); 46 assert(c.empty()); 47 assert(std::distance(c.begin(), c.end()) == 0); 48 assert(c.load_factor() == 0); 49 assert(c.max_load_factor() == 1); 50 } 51 #if TEST_STD_VER >= 11 52 { 53 typedef std::unordered_set<NotConstructible, 54 test_hash<std::hash<NotConstructible> >, 55 test_compare<std::equal_to<NotConstructible> >, 56 min_allocator<NotConstructible> 57 > C; 58 C c(7, 59 test_hash<std::hash<NotConstructible> >(8), 60 test_compare<std::equal_to<NotConstructible> >(9), 61 min_allocator<NotConstructible>() 62 ); 63 LIBCPP_ASSERT(c.bucket_count() == 7); 64 assert(c.hash_function() == test_hash<std::hash<NotConstructible> >(8)); 65 assert(c.key_eq() == test_compare<std::equal_to<NotConstructible> >(9)); 66 assert(c.get_allocator() == (min_allocator<NotConstructible>())); 67 assert(c.size() == 0); 68 assert(c.empty()); 69 assert(std::distance(c.begin(), c.end()) == 0); 70 assert(c.load_factor() == 0); 71 assert(c.max_load_factor() == 1); 72 } 73 #endif 74 } 75