Reverting merge from trunk
[official-gcc.git] / libstdc++-v3 / testsuite / 23_containers / unordered_multiset / operations / count.cc
bloba8f6c20aa916d7409d3ad674c946a2ec39ccee81
1 // { dg-options "-std=gnu++0x" }
3 // 2011-10-28 Paolo Carlini <paolo.carlini@oracle.com>
5 // Copyright (C) 2011-2013 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.
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.
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/>.
23 #include <unordered_set>
24 #include <testsuite_hooks.h>
26 void test01()
28 bool test __attribute__((unused)) = true;
29 using namespace std;
31 unordered_multiset<int> ums0;
32 VERIFY( ums0.count(0) == 0 );
33 VERIFY( ums0.count(1) == 0 );
35 ums0.insert(1);
36 VERIFY( ums0.count(0) == 0 );
37 VERIFY( ums0.count(1) == 1 );
39 ums0.insert(1);
40 VERIFY( ums0.count(0) == 0 );
41 VERIFY( ums0.count(1) == 2 );
43 ums0.insert(2);
44 VERIFY( ums0.count(2) == 1 );
46 ums0.insert(3);
47 ums0.insert(3);
48 ums0.insert(3);
49 VERIFY( ums0.count(3) == 3 );
51 ums0.erase(2);
52 VERIFY( ums0.count(2) == 0 );
54 ums0.erase(0);
55 VERIFY( ums0.count(0) == 0 );
57 unordered_multiset<int> ums1(ums0);
58 VERIFY( ums1.count(0) == 0 );
59 VERIFY( ums1.count(1) == 2 );
60 VERIFY( ums1.count(2) == 0 );
61 VERIFY( ums1.count(3) == 3 );
63 ums0.clear();
64 VERIFY( ums0.count(0) == 0 );
65 VERIFY( ums0.count(1) == 0 );
66 VERIFY( ums0.count(2) == 0 );
67 VERIFY( ums0.count(3) == 0 );
69 ums1.insert(4);
70 ums1.insert(5);
71 ums1.insert(5);
72 ums1.insert(5);
73 ums1.insert(5);
74 VERIFY( ums1.count(4) == 1 );
75 VERIFY( ums1.count(5) == 4 );
77 ums1.erase(1);
78 VERIFY( ums1.count(1) == 0 );
80 ums1.erase(ums1.find(5));
81 VERIFY( ums1.count(5) == 3 );
83 ums1.insert(1);
84 ums1.insert(1);
85 VERIFY( ums1.count(1) == 2 );
87 ums1.erase(5);
88 VERIFY( ums1.count(5) == 0 );
90 ums1.erase(ums1.find(4));
91 VERIFY( ums1.count(4) == 0 );
93 ums1.clear();
94 VERIFY( ums1.count(0) == 0 );
95 VERIFY( ums1.count(1) == 0 );
96 VERIFY( ums1.count(2) == 0 );
97 VERIFY( ums1.count(3) == 0 );
98 VERIFY( ums1.count(4) == 0 );
99 VERIFY( ums1.count(5) == 0 );
102 int main()
104 test01();
105 return 0;