Remove old autovect-branch by moving to "dead" directory.
[official-gcc.git] / old-autovect-branch / libstdc++-v3 / testsuite / tr1 / 6_containers / unordered / find / multimap1.cc
blob1fc3e18addbb6f996d899d2ccbebac5e5c8b7d37
1 // { dg-do run }
3 // 2005-2-18 Matt Austern <austern@apple.com>
4 //
5 // Copyright (C) 2005 Free Software Foundation, Inc.
6 //
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)
11 // any later version.
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,
21 // USA.
23 // 6.3.4.6 unordered_multimap
24 // find, equal_range, count
26 #include <string>
27 #include <iterator>
28 #include <algorithm>
29 #include <utility>
30 #include <tr1/unordered_map>
31 #include "testsuite_hooks.h"
33 bool test __attribute__((unused)) = true;
35 void test01()
37 typedef std::tr1::unordered_multimap<std::string, int> Map;
38 typedef std::pair<const std::string, int> Pair;
40 Map m;
41 VERIFY(m.empty());
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;
62 ++tmp;
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);
81 int main()
83 test01();
84 return 0;