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