Remove old autovect-branch by moving to "dead" directory.
[official-gcc.git] / old-autovect-branch / libstdc++-v3 / testsuite / tr1 / 6_containers / unordered / erase / 24061-multimap.cc
blobb9980b73136f486408cd9b4e004034c8f50d2866
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.
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.
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.
21 // 6.3.4.6 Class template unordered_multimap
23 #include <tr1/unordered_map>
24 #include <string>
25 #include <testsuite_hooks.h>
27 // libstdc++/24061
28 void test01()
30 bool test __attribute__((unused)) = true;
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;
37 Mmap mm1;
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));
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 );
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 );
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 );
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 );
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 );
99 iterator it13 = mm1.erase(mm1.begin(), mm1.end());
100 VERIFY( mm1.size() == 0 );
101 VERIFY( it13 == mm1.end() );
102 VERIFY( it13 == mm1.begin() );
105 int main()
107 test01();
108 return 0;