OSDN Git Service

Licensing changes to GPLv3 resp. GPLv3 with GCC Runtime Exception.
[pf3gnuchains/gcc-fork.git] / libstdc++-v3 / testsuite / tr1 / 6_containers / unordered_multiset / erase / 24061-multiset.cc
1 // 2005-10-08  Paolo Carlini  <pcarlini@suse.de> 
2 //
3 // Copyright (C) 2005, 2009 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 3, 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 COPYING3.  If not see
18 // <http://www.gnu.org/licenses/>.
19
20 // 6.3.4.5  Class template unordered_multiset
21
22 #include <tr1/unordered_set>
23 #include <string>
24 #include <testsuite_hooks.h>
25
26 // libstdc++/24061
27 void test01()
28 {
29   bool test __attribute__((unused)) = true;
30   
31   typedef std::tr1::unordered_multiset<std::string> Mset;
32   typedef Mset::iterator       iterator;
33   typedef Mset::const_iterator const_iterator;
34
35   Mset ms1;
36   
37   ms1.insert("all the love in the world");
38   ms1.insert("you know what you are?");
39   ms1.insert("the collector");
40   ms1.insert("the hand that feeds");
41   ms1.insert("love is not enough");
42   ms1.insert("every day is exactly the same");
43   ms1.insert("with teeth");
44   ms1.insert("only");
45   ms1.insert("getting smaller");
46   ms1.insert("sunspots");
47
48   ms1.insert("the hand that feeds");
49   ms1.insert("love is not enough");
50   ms1.insert("every day is exactly the same");
51   VERIFY( ms1.size() == 13 );
52
53   iterator it1 = ms1.begin();
54   ++it1;
55   iterator it2 = it1;
56   ++it2;
57   iterator it3 = ms1.erase(it1);
58   VERIFY( ms1.size() == 12 );
59   VERIFY( it3 == it2 );
60   VERIFY( *it3 == *it2 );
61
62   iterator it4 = ms1.begin();
63   ++it4;
64   ++it4;
65   ++it4;
66   iterator it5 = it4;
67   ++it5;
68   ++it5;
69   iterator it6 = ms1.erase(it4, it5);
70   VERIFY( ms1.size() == 10 );
71   VERIFY( it6 == it5 );
72   VERIFY( *it6 == *it5 );
73
74   const_iterator it7 = ms1.begin();
75   ++it7;
76   ++it7;
77   ++it7;
78   const_iterator it8 = it7;
79   ++it8;
80   const_iterator it9 = ms1.erase(it7);
81   VERIFY( ms1.size() == 9 );
82   VERIFY( it9 == it8 );
83   VERIFY( *it9 == *it8 );
84
85   const_iterator it10 = ms1.begin();
86   ++it10;
87   const_iterator it11 = it10;
88   ++it11;
89   ++it11;
90   ++it11;
91   ++it11;
92   const_iterator it12 = ms1.erase(it10, it11);
93   VERIFY( ms1.size() == 5 );
94   VERIFY( it12 == it11 );
95   VERIFY( *it12 == *it11 );
96
97   iterator it13 = ms1.erase(ms1.begin(), ms1.end());
98   VERIFY( ms1.size() == 0 );
99   VERIFY( it13 == ms1.end() );
100   VERIFY( it13 == ms1.begin() );
101 }
102   
103 int main()
104 {
105   test01();
106   return 0;
107 }