1 // 2007-02-22 Paolo Carlini <pcarlini@suse.de>
3 // Copyright (C) 2007, 2009 Free Software Foundation, Inc.
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)
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 COPYING3. If not see
18 // <http://www.gnu.org/licenses/>.
20 // 6.3.4.3 Class template unordered_set
22 #include <tr1/unordered_set>
24 #include <testsuite_hooks.h>
26 // In the occasion of libstdc++/25896
29 bool test
__attribute__((unused
)) = true;
31 typedef std::tr1::unordered_set
<std::string
> Set
;
32 typedef Set::iterator iterator
;
33 typedef Set::const_iterator const_iterator
;
37 s1
.insert("because to why");
38 s1
.insert("the stockholm syndrome");
39 s1
.insert("a cereous night");
42 s1
.insert("the way you are when");
43 s1
.insert("tillsammans");
44 s1
.insert("umbra/penumbra");
45 s1
.insert("belonging (no longer mix)");
46 s1
.insert("one line behind");
47 VERIFY( s1
.size() == 10 );
49 VERIFY( s1
.erase("eeilo") == 1 );
50 VERIFY( s1
.size() == 9 );
51 iterator it1
= s1
.find("eeilo");
52 VERIFY( it1
== s1
.end() );
54 VERIFY( s1
.erase("tillsammans") == 1 );
55 VERIFY( s1
.size() == 8 );
56 iterator it2
= s1
.find("tillsammans");
57 VERIFY( it2
== s1
.end() );
59 // Must work (see DR 526)
60 iterator it3
= s1
.find("belonging (no longer mix)");
61 VERIFY( it3
!= s1
.end() );
62 VERIFY( s1
.erase(*it3
) == 1 );
63 VERIFY( s1
.size() == 7 );
64 it3
= s1
.find("belonging (no longer mix)");
65 VERIFY( it3
== s1
.end() );
67 VERIFY( !s1
.erase("abra") );
68 VERIFY( s1
.size() == 7 );
70 VERIFY( !s1
.erase("eeilo") );
71 VERIFY( s1
.size() == 7 );
73 VERIFY( s1
.erase("because to why") == 1 );
74 VERIFY( s1
.size() == 6 );
75 iterator it4
= s1
.find("because to why");
76 VERIFY( it4
== s1
.end() );
78 iterator it5
= s1
.find("umbra/penumbra");
79 iterator it6
= s1
.find("one line behind");
80 VERIFY( it5
!= s1
.end() );
81 VERIFY( it6
!= s1
.end() );
83 VERIFY( s1
.find("the stockholm syndrome") != s1
.end() );
84 VERIFY( s1
.find("a cereous night") != s1
.end() );
85 VERIFY( s1
.find("the way you are when") != s1
.end() );
86 VERIFY( s1
.find("a cereous night") != s1
.end() );
88 VERIFY( s1
.erase(*it5
) == 1 );
89 VERIFY( s1
.size() == 5 );
90 it5
= s1
.find("umbra/penumbra");
91 VERIFY( it5
== s1
.end() );
93 VERIFY( s1
.erase(*it6
) == 1 );
94 VERIFY( s1
.size() == 4 );
95 it6
= s1
.find("one line behind");
96 VERIFY( it6
== s1
.end() );
98 iterator it7
= s1
.begin();
104 VERIFY( s1
.erase(*it8
) == 1 );
105 VERIFY( s1
.size() == 3 );
106 VERIFY( ++it7
== it9
);
110 iterator it11
= it10
;
112 VERIFY( s1
.erase(*it9
) == 1 );
113 VERIFY( s1
.size() == 2 );
114 VERIFY( ++it10
== s1
.end() );
116 VERIFY( s1
.erase(s1
.begin()) != s1
.end() );
117 VERIFY( s1
.size() == 1 );
118 VERIFY( s1
.begin() == it11
);
120 VERIFY( s1
.erase(*s1
.begin()) == 1 );
121 VERIFY( s1
.size() == 0 );
122 VERIFY( s1
.begin() == s1
.end() );