]>
Commit | Line | Data |
---|---|---|
4a6b297c PC |
1 | // 2011-10-28 Paolo Carlini <paolo.carlini@oracle.com> |
2 | ||
818ab71a | 3 | // Copyright (C) 2011-2016 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 | { | |
26 | bool test __attribute__((unused)) = true; | |
27 | using namespace std; | |
28 | ||
29 | multiset<int> ms0; | |
30 | VERIFY( ms0.count(0) == 0 ); | |
31 | VERIFY( ms0.count(1) == 0 ); | |
32 | ||
33 | ms0.insert(1); | |
34 | VERIFY( ms0.count(0) == 0 ); | |
35 | VERIFY( ms0.count(1) == 1 ); | |
36 | ||
37 | ms0.insert(1); | |
38 | VERIFY( ms0.count(0) == 0 ); | |
39 | VERIFY( ms0.count(1) == 2 ); | |
40 | ||
41 | ms0.insert(2); | |
42 | VERIFY( ms0.count(2) == 1 ); | |
43 | ||
44 | ms0.insert(3); | |
45 | ms0.insert(3); | |
46 | ms0.insert(3); | |
47 | VERIFY( ms0.count(3) == 3 ); | |
48 | ||
49 | ms0.erase(2); | |
50 | VERIFY( ms0.count(2) == 0 ); | |
51 | ||
52 | ms0.erase(0); | |
53 | VERIFY( ms0.count(0) == 0 ); | |
54 | ||
55 | multiset<int> ms1(ms0); | |
56 | VERIFY( ms1.count(0) == 0 ); | |
57 | VERIFY( ms1.count(1) == 2 ); | |
58 | VERIFY( ms1.count(2) == 0 ); | |
59 | VERIFY( ms1.count(3) == 3 ); | |
60 | ||
61 | ms0.clear(); | |
62 | VERIFY( ms0.count(0) == 0 ); | |
63 | VERIFY( ms0.count(1) == 0 ); | |
64 | VERIFY( ms0.count(2) == 0 ); | |
65 | VERIFY( ms0.count(3) == 0 ); | |
66 | ||
67 | ms1.insert(4); | |
68 | ms1.insert(5); | |
69 | ms1.insert(5); | |
70 | ms1.insert(5); | |
71 | ms1.insert(5); | |
72 | VERIFY( ms1.count(4) == 1 ); | |
73 | VERIFY( ms1.count(5) == 4 ); | |
74 | ||
75 | ms1.erase(1); | |
76 | VERIFY( ms1.count(1) == 0 ); | |
77 | ||
78 | ms1.erase(ms1.find(5)); | |
79 | VERIFY( ms1.count(5) == 3 ); | |
80 | ||
81 | ms1.insert(1); | |
82 | ms1.insert(1); | |
83 | VERIFY( ms1.count(1) == 2 ); | |
84 | ||
85 | ms1.erase(5); | |
86 | VERIFY( ms1.count(5) == 0 ); | |
87 | ||
88 | ms1.erase(ms1.find(4)); | |
89 | VERIFY( ms1.count(4) == 0 ); | |
90 | ||
91 | ms1.clear(); | |
92 | VERIFY( ms1.count(0) == 0 ); | |
93 | VERIFY( ms1.count(1) == 0 ); | |
94 | VERIFY( ms1.count(2) == 0 ); | |
95 | VERIFY( ms1.count(3) == 0 ); | |
96 | VERIFY( ms1.count(4) == 0 ); | |
97 | VERIFY( ms1.count(5) == 0 ); | |
98 | } | |
99 | ||
100 | int main() | |
101 | { | |
102 | test01(); | |
103 | return 0; | |
104 | } |