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