3 // 2005-2-18 Matt Austern <austern@apple.com>
5 // Copyright (C) 2005 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 2, 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 COPYING. If not, write to the Free
20 // Software Foundation, 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301,
23 // 6.3.4.6 unordered_multimap
24 // find, equal_range, count
30 #include <tr1/unordered_map>
31 #include "testsuite_hooks.h"
33 bool test
__attribute__((unused
)) = true;
37 typedef std::tr1::unordered_multimap
<std::string
, int> Map
;
38 typedef std::pair
<const std::string
, int> Pair
;
43 m
.insert(Pair("grape", 3));
44 m
.insert(Pair("durian", 8));
45 m
.insert(Pair("grape", 7));
47 Map::iterator i1
= m
.find("grape");
48 Map::iterator i2
= m
.find("durian");
49 Map::iterator i3
= m
.find("kiwi");
51 VERIFY(i1
!= m
.end());
52 VERIFY(i1
->first
== "grape");
53 VERIFY(i1
->second
== 3 || i2
->second
== 7);
54 VERIFY(i2
!= m
.end());
55 VERIFY(i2
->first
== "durian");
56 VERIFY(i2
->second
== 8);
57 VERIFY(i3
== m
.end());
59 std::pair
<Map::iterator
, Map::iterator
> p1
= m
.equal_range("grape");
60 VERIFY(std::distance(p1
.first
, p1
.second
) == 2);
61 Map::iterator tmp
= p1
.first
;
63 VERIFY(p1
.first
->first
== "grape");
64 VERIFY(tmp
->first
== "grape");
65 VERIFY((p1
.first
->second
== 3 && tmp
->second
== 7) ||
66 (p1
.first
->second
== 7 && tmp
->second
== 3));
68 std::pair
<Map::iterator
, Map::iterator
> p2
= m
.equal_range("durian");
69 VERIFY(std::distance(p2
.first
, p2
.second
) == 1);
70 VERIFY(p2
.first
->first
== "durian");
71 VERIFY(p2
.first
->second
== 8);
73 std::pair
<Map::iterator
, Map::iterator
> p3
= m
.equal_range("kiwi");
74 VERIFY(p3
.first
== p3
.second
);
76 VERIFY(m
.count("grape") == 2);
77 VERIFY(m
.count("durian") == 1);
78 VERIFY(m
.count("kiwi") == 0);