]> git.ipfire.org Git - thirdparty/gcc.git/blob - libstdc++-v3/testsuite/23_containers/multimap/operations/count.cc
Update copyright years.
[thirdparty/gcc.git] / libstdc++-v3 / testsuite / 23_containers / multimap / operations / count.cc
1 // 2011-10-28 Paolo Carlini <paolo.carlini@oracle.com>
2
3 // Copyright (C) 2011-2019 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.
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 <map>
22 #include <testsuite_hooks.h>
23
24 void test01()
25 {
26 using namespace std;
27
28 typedef multimap<int, int>::value_type value_type;
29
30 multimap<int, int> mm0;
31 VERIFY( mm0.count(0) == 0 );
32 VERIFY( mm0.count(1) == 0 );
33
34 mm0.insert(value_type(1, 1));
35 VERIFY( mm0.count(0) == 0 );
36 VERIFY( mm0.count(1) == 1 );
37
38 mm0.insert(value_type(1, 2));
39 VERIFY( mm0.count(0) == 0 );
40 VERIFY( mm0.count(1) == 2 );
41
42 mm0.insert(value_type(2, 1));
43 VERIFY( mm0.count(2) == 1 );
44
45 mm0.insert(value_type(3, 1));
46 mm0.insert(value_type(3, 2));
47 mm0.insert(value_type(3, 3));
48 VERIFY( mm0.count(3) == 3 );
49
50 mm0.erase(2);
51 VERIFY( mm0.count(2) == 0 );
52
53 mm0.erase(0);
54 VERIFY( mm0.count(0) == 0 );
55
56 multimap<int, int> mm1(mm0);
57 VERIFY( mm1.count(0) == 0 );
58 VERIFY( mm1.count(1) == 2 );
59 VERIFY( mm1.count(2) == 0 );
60 VERIFY( mm1.count(3) == 3 );
61
62 mm0.clear();
63 VERIFY( mm0.count(0) == 0 );
64 VERIFY( mm0.count(1) == 0 );
65 VERIFY( mm0.count(2) == 0 );
66 VERIFY( mm0.count(3) == 0 );
67
68 mm1.insert(value_type(4, 1));
69 mm1.insert(value_type(5, 1));
70 mm1.insert(value_type(5, 2));
71 mm1.insert(value_type(5, 3));
72 mm1.insert(value_type(5, 4));
73 VERIFY( mm1.count(4) == 1 );
74 VERIFY( mm1.count(5) == 4 );
75
76 mm1.erase(1);
77 VERIFY( mm1.count(1) == 0 );
78
79 mm1.erase(mm1.find(5));
80 VERIFY( mm1.count(5) == 3 );
81
82 mm1.insert(value_type(1, 1));
83 mm1.insert(value_type(1, 2));
84 VERIFY( mm1.count(1) == 2 );
85
86 mm1.erase(5);
87 VERIFY( mm1.count(5) == 0 );
88
89 mm1.erase(mm1.find(4));
90 VERIFY( mm1.count(4) == 0 );
91
92 mm1.clear();
93 VERIFY( mm1.count(0) == 0 );
94 VERIFY( mm1.count(1) == 0 );
95 VERIFY( mm1.count(2) == 0 );
96 VERIFY( mm1.count(3) == 0 );
97 VERIFY( mm1.count(4) == 0 );
98 VERIFY( mm1.count(5) == 0 );
99 }
100
101 int main()
102 {
103 test01();
104 return 0;
105 }