]> CyberLeo.Net >> Repos - FreeBSD/FreeBSD.git/blob - test/std/containers/unord/unord.set/max_load_factor.pass.cpp
Vendor import of libc++ trunk r300422:
[FreeBSD/FreeBSD.git] / test / std / containers / unord / unord.set / max_load_factor.pass.cpp
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 // 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_set>
24 #include <cassert>
25
26 #include "min_allocator.h"
27
28 int main()
29 {
30     {
31         typedef std::unordered_set<int> C;
32         const C c;
33         assert(c.max_load_factor() == 1);
34     }
35     {
36         typedef std::unordered_set<int> C;
37         C c;
38         assert(c.max_load_factor() == 1);
39         c.max_load_factor(2.5);
40         assert(c.max_load_factor() == 2.5);
41     }
42 #if TEST_STD_VER >= 11
43     {
44         typedef std::unordered_set<int, std::hash<int>,
45                                       std::equal_to<int>, min_allocator<int>> C;
46         const C c;
47         assert(c.max_load_factor() == 1);
48     }
49     {
50         typedef std::unordered_set<int, std::hash<int>,
51                                       std::equal_to<int>, min_allocator<int>> C;
52         C c;
53         assert(c.max_load_factor() == 1);
54         c.max_load_factor(2.5);
55         assert(c.max_load_factor() == 2.5);
56     }
57 #endif
58 #if _LIBCPP_DEBUG_LEVEL >= 1
59     {
60         typedef std::unordered_set<int> C;
61         C c;
62         c.max_load_factor(-0.5f);
63         assert(false);
64     }
65 #endif
66 }