blob: b19a6e6cfa08d612786f16aaa7c48fde48a88a53 [file] [log] [blame]
Howard Hinnantbc8d3f92010-05-11 19:42:16 +00001//===----------------------------------------------------------------------===//
2//
Howard Hinnantf5256e12010-05-11 21:36:01 +00003// The LLVM Compiler Infrastructure
Howard Hinnantbc8d3f92010-05-11 19:42:16 +00004//
Howard Hinnantb64f8b02010-11-16 22:09:02 +00005// This file is dual licensed under the MIT and the University of Illinois Open
6// Source Licenses. See LICENSE.TXT for details.
Howard Hinnantbc8d3f92010-05-11 19:42:16 +00007//
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
Eric Fiselierfd9bbf52015-07-19 03:16:47 +000023#include "test_macros.h"
Marshall Clow061d0cc2013-11-26 20:58:02 +000024#include "min_allocator.h"
Howard Hinnant7a6b7ce2013-06-22 15:21:29 +000025
Howard Hinnantbc8d3f92010-05-11 19:42:16 +000026int main()
27{
28 {
29 typedef std::unordered_map<int, std::string> C;
Howard Hinnantbc8d3f92010-05-11 19:42:16 +000030 const C c;
31 assert(c.max_load_factor() == 1);
32 }
33 {
34 typedef std::unordered_map<int, std::string> C;
Howard Hinnantbc8d3f92010-05-11 19:42:16 +000035 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 }
Eric Fiselierfd9bbf52015-07-19 03:16:47 +000040#if TEST_STD_VER >= 11
Howard Hinnant7a6b7ce2013-06-22 15:21:29 +000041 {
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;
Howard Hinnant7a6b7ce2013-06-22 15:21:29 +000044 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;
Howard Hinnant7a6b7ce2013-06-22 15:21:29 +000050 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
Howard Hinnant824c1992013-08-02 17:50:49 +000056#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
Howard Hinnantbc8d3f92010-05-11 19:42:16 +000064}