]>
git.ipfire.org Git - thirdparty/gcc.git/blob - libstdc++-v3/testsuite/23_containers/unordered_set/operations/count.cc
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.
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)
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>
28 bool test
__attribute__((unused
)) = true;
31 unordered_set
<int> us0
;
32 VERIFY( us0
.count(0) == 0 );
33 VERIFY( us0
.count(1) == 0 );
36 VERIFY( us0
.count(0) == 0 );
37 VERIFY( us0
.count(1) == 1 );
40 VERIFY( us0
.count(0) == 0 );
41 VERIFY( us0
.count(1) == 1 );
44 VERIFY( us0
.count(2) == 1 );
49 VERIFY( us0
.count(3) == 1 );
52 VERIFY( us0
.count(2) == 0 );
55 VERIFY( us0
.count(0) == 0 );
57 unordered_set
<int> us1(us0
);
58 VERIFY( us1
.count(0) == 0 );
59 VERIFY( us1
.count(1) == 1 );
60 VERIFY( us1
.count(2) == 0 );
61 VERIFY( us1
.count(3) == 1 );
64 VERIFY( us0
.count(0) == 0 );
65 VERIFY( us0
.count(1) == 0 );
66 VERIFY( us0
.count(2) == 0 );
67 VERIFY( us0
.count(3) == 0 );
74 VERIFY( us1
.count(4) == 1 );
75 VERIFY( us1
.count(5) == 1 );
78 VERIFY( us1
.count(1) == 0 );
80 us1
.erase(us1
.find(5));
81 VERIFY( us1
.count(5) == 0 );
85 VERIFY( us1
.count(1) == 1 );
88 VERIFY( us1
.count(5) == 0 );
90 us1
.erase(us1
.find(4));
91 VERIFY( us1
.count(4) == 0 );
94 VERIFY( us1
.count(0) == 0 );
95 VERIFY( us1
.count(1) == 0 );
96 VERIFY( us1
.count(2) == 0 );
97 VERIFY( us1
.count(3) == 0 );
98 VERIFY( us1
.count(4) == 0 );
99 VERIFY( us1
.count(5) == 0 );