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

Subversion Repositories openrisc

[/] [openrisc/] [trunk/] [gnu-dev/] [or1k-gcc/] [libstdc++-v3/] [testsuite/] [23_containers/] [unordered_multiset/] [erase/] [24061-multiset.cc] - Blame information for rev 833

Go to most recent revision | Details | Compare with Previous | View Log

Line No. Rev Author Line
1 742 jeremybenn
// { dg-options "-std=gnu++0x" }
2
 
3
// 2010-02-10  Paolo Carlini  <paolo.carlini@oracle.com> 
4
//
5
// Copyright (C) 2010 Free Software Foundation, Inc.
6
//
7
// This file is part of the GNU ISO C++ Library.  This library is free
8
// software; you can redistribute it and/or modify it under the
9
// terms of the GNU General Public License as published by the
10
// Free Software Foundation; either version 3, or (at your option)
11
// any later version.
12
//
13
// This library is distributed in the hope that it will be useful,
14
// but WITHOUT ANY WARRANTY; without even the implied warranty of
15
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
16
// GNU General Public License for more details.
17
//
18
// You should have received a copy of the GNU General Public License along
19
// with this library; see the file COPYING3.  If not see
20
// <http://www.gnu.org/licenses/>.
21
 
22
#include <unordered_set>
23
#include <string>
24
#include <testsuite_hooks.h>
25
 
26
namespace
27
{
28
  std::size_t
29
  get_nb_bucket_elems(const std::unordered_multiset<std::string>& us)
30
  {
31
    std::size_t nb = 0;
32
    for (std::size_t b = 0; b != us.bucket_count(); ++b)
33
      {
34
        nb += us.bucket_size(b);
35
      }
36
    return nb;
37
  }
38
}
39
 
40
// libstdc++/24061
41
void test01()
42
{
43
  bool test __attribute__((unused)) = true;
44
 
45
  typedef std::unordered_multiset<std::string> Mset;
46
  typedef Mset::iterator       iterator;
47
  typedef Mset::const_iterator const_iterator;
48
 
49
  Mset ms1;
50
 
51
  ms1.insert("all the love in the world");
52
  ms1.insert("you know what you are?");
53
  ms1.insert("the collector");
54
  ms1.insert("the hand that feeds");
55
  ms1.insert("love is not enough");
56
  ms1.insert("every day is exactly the same");
57
  ms1.insert("with teeth");
58
  ms1.insert("only");
59
  ms1.insert("getting smaller");
60
  ms1.insert("sunspots");
61
 
62
  ms1.insert("the hand that feeds");
63
  ms1.insert("love is not enough");
64
  ms1.insert("every day is exactly the same");
65
  VERIFY( ms1.size() == 13 );
66
  VERIFY( get_nb_bucket_elems(ms1) == ms1.size() );
67
 
68
  iterator it1 = ms1.begin();
69
  ++it1;
70
  iterator it2 = it1;
71
  ++it2;
72
  iterator it3 = ms1.erase(it1);
73
  VERIFY( ms1.size() == 12 );
74
  VERIFY( get_nb_bucket_elems(ms1) == ms1.size() );
75
  VERIFY( it3 == it2 );
76
  VERIFY( *it3 == *it2 );
77
 
78
  iterator it4 = ms1.begin();
79
  ++it4;
80
  ++it4;
81
  ++it4;
82
  iterator it5 = it4;
83
  ++it5;
84
  ++it5;
85
  iterator it6 = ms1.erase(it4, it5);
86
  VERIFY( ms1.size() == 10 );
87
  VERIFY( get_nb_bucket_elems(ms1) == ms1.size() );
88
  VERIFY( it6 == it5 );
89
  VERIFY( *it6 == *it5 );
90
 
91
  const_iterator it7 = ms1.begin();
92
  ++it7;
93
  ++it7;
94
  ++it7;
95
  const_iterator it8 = it7;
96
  ++it8;
97
  const_iterator it9 = ms1.erase(it7);
98
  VERIFY( ms1.size() == 9 );
99
  VERIFY( get_nb_bucket_elems(ms1) == ms1.size() );
100
  VERIFY( it9 == it8 );
101
  VERIFY( *it9 == *it8 );
102
 
103
  const_iterator it10 = ms1.begin();
104
  ++it10;
105
  const_iterator it11 = it10;
106
  ++it11;
107
  ++it11;
108
  ++it11;
109
  ++it11;
110
  const_iterator it12 = ms1.erase(it10, it11);
111
  VERIFY( ms1.size() == 5 );
112
  VERIFY( get_nb_bucket_elems(ms1) == ms1.size() );
113
  VERIFY( it12 == it11 );
114
  VERIFY( *it12 == *it11 );
115
 
116
  iterator it13 = ms1.erase(ms1.begin(), ms1.end());
117
  VERIFY( ms1.size() == 0 );
118
  VERIFY( get_nb_bucket_elems(ms1) == ms1.size() );
119
  VERIFY( it13 == ms1.end() );
120
  VERIFY( it13 == ms1.begin() );
121
}
122
 
123
int main()
124
{
125
  test01();
126
  return 0;
127
}

powered by: WebSVN 2.1.0

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