size_hash_equal_allocator.pass.cpp revision f5256e16dfc425c1d466f6308d4026d529ce9e0b
1//===----------------------------------------------------------------------===//
2//
3//                     The LLVM Compiler Infrastructure
4//
5// This file is distributed under the University of Illinois Open Source
6// License. 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// unordered_map(size_type n, const hasher& hf, const key_equal& eql, const allocator_type& a);
17
18#include <unordered_map>
19#include <cassert>
20
21#include "../../../NotConstructible.h"
22#include "../../../test_compare.h"
23#include "../../../test_hash.h"
24#include "../../../test_allocator.h"
25
26int main()
27{
28    {
29        typedef std::unordered_map<NotConstructible, NotConstructible,
30                                   test_hash<std::hash<NotConstructible> >,
31                                   test_compare<std::equal_to<NotConstructible> >,
32                                   test_allocator<std::pair<const NotConstructible,
33                                                                  NotConstructible> >
34                                   > C;
35        C c(7,
36            test_hash<std::hash<NotConstructible> >(8),
37            test_compare<std::equal_to<NotConstructible> >(9),
38            test_allocator<std::pair<const NotConstructible, NotConstructible> >(10)
39           );
40        assert(c.bucket_count() == 7);
41        assert(c.hash_function() == test_hash<std::hash<NotConstructible> >(8));
42        assert(c.key_eq() == test_compare<std::equal_to<NotConstructible> >(9));
43        assert(c.get_allocator() ==
44               (test_allocator<std::pair<const NotConstructible, NotConstructible> >(10)));
45        assert(c.size() == 0);
46        assert(c.empty());
47        assert(std::distance(c.begin(), c.end()) == 0);
48        assert(c.load_factor() == 0);
49        assert(c.max_load_factor() == 1);
50    }
51}
52