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_map>
24 #include <testsuite_hooks.h>
28 bool test
__attribute__((unused
)) = true;
31 typedef unordered_map
<int, int>::value_type value_type
;
33 unordered_map
<int, int> um0
;
34 VERIFY( um0
.count(0) == 0 );
35 VERIFY( um0
.count(1) == 0 );
37 um0
.insert(value_type(1, 1));
38 VERIFY( um0
.count(0) == 0 );
39 VERIFY( um0
.count(1) == 1 );
41 um0
.insert(value_type(1, 2));
42 VERIFY( um0
.count(0) == 0 );
43 VERIFY( um0
.count(1) == 1 );
45 um0
.insert(value_type(2, 1));
46 VERIFY( um0
.count(2) == 1 );
48 um0
.insert(value_type(3, 1));
49 um0
.insert(value_type(3, 2));
50 um0
.insert(value_type(3, 3));
51 VERIFY( um0
.count(3) == 1 );
54 VERIFY( um0
.count(2) == 0 );
57 VERIFY( um0
.count(0) == 0 );
59 unordered_map
<int, int> um1(um0
);
60 VERIFY( um1
.count(0) == 0 );
61 VERIFY( um1
.count(1) == 1 );
62 VERIFY( um1
.count(2) == 0 );
63 VERIFY( um1
.count(3) == 1 );
66 VERIFY( um0
.count(0) == 0 );
67 VERIFY( um0
.count(1) == 0 );
68 VERIFY( um0
.count(2) == 0 );
69 VERIFY( um0
.count(3) == 0 );
71 um1
.insert(value_type(4, 1));
72 um1
.insert(value_type(5, 1));
73 um1
.insert(value_type(5, 2));
74 um1
.insert(value_type(5, 3));
75 um1
.insert(value_type(5, 4));
76 VERIFY( um1
.count(4) == 1 );
77 VERIFY( um1
.count(5) == 1 );
80 VERIFY( um1
.count(1) == 0 );
82 um1
.erase(um1
.find(5));
83 VERIFY( um1
.count(5) == 0 );
85 um1
.insert(value_type(1, 1));
86 um1
.insert(value_type(1, 2));
87 VERIFY( um1
.count(1) == 1 );
90 VERIFY( um1
.count(5) == 0 );
92 um1
.erase(um1
.find(4));
93 VERIFY( um1
.count(4) == 0 );
96 VERIFY( um1
.count(0) == 0 );
97 VERIFY( um1
.count(1) == 0 );
98 VERIFY( um1
.count(2) == 0 );
99 VERIFY( um1
.count(3) == 0 );
100 VERIFY( um1
.count(4) == 0 );
101 VERIFY( um1
.count(5) == 0 );