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