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_map
15 
16 // float max_load_factor() const;
17 // void max_load_factor(float mlf);
18 
19 #include <unordered_map>
20 #include <string>
21 #include <cassert>
22 
23 #include "test_macros.h"
24 #include "min_allocator.h"
25 
main()26 int main()
27 {
28     {
29         typedef std::unordered_map<int, std::string> C;
30         const C c;
31         assert(c.max_load_factor() == 1);
32     }
33     {
34         typedef std::unordered_map<int, std::string> C;
35         C c;
36         assert(c.max_load_factor() == 1);
37         c.max_load_factor(2.5);
38         assert(c.max_load_factor() == 2.5);
39     }
40 #if TEST_STD_VER >= 11
41     {
42         typedef std::unordered_map<int, std::string, std::hash<int>, std::equal_to<int>,
43                             min_allocator<std::pair<const int, std::string>>> C;
44         const C c;
45         assert(c.max_load_factor() == 1);
46     }
47     {
48         typedef std::unordered_map<int, std::string, std::hash<int>, std::equal_to<int>,
49                             min_allocator<std::pair<const int, std::string>>> C;
50         C c;
51         assert(c.max_load_factor() == 1);
52         c.max_load_factor(2.5);
53         assert(c.max_load_factor() == 2.5);
54     }
55 #endif
56 #if _LIBCPP_DEBUG_LEVEL >= 1
57     {
58         typedef std::unordered_map<int, std::string> C;
59         C c;
60         c.max_load_factor(0);
61         assert(false);
62     }
63 #endif
64 }
65