]>
Commit | Line | Data |
---|---|---|
3c9b5053 PC |
1 | // 2005-10-08 Paolo Carlini <pcarlini@suse.de> |
2 | // | |
3 | // Copyright (C) 2005 Free Software Foundation, Inc. | |
4 | // | |
5 | // This file is part of the GNU ISO C++ Library. This library is free | |
6 | // software; you can redistribute it and/or modify it under the | |
7 | // terms of the GNU General Public License as published by the | |
8 | // Free Software Foundation; either version 2, or (at your option) | |
9 | // any later version. | |
10 | // | |
11 | // This library is distributed in the hope that it will be useful, | |
12 | // but WITHOUT ANY WARRANTY; without even the implied warranty of | |
13 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
14 | // GNU General Public License for more details. | |
15 | // | |
16 | // You should have received a copy of the GNU General Public License along | |
17 | // with this library; see the file COPYING. If not, write to the Free | |
18 | // Software Foundation, 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, | |
19 | // USA. | |
20 | ||
21 | // 6.3.4.6 Class template unordered_multimap | |
22 | ||
23 | #include <tr1/unordered_map> | |
24 | #include <string> | |
25 | #include <testsuite_hooks.h> | |
26 | ||
27 | // libstdc++/24061 | |
28 | void test01() | |
29 | { | |
30 | bool test __attribute__((unused)) = true; | |
31 | ||
32 | typedef std::tr1::unordered_multimap<std::string, int> Mmap; | |
33 | typedef Mmap::iterator iterator; | |
34 | typedef Mmap::const_iterator const_iterator; | |
35 | typedef Mmap::value_type value_type; | |
36 | ||
37 | Mmap mm1; | |
38 | ||
39 | mm1.insert(value_type("all the love in the world", 1)); | |
40 | mm1.insert(value_type("you know what you are?", 2)); | |
41 | mm1.insert(value_type("the collector", 3)); | |
42 | mm1.insert(value_type("the hand that feeds", 4)); | |
43 | mm1.insert(value_type("love is not enough", 5)); | |
44 | mm1.insert(value_type("every day is exactly the same", 6)); | |
45 | mm1.insert(value_type("with teeth", 7)); | |
46 | mm1.insert(value_type("only", 8)); | |
47 | mm1.insert(value_type("getting smaller", 9)); | |
48 | mm1.insert(value_type("sunspots", 10)); | |
49 | ||
50 | mm1.insert(value_type("you know what you are?", 5)); | |
51 | mm1.insert(value_type("the collector", 6)); | |
52 | mm1.insert(value_type("the hand that feeds", 7)); | |
53 | VERIFY( mm1.size() == 13 ); | |
54 | ||
55 | iterator it1 = mm1.begin(); | |
56 | ++it1; | |
57 | iterator it2 = it1; | |
58 | ++it2; | |
59 | iterator it3 = mm1.erase(it1); | |
60 | VERIFY( mm1.size() == 12 ); | |
61 | VERIFY( it3 == it2 ); | |
62 | VERIFY( *it3 == *it2 ); | |
63 | ||
64 | iterator it4 = mm1.begin(); | |
65 | ++it4; | |
66 | ++it4; | |
67 | ++it4; | |
68 | iterator it5 = it4; | |
69 | ++it5; | |
70 | ++it5; | |
71 | iterator it6 = mm1.erase(it4, it5); | |
72 | VERIFY( mm1.size() == 10 ); | |
73 | VERIFY( it6 == it5 ); | |
74 | VERIFY( *it6 == *it5 ); | |
75 | ||
76 | const_iterator it7 = mm1.begin(); | |
77 | ++it7; | |
78 | ++it7; | |
79 | ++it7; | |
80 | const_iterator it8 = it7; | |
81 | ++it8; | |
82 | const_iterator it9 = mm1.erase(it7); | |
83 | VERIFY( mm1.size() == 9 ); | |
84 | VERIFY( it9 == it8 ); | |
85 | VERIFY( *it9 == *it8 ); | |
86 | ||
87 | const_iterator it10 = mm1.begin(); | |
88 | ++it10; | |
89 | const_iterator it11 = it10; | |
90 | ++it11; | |
91 | ++it11; | |
92 | ++it11; | |
93 | ++it11; | |
94 | const_iterator it12 = mm1.erase(it10, it11); | |
95 | VERIFY( mm1.size() == 5 ); | |
96 | VERIFY( it12 == it11 ); | |
97 | VERIFY( *it12 == *it11 ); | |
98 | ||
99 | iterator it13 = mm1.erase(mm1.begin(), mm1.end()); | |
100 | VERIFY( mm1.size() == 0 ); | |
101 | VERIFY( it13 == mm1.end() ); | |
102 | VERIFY( it13 == mm1.begin() ); | |
103 | } | |
104 | ||
105 | int main() | |
106 | { | |
107 | test01(); | |
108 | return 0; | |
109 | } |