OpenCores
URL https://opencores.org/ocsvn/openrisc_2011-10-31/openrisc_2011-10-31/trunk

Subversion Repositories openrisc_2011-10-31

[/] [openrisc/] [tags/] [gnu-src/] [gcc-4.5.1/] [gcc-4.5.1-or32-1.0rc3/] [libstdc++-v3/] [testsuite/] [23_containers/] [list/] [modifiers/] [1.h] - Blame information for rev 516

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 424 jeremybenn
// Copyright (C) 2001, 2003, 2004, 2005, 2009 Free Software Foundation, Inc.
2
//
3
// This file is part of the GNU ISO C++ Library.  This library is free
4
// software; you can redistribute it and/or modify it under the
5
// terms of the GNU General Public License as published by the
6
// Free Software Foundation; either version 3, or (at your option)
7
// any later version.
8
 
9
// This library is distributed in the hope that it will be useful,
10
// but WITHOUT ANY WARRANTY; without Pred the implied warranty of
11
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
12
// GNU General Public License for more details.
13
 
14
// You should have received a copy of the GNU General Public License along
15
// with this library; see the file COPYING3.  If not see
16
// <http://www.gnu.org/licenses/>.
17
 
18
// 23.2.2.3 list modifiers [lib.list.modifiers]
19
 
20
#include <testsuite_hooks.h>
21
 
22
// range and fill insert/erase + clear
23
// missing: o  fill insert disguised as a range insert in all its variants
24
//          o  exception effects
25
template<typename _Tp>
26
void
27
modifiers1()
28
{
29
  bool test __attribute__((unused)) = true;
30
  typedef _Tp list_type;
31
  typedef typename list_type::iterator iterator;
32
  typedef typename list_type::value_type value_type;
33
 
34
  using __gnu_test::copy_constructor;
35
  using __gnu_test::destructor;
36
 
37
  list_type list0301;
38
  value_type::reset();
39
 
40
  // fill insert at beginning of list / empty list
41
  list0301.insert(list0301.begin(), 3, value_type(11)); // should be [11 11 11]
42
  VERIFY(list0301.size() == 3);
43
  VERIFY(copy_constructor::count() == 3);
44
 
45
  // save iterators to verify post-insert validity
46
  iterator b = list0301.begin();
47
  iterator m = list0301.end(); --m;
48
  iterator e = list0301.end();
49
 
50
  // fill insert at end of list
51
  value_type::reset();
52
  list0301.insert(list0301.end(), 3, value_type(13)); // should be [11 11 11 13 13 13]
53
  VERIFY(list0301.size() == 6);
54
  VERIFY(copy_constructor::count() == 3);
55
  VERIFY(b == list0301.begin() && b->id() == 11);
56
  VERIFY(e == list0301.end());
57
  VERIFY(m->id() == 11);
58
 
59
  // fill insert in the middle of list
60
  ++m;
61
  value_type::reset();
62
  list0301.insert(m, 3, value_type(12)); // should be [11 11 11 12 12 12 13 13 13]
63
  VERIFY(list0301.size() == 9);
64
  VERIFY(copy_constructor::count() == 3);
65
  VERIFY(b == list0301.begin() && b->id() == 11);
66
  VERIFY(e == list0301.end());
67
  VERIFY(m->id() == 13);
68
 
69
  // single erase
70
  value_type::reset();
71
  m = list0301.erase(m); // should be [11 11 11 12 12 12 13 13]
72
  VERIFY(list0301.size() == 8);
73
  VERIFY(destructor::count() == 1);
74
  VERIFY(b == list0301.begin() && b->id() == 11);
75
  VERIFY(e == list0301.end());
76
  VERIFY(m->id() == 13);
77
 
78
  // range erase
79
  value_type::reset();
80
  m = list0301.erase(list0301.begin(), m); // should be [13 13]
81
  VERIFY(list0301.size() == 2);
82
  VERIFY(destructor::count() == 6);
83
  VERIFY(m->id() == 13);
84
 
85
  // range fill at beginning
86
  const int A[] = {321, 322, 333};
87
  const int N = sizeof(A) / sizeof(int);
88
  value_type::reset();
89
  b = list0301.begin();
90
  list0301.insert(b, A, A + N); // should be [321 322 333 13 13]
91
  VERIFY(list0301.size() == 5);
92
  VERIFY(copy_constructor::count() == 3);
93
  VERIFY(m->id() == 13);
94
 
95
  // range fill at end
96
  value_type::reset();
97
  list0301.insert(e, A, A + N); // should be [321 322 333 13 13 321 322 333]
98
  VERIFY(list0301.size() == 8);
99
  VERIFY(copy_constructor::count() == 3);
100
  VERIFY(e == list0301.end());
101
  VERIFY(m->id() == 13);
102
 
103
  // range fill in middle
104
  value_type::reset();
105
  list0301.insert(m, A, A + N);
106
  VERIFY(list0301.size() == 11);
107
  VERIFY(copy_constructor::count() == 3);
108
  VERIFY(e == list0301.end());
109
  VERIFY(m->id() == 13);
110
 
111
  value_type::reset();
112
  list0301.clear();
113
  VERIFY(list0301.size() == 0);
114
  VERIFY(destructor::count() == 11);
115
  VERIFY(e == list0301.end());
116
}

powered by: WebSVN 2.1.0

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