]> CyberLeo.Net >> Repos - FreeBSD/FreeBSD.git/blob - test/std/containers/unord/unord.set/max_load_factor.pass.cpp
Import libc++ 3.7.0 release (r246257).
[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         typedef int P;
33         const C c;
34         assert(c.max_load_factor() == 1);
35     }
36     {
37         typedef std::unordered_set<int> C;
38         typedef int P;
39         C c;
40         assert(c.max_load_factor() == 1);
41         c.max_load_factor(2.5);
42         assert(c.max_load_factor() == 2.5);
43     }
44 #if __cplusplus >= 201103L
45     {
46         typedef std::unordered_set<int, std::hash<int>,
47                                       std::equal_to<int>, min_allocator<int>> C;
48         typedef int P;
49         const C c;
50         assert(c.max_load_factor() == 1);
51     }
52     {
53         typedef std::unordered_set<int, std::hash<int>,
54                                       std::equal_to<int>, min_allocator<int>> C;
55         typedef int P;
56         C c;
57         assert(c.max_load_factor() == 1);
58         c.max_load_factor(2.5);
59         assert(c.max_load_factor() == 2.5);
60     }
61 #endif
62 #if _LIBCPP_DEBUG_LEVEL >= 1
63     {
64         typedef std::unordered_set<int> C;
65         C c;
66         c.max_load_factor(-0.5f);
67         assert(false);
68     }
69 #endif
70 }