]>
git.ipfire.org Git - thirdparty/gcc.git/blob - libstdc++-v3/testsuite/23_containers/map/operations/count.cc
1 // 2011-10-28 Paolo Carlini <paolo.carlini@oracle.com>
3 // Copyright (C) 2011-2022 Free Software Foundation, Inc.
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)
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/>.
22 #include <testsuite_hooks.h>
28 typedef map
<int, int>::value_type value_type
;
31 VERIFY( m0
.count(0) == 0 );
32 VERIFY( m0
.count(1) == 0 );
34 m0
.insert(value_type(1, 1));
35 VERIFY( m0
.count(0) == 0 );
36 VERIFY( m0
.count(1) == 1 );
38 m0
.insert(value_type(1, 2));
39 VERIFY( m0
.count(0) == 0 );
40 VERIFY( m0
.count(1) == 1 );
42 m0
.insert(value_type(2, 1));
43 VERIFY( m0
.count(2) == 1 );
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 );
51 VERIFY( m0
.count(2) == 0 );
54 VERIFY( m0
.count(0) == 0 );
57 VERIFY( m1
.count(0) == 0 );
58 VERIFY( m1
.count(1) == 1 );
59 VERIFY( m1
.count(2) == 0 );
60 VERIFY( m1
.count(3) == 1 );
63 VERIFY( m0
.count(0) == 0 );
64 VERIFY( m0
.count(1) == 0 );
65 VERIFY( m0
.count(2) == 0 );
66 VERIFY( m0
.count(3) == 0 );
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 );
77 VERIFY( m1
.count(1) == 0 );
80 VERIFY( m1
.count(5) == 0 );
82 m1
.insert(value_type(1, 1));
83 m1
.insert(value_type(1, 2));
84 VERIFY( m1
.count(1) == 1 );
87 VERIFY( m1
.count(5) == 0 );
90 VERIFY( m1
.count(4) == 0 );
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 );