Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 1 | //===----------------------------------------------------------------------===// |
| 2 | // |
Howard Hinnant | f5256e1 | 2010-05-11 21:36:01 +0000 | [diff] [blame] | 3 | // The LLVM Compiler Infrastructure |
Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 4 | // |
Howard Hinnant | b64f8b0 | 2010-11-16 22:09:02 +0000 | [diff] [blame] | 5 | // This file is dual licensed under the MIT and the University of Illinois Open |
| 6 | // Source Licenses. See LICENSE.TXT for details. |
Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 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 | |
Eric Fiselier | fd9bbf5 | 2015-07-19 03:16:47 +0000 | [diff] [blame] | 23 | #include "test_macros.h" |
Marshall Clow | 061d0cc | 2013-11-26 20:58:02 +0000 | [diff] [blame] | 24 | #include "min_allocator.h" |
Howard Hinnant | 7a6b7ce | 2013-06-22 15:21:29 +0000 | [diff] [blame] | 25 | |
Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 26 | int main() |
| 27 | { |
| 28 | { |
| 29 | typedef std::unordered_map<int, std::string> C; |
Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 30 | const C c; |
| 31 | assert(c.max_load_factor() == 1); |
| 32 | } |
| 33 | { |
| 34 | typedef std::unordered_map<int, std::string> C; |
Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 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 | } |
Eric Fiselier | fd9bbf5 | 2015-07-19 03:16:47 +0000 | [diff] [blame] | 40 | #if TEST_STD_VER >= 11 |
Howard Hinnant | 7a6b7ce | 2013-06-22 15:21:29 +0000 | [diff] [blame] | 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; |
Howard Hinnant | 7a6b7ce | 2013-06-22 15:21:29 +0000 | [diff] [blame] | 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; |
Howard Hinnant | 7a6b7ce | 2013-06-22 15:21:29 +0000 | [diff] [blame] | 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 |
Howard Hinnant | 824c199 | 2013-08-02 17:50:49 +0000 | [diff] [blame] | 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 |
Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 64 | } |