llvm-project
179 строк · 3.3 Кб
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// <set>
10
11// class set
12
13// void swap(set& m);
14
15#include <set>
16#include <cassert>
17
18#include "test_macros.h"
19#include "min_allocator.h"
20
21int main(int, char**)
22{
23{
24typedef int V;
25typedef std::set<int> M;
26{
27M m1;
28M m2;
29M m1_save = m1;
30M m2_save = m2;
31m1.swap(m2);
32assert(m1 == m2_save);
33assert(m2 == m1_save);
34}
35{
36V ar2[] =
37{
385,
396,
407,
418,
429,
4310,
4411,
4512
46};
47M m1;
48M m2(ar2, ar2+sizeof(ar2)/sizeof(ar2[0]));
49M m1_save = m1;
50M m2_save = m2;
51m1.swap(m2);
52assert(m1 == m2_save);
53assert(m2 == m1_save);
54}
55{
56V ar1[] =
57{
581,
592,
603,
614
62};
63M m1(ar1, ar1+sizeof(ar1)/sizeof(ar1[0]));
64M m2;
65M m1_save = m1;
66M m2_save = m2;
67m1.swap(m2);
68assert(m1 == m2_save);
69assert(m2 == m1_save);
70}
71{
72V ar1[] =
73{
741,
752,
763,
774
78};
79V ar2[] =
80{
815,
826,
837,
848,
859,
8610,
8711,
8812
89};
90M m1(ar1, ar1+sizeof(ar1)/sizeof(ar1[0]));
91M m2(ar2, ar2+sizeof(ar2)/sizeof(ar2[0]));
92M m1_save = m1;
93M m2_save = m2;
94m1.swap(m2);
95assert(m1 == m2_save);
96assert(m2 == m1_save);
97}
98}
99#if TEST_STD_VER >= 11
100{
101typedef int V;
102typedef std::set<int, std::less<int>, min_allocator<int>> M;
103{
104M m1;
105M m2;
106M m1_save = m1;
107M m2_save = m2;
108m1.swap(m2);
109assert(m1 == m2_save);
110assert(m2 == m1_save);
111}
112{
113V ar2[] =
114{
1155,
1166,
1177,
1188,
1199,
12010,
12111,
12212
123};
124M m1;
125M m2(ar2, ar2+sizeof(ar2)/sizeof(ar2[0]));
126M m1_save = m1;
127M m2_save = m2;
128m1.swap(m2);
129assert(m1 == m2_save);
130assert(m2 == m1_save);
131}
132{
133V ar1[] =
134{
1351,
1362,
1373,
1384
139};
140M m1(ar1, ar1+sizeof(ar1)/sizeof(ar1[0]));
141M m2;
142M m1_save = m1;
143M m2_save = m2;
144m1.swap(m2);
145assert(m1 == m2_save);
146assert(m2 == m1_save);
147}
148{
149V ar1[] =
150{
1511,
1522,
1533,
1544
155};
156V ar2[] =
157{
1585,
1596,
1607,
1618,
1629,
16310,
16411,
16512
166};
167M m1(ar1, ar1+sizeof(ar1)/sizeof(ar1[0]));
168M m2(ar2, ar2+sizeof(ar2)/sizeof(ar2[0]));
169M m1_save = m1;
170M m2_save = m2;
171m1.swap(m2);
172assert(m1 == m2_save);
173assert(m2 == m1_save);
174}
175}
176#endif
177
178return 0;
179}
180