1 //===----------------------------------------------------------------------===//
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
7 //===----------------------------------------------------------------------===//
12 // void swap(vector& x);
16 #include "test_macros.h"
17 #include "test_allocator.h"
18 #include "min_allocator.h"
23 std::vector
<bool> v1(100);
24 std::vector
<bool> v2(200);
26 assert(v1
.size() == 200);
27 assert(v1
.capacity() >= 200);
28 assert(v2
.size() == 100);
29 assert(v2
.capacity() >= 100);
32 typedef test_allocator
<bool> A
;
33 std::vector
<bool, A
> v1(100, true, A(1, 1));
34 std::vector
<bool, A
> v2(200, false, A(1, 2));
36 assert(v1
.size() == 200);
37 assert(v1
.capacity() >= 200);
38 assert(v2
.size() == 100);
39 assert(v2
.capacity() >= 100);
40 assert(v1
.get_allocator().get_id() == 1);
41 assert(v2
.get_allocator().get_id() == 2);
44 typedef other_allocator
<bool> A
;
45 std::vector
<bool, A
> v1(100, true, A(1));
46 std::vector
<bool, A
> v2(200, false, A(2));
48 assert(v1
.size() == 200);
49 assert(v1
.capacity() >= 200);
50 assert(v2
.size() == 100);
51 assert(v2
.capacity() >= 100);
52 assert(v1
.get_allocator() == A(2));
53 assert(v2
.get_allocator() == A(1));
56 std::vector
<bool> v(2);
57 std::vector
<bool>::reference r1
= v
[0];
58 std::vector
<bool>::reference r2
= v
[1];
62 assert(v
[0] == false);
65 #if TEST_STD_VER >= 11
67 std::vector
<bool, min_allocator
<bool>> v1(100);
68 std::vector
<bool, min_allocator
<bool>> v2(200);
70 assert(v1
.size() == 200);
71 assert(v1
.capacity() >= 200);
72 assert(v2
.size() == 100);
73 assert(v2
.capacity() >= 100);
76 typedef min_allocator
<bool> A
;
77 std::vector
<bool, A
> v1(100, true, A());
78 std::vector
<bool, A
> v2(200, false, A());
80 assert(v1
.size() == 200);
81 assert(v1
.capacity() >= 200);
82 assert(v2
.size() == 100);
83 assert(v2
.capacity() >= 100);
84 assert(v1
.get_allocator() == A());
85 assert(v2
.get_allocator() == A());
88 std::vector
<bool, min_allocator
<bool>> v(2);
89 std::vector
<bool, min_allocator
<bool>>::reference r1
= v
[0];
90 std::vector
<bool, min_allocator
<bool>>::reference r2
= v
[1];
94 assert(v
[0] == false);