max_load_factor.pass.cpp (1924B)
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_map> 11 12 // template <class Key, class T, class Hash = hash<Key>, class Pred = equal_to<Key>, 13 // class Alloc = allocator<pair<const Key, T>>> 14 // class unordered_multimap 15 16 // float max_load_factor() const; 17 // void max_load_factor(float mlf); 18 19 #ifdef _LIBCPP_DEBUG 20 #define _LIBCPP_ASSERT(x, m) ((x) ? (void)0 : std::exit(0)) 21 #endif 22 23 #include <unordered_map> 24 #include <string> 25 #include <cassert> 26 27 #include "min_allocator.h" 28 29 int main() 30 { 31 { 32 typedef std::unordered_multimap<int, std::string> C; 33 const C c; 34 assert(c.max_load_factor() == 1); 35 } 36 { 37 typedef std::unordered_multimap<int, std::string> C; 38 C c; 39 assert(c.max_load_factor() == 1); 40 c.max_load_factor(2.5); 41 assert(c.max_load_factor() == 2.5); 42 } 43 #if TEST_STD_VER >= 11 44 { 45 typedef std::unordered_multimap<int, std::string, std::hash<int>, std::equal_to<int>, 46 min_allocator<std::pair<const int, std::string>>> C; 47 const C c; 48 assert(c.max_load_factor() == 1); 49 } 50 { 51 typedef std::unordered_multimap<int, std::string, std::hash<int>, std::equal_to<int>, 52 min_allocator<std::pair<const int, std::string>>> C; 53 C c; 54 assert(c.max_load_factor() == 1); 55 c.max_load_factor(2.5); 56 assert(c.max_load_factor() == 2.5); 57 } 58 #endif 59 #if _LIBCPP_DEBUG_LEVEL >= 1 60 { 61 typedef std::unordered_multimap<int, std::string> C; 62 C c; 63 c.max_load_factor(0); 64 assert(false); 65 } 66 #endif 67 }