]>
Commit | Line | Data |
---|---|---|
4a6b297c PC |
1 | // 2011-10-28 Paolo Carlini <paolo.carlini@oracle.com> |
2 | ||
a5544970 | 3 | // Copyright (C) 2011-2019 Free Software Foundation, Inc. |
4a6b297c PC |
4 | // |
5 | // This file is part of the GNU ISO C++ Library. This library is free | |
6 | // software; you can redistribute it and/or modify it under the | |
7 | // terms of the GNU General Public License as published by the | |
8 | // Free Software Foundation; either version 3, or (at your option) | |
9 | // any later version. | |
10 | // | |
11 | // This library is distributed in the hope that it will be useful, | |
12 | // but WITHOUT ANY WARRANTY; without even the implied warranty of | |
13 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
14 | // GNU General Public License for more details. | |
15 | // | |
16 | // You should have received a copy of the GNU General Public License along | |
17 | // with this library; see the file COPYING3. If not see | |
18 | // <http://www.gnu.org/licenses/>. | |
19 | // | |
20 | ||
21 | #include <set> | |
22 | #include <testsuite_hooks.h> | |
23 | ||
24 | void test01() | |
25 | { | |
4a6b297c PC |
26 | using namespace std; |
27 | ||
28 | set<int> s0; | |
29 | VERIFY( s0.count(0) == 0 ); | |
30 | VERIFY( s0.count(1) == 0 ); | |
31 | ||
32 | s0.insert(1); | |
33 | VERIFY( s0.count(0) == 0 ); | |
34 | VERIFY( s0.count(1) == 1 ); | |
35 | ||
36 | s0.insert(1); | |
37 | VERIFY( s0.count(0) == 0 ); | |
38 | VERIFY( s0.count(1) == 1 ); | |
39 | ||
40 | s0.insert(2); | |
41 | VERIFY( s0.count(2) == 1 ); | |
42 | ||
43 | s0.insert(3); | |
44 | s0.insert(3); | |
45 | s0.insert(3); | |
46 | VERIFY( s0.count(3) == 1 ); | |
47 | ||
48 | s0.erase(2); | |
49 | VERIFY( s0.count(2) == 0 ); | |
50 | ||
51 | s0.erase(0); | |
52 | VERIFY( s0.count(0) == 0 ); | |
53 | ||
54 | set<int> s1(s0); | |
55 | VERIFY( s1.count(0) == 0 ); | |
56 | VERIFY( s1.count(1) == 1 ); | |
57 | VERIFY( s1.count(2) == 0 ); | |
58 | VERIFY( s1.count(3) == 1 ); | |
59 | ||
60 | s0.clear(); | |
61 | VERIFY( s0.count(0) == 0 ); | |
62 | VERIFY( s0.count(1) == 0 ); | |
63 | VERIFY( s0.count(2) == 0 ); | |
64 | VERIFY( s0.count(3) == 0 ); | |
65 | ||
66 | s1.insert(4); | |
67 | s1.insert(5); | |
68 | s1.insert(5); | |
69 | s1.insert(5); | |
70 | s1.insert(5); | |
71 | VERIFY( s1.count(4) == 1 ); | |
72 | VERIFY( s1.count(5) == 1 ); | |
73 | ||
74 | s1.erase(1); | |
75 | VERIFY( s1.count(1) == 0 ); | |
76 | ||
77 | s1.erase(s1.find(5)); | |
78 | VERIFY( s1.count(5) == 0 ); | |
79 | ||
80 | s1.insert(1); | |
81 | s1.insert(1); | |
82 | VERIFY( s1.count(1) == 1 ); | |
83 | ||
84 | s1.erase(5); | |
85 | VERIFY( s1.count(5) == 0 ); | |
86 | ||
87 | s1.erase(s1.find(4)); | |
88 | VERIFY( s1.count(4) == 0 ); | |
89 | ||
90 | s1.clear(); | |
91 | VERIFY( s1.count(0) == 0 ); | |
92 | VERIFY( s1.count(1) == 0 ); | |
93 | VERIFY( s1.count(2) == 0 ); | |
94 | VERIFY( s1.count(3) == 0 ); | |
95 | VERIFY( s1.count(4) == 0 ); | |
96 | VERIFY( s1.count(5) == 0 ); | |
97 | } | |
98 | ||
99 | int main() | |
100 | { | |
101 | test01(); | |
102 | return 0; | |
103 | } |