1//===----------------------------------------------------------------------===//
2//
3// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4// See https://llvm.org/LICENSE.txt for license information.
5// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6//
7//===----------------------------------------------------------------------===//
8
9// UNSUPPORTED: c++03
10
11// <unordered_set>
12
13// template <class Value, class Hash = hash<Value>, class Pred = equal_to<Value>,
14// class Alloc = allocator<Value>>
15// class unordered_multiset
16
17// unordered_multiset& operator=(initializer_list<value_type> il);
18
19#include <unordered_set>
20#include <cassert>
21#include <cfloat>
22#include <cmath>
23#include <cstddef>
24
25#include "test_macros.h"
26#include "../../../test_compare.h"
27#include "../../../test_hash.h"
28#include "test_allocator.h"
29#include "min_allocator.h"
30
31int main(int, char**) {
32 {
33 typedef test_allocator<int> A;
34 typedef std::unordered_multiset<int, test_hash<int>, test_equal_to<int>, A > C;
35 typedef int P;
36 C c = {P(4), P(1), P(2)};
37 c = {P(1), P(2), P(3), P(4), P(1), P(2)};
38 assert(c.bucket_count() >= 7);
39 assert(c.size() == 6);
40 assert(c.count(1) == 2);
41 assert(c.count(2) == 2);
42 assert(c.count(3) == 1);
43 assert(c.count(4) == 1);
44 assert(static_cast<std::size_t>(std::distance(c.begin(), c.end())) == c.size());
45 assert(static_cast<std::size_t>(std::distance(c.cbegin(), c.cend())) == c.size());
46 assert(fabs(c.load_factor() - (float)c.size() / c.bucket_count()) < FLT_EPSILON);
47 assert(c.max_load_factor() == 1);
48 }
49 {
50 typedef min_allocator<int> A;
51 typedef std::unordered_multiset<int, test_hash<int>, test_equal_to<int>, A > C;
52 typedef int P;
53 C c = {P(4), P(1), P(2)};
54 c = {P(1), P(2), P(3), P(4), P(1), P(2)};
55 assert(c.bucket_count() >= 7);
56 assert(c.size() == 6);
57 assert(c.count(1) == 2);
58 assert(c.count(2) == 2);
59 assert(c.count(3) == 1);
60 assert(c.count(4) == 1);
61 assert(static_cast<std::size_t>(std::distance(c.begin(), c.end())) == c.size());
62 assert(static_cast<std::size_t>(std::distance(c.cbegin(), c.cend())) == c.size());
63 assert(fabs(c.load_factor() - (float)c.size() / c.bucket_count()) < FLT_EPSILON);
64 assert(c.max_load_factor() == 1);
65 }
66
67 return 0;
68}
69

source code of libcxx/test/std/containers/unord/unord.multiset/unord.multiset.cnstr/assign_init.pass.cpp