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 // <set>
11
12 // class multiset
13
14 // template <class InputIterator>
15 // multiset(InputIterator first, InputIterator last,
16 // const value_compare& comp, const allocator_type& a);
17
18 #include <set>
19 #include <cassert>
20
21 #include "test_iterators.h"
22 #include "../../../test_compare.h"
23 #include "test_allocator.h"
24
main()25 int main()
26 {
27 typedef int V;
28 V ar[] =
29 {
30 1,
31 1,
32 1,
33 2,
34 2,
35 2,
36 3,
37 3,
38 3
39 };
40 typedef test_compare<std::less<V> > C;
41 typedef test_allocator<V> A;
42 std::multiset<V, C, A> m(input_iterator<const V*>(ar),
43 input_iterator<const V*>(ar+sizeof(ar)/sizeof(ar[0])),
44 C(5), A(7));
45 assert(m.value_comp() == C(5));
46 assert(m.get_allocator() == A(7));
47 assert(m.size() == 9);
48 assert(distance(m.begin(), m.end()) == 9);
49 assert(*next(m.begin(), 0) == 1);
50 assert(*next(m.begin(), 1) == 1);
51 assert(*next(m.begin(), 2) == 1);
52 assert(*next(m.begin(), 3) == 2);
53 assert(*next(m.begin(), 4) == 2);
54 assert(*next(m.begin(), 5) == 2);
55 assert(*next(m.begin(), 6) == 3);
56 assert(*next(m.begin(), 7) == 3);
57 assert(*next(m.begin(), 8) == 3);
58 #if _LIBCPP_STD_VER > 11
59 {
60 typedef int V;
61 V ar[] =
62 {
63 1,
64 1,
65 1,
66 2,
67 2,
68 2,
69 3,
70 3,
71 3
72 };
73 typedef test_allocator<V> A;
74 typedef test_compare<std::less<int> > C;
75 A a;
76 std::multiset<V, C, A> m(ar, ar+sizeof(ar)/sizeof(ar[0]), a);
77
78 assert(m.size() == 9);
79 assert(distance(m.begin(), m.end()) == 9);
80 assert(*next(m.begin(), 0) == 1);
81 assert(*next(m.begin(), 1) == 1);
82 assert(*next(m.begin(), 2) == 1);
83 assert(*next(m.begin(), 3) == 2);
84 assert(*next(m.begin(), 4) == 2);
85 assert(*next(m.begin(), 5) == 2);
86 assert(*next(m.begin(), 6) == 3);
87 assert(*next(m.begin(), 7) == 3);
88 assert(*next(m.begin(), 8) == 3);
89 assert(m.get_allocator() == a);
90 }
91 #endif
92 }
93