]> CyberLeo.Net >> Repos - FreeBSD/FreeBSD.git/blob - test/std/containers/sequences/forwardlist/forwardlist.cons/copy.pass.cpp
Vendor import of libc++ trunk r290819:
[FreeBSD/FreeBSD.git] / test / std / containers / sequences / forwardlist / forwardlist.cons / copy.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 // <forward_list>
11
12 // forward_list(const forward_list& x);
13
14 #include <forward_list>
15 #include <cassert>
16 #include <iterator>
17
18 #include "test_macros.h"
19 #include "test_allocator.h"
20 #include "min_allocator.h"
21
22 int main()
23 {
24     {
25         typedef int T;
26         typedef test_allocator<int> A;
27         typedef std::forward_list<T, A> C;
28         const T t[] = {0, 1, 2, 3, 4, 5, 6, 7, 8, 9};
29         C c0(std::begin(t), std::end(t), A(10));
30         C c = c0;
31         int n = 0;
32         for (C::const_iterator i = c.begin(), e = c.end(); i != e; ++i, ++n)
33             assert(*i == n);
34         assert(n == std::end(t) - std::begin(t));
35         assert(c == c0);
36         assert(c.get_allocator() == A(10));
37     }
38 #if TEST_STD_VER >= 11
39     {
40         typedef int T;
41         typedef other_allocator<int> A;
42         typedef std::forward_list<T, A> C;
43         const T t[] = {0, 1, 2, 3, 4, 5, 6, 7, 8, 9};
44         C c0(std::begin(t), std::end(t), A(10));
45         C c = c0;
46         int n = 0;
47         for (C::const_iterator i = c.begin(), e = c.end(); i != e; ++i, ++n)
48             assert(*i == n);
49         assert(n == std::end(t) - std::begin(t));
50         assert(c == c0);
51         assert(c.get_allocator() == A(-2));
52     }
53     {
54         typedef int T;
55         typedef min_allocator<int> A;
56         typedef std::forward_list<T, A> C;
57         const T t[] = {0, 1, 2, 3, 4, 5, 6, 7, 8, 9};
58         C c0(std::begin(t), std::end(t), A());
59         C c = c0;
60         int n = 0;
61         for (C::const_iterator i = c.begin(), e = c.end(); i != e; ++i, ++n)
62             assert(*i == n);
63         assert(n == std::end(t) - std::begin(t));
64         assert(c == c0);
65         assert(c.get_allocator() == A());
66     }
67 #endif
68 }