]>
Commit | Line | Data |
---|---|---|
6bbd10c7 MA |
1 | // { dg-do run } |
2 | ||
3 | // 2005-2-18 Matt Austern <austern@apple.com> | |
4 | // | |
7adcbafe | 5 | // Copyright (C) 2005-2022 Free Software Foundation, Inc. |
6bbd10c7 MA |
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 | |
748086b7 | 10 | // Free Software Foundation; either version 3, or (at your option) |
6bbd10c7 MA |
11 | // any later version. |
12 | // | |
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. | |
17 | // | |
18 | // You should have received a copy of the GNU General Public License along | |
748086b7 JJ |
19 | // with this library; see the file COPYING3. If not see |
20 | // <http://www.gnu.org/licenses/>. | |
6bbd10c7 MA |
21 | |
22 | // 6.3.4.5 unordered_set | |
23 | // find, equal_range, count | |
24 | ||
25 | #include <string> | |
26 | #include <iterator> | |
27 | #include <algorithm> | |
28 | #include <tr1/unordered_set> | |
29 | #include "testsuite_hooks.h" | |
30 | ||
6bbd10c7 MA |
31 | void test01() |
32 | { | |
33 | typedef std::tr1::unordered_multiset<std::string> Set; | |
34 | Set s; | |
35 | VERIFY(s.empty()); | |
36 | ||
37 | s.insert("grape"); | |
38 | s.insert("banana"); | |
39 | s.insert("grape"); | |
40 | ||
41 | Set::iterator i2 = s.find("banana"); | |
42 | VERIFY(i2 != s.end()); | |
43 | VERIFY(*i2 == "banana"); | |
f92ab29f | 44 | |
6bbd10c7 MA |
45 | std::pair<Set::iterator, Set::iterator> p = s.equal_range("grape"); |
46 | VERIFY(std::distance(p.first, p.second) == 2); | |
47 | Set::iterator i3 = p.first; | |
48 | ++i3; | |
49 | VERIFY(*p.first == "grape"); | |
50 | VERIFY(*i3 == "grape"); | |
51 | ||
52 | Set::iterator i4 = s.find("lime"); | |
f92ab29f | 53 | VERIFY(i4 == s.end()); |
6bbd10c7 MA |
54 | |
55 | VERIFY(s.count("grape") == 2); | |
56 | VERIFY(s.count("banana") == 1); | |
57 | VERIFY(s.count("lime") == 0); | |
58 | } | |
59 | ||
60 | int main() | |
61 | { | |
62 | test01(); | |
63 | return 0; | |
64 | } |