OpenCores
URL https://opencores.org/ocsvn/scarts/scarts/trunk

Subversion Repositories scarts

[/] [scarts/] [trunk/] [toolchain/] [scarts-gcc/] [gcc-4.1.1/] [libstdc++-v3/] [testsuite/] [tr1/] [6_containers/] [unordered/] [erase/] [24061-set.cc] - Blame information for rev 19

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 19 jlechner
// 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.3  Class template unordered_set
22
 
23
#include <tr1/unordered_set>
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_set<std::string> Set;
33
  typedef Set::iterator       iterator;
34
  typedef Set::const_iterator const_iterator;
35
 
36
  Set s1;
37
 
38
  s1.insert("all the love in the world");
39
  s1.insert("you know what you are?");
40
  s1.insert("the collector");
41
  s1.insert("the hand that feeds");
42
  s1.insert("love is not enough");
43
  s1.insert("every day is exactly the same");
44
  s1.insert("with teeth");
45
  s1.insert("only");
46
  s1.insert("getting smaller");
47
  s1.insert("sunspots");
48
  VERIFY( s1.size() == 10 );
49
 
50
  iterator it1 = s1.begin();
51
  ++it1;
52
  iterator it2 = it1;
53
  ++it2;
54
  iterator it3 = s1.erase(it1);
55
  VERIFY( s1.size() == 9 );
56
  VERIFY( it3 == it2 );
57
  VERIFY( *it3 == *it2 );
58
 
59
  iterator it4 = s1.begin();
60
  ++it4;
61
  ++it4;
62
  ++it4;
63
  iterator it5 = it4;
64
  ++it5;
65
  ++it5;
66
  iterator it6 = s1.erase(it4, it5);
67
  VERIFY( s1.size() == 7 );
68
  VERIFY( it6 == it5 );
69
  VERIFY( *it6 == *it5 );
70
 
71
  const_iterator it7 = s1.begin();
72
  ++it7;
73
  ++it7;
74
  ++it7;
75
  const_iterator it8 = it7;
76
  ++it8;
77
  const_iterator it9 = s1.erase(it7);
78
  VERIFY( s1.size() == 6 );
79
  VERIFY( it9 == it8 );
80
  VERIFY( *it9 == *it8 );
81
 
82
  const_iterator it10 = s1.begin();
83
  ++it10;
84
  const_iterator it11 = it10;
85
  ++it11;
86
  ++it11;
87
  ++it11;
88
  ++it11;
89
  const_iterator it12 = s1.erase(it10, it11);
90
  VERIFY( s1.size() == 2 );
91
  VERIFY( it12 == it11 );
92
  VERIFY( *it12 == *it11 );
93
  VERIFY( ++it12 == s1.end() );
94
 
95
  iterator it13 = s1.erase(s1.begin(), s1.end());
96
  VERIFY( s1.size() == 0 );
97
  VERIFY( it13 == s1.end() );
98
  VERIFY( it13 == s1.begin() );
99
}
100
 
101
int main()
102
{
103
  test01();
104
  return 0;
105
}

powered by: WebSVN 2.1.0

© copyright 1999-2024 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.