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