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

Subversion Repositories scarts

[/] [scarts/] [trunk/] [toolchain/] [scarts-gcc/] [gcc-4.1.1/] [libstdc++-v3/] [testsuite/] [23_containers/] [list/] [modifiers/] [2.cc] - Blame information for rev 19

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 19 jlechner
// Copyright (C) 2001, 2003, 2004, 2005 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 2, 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 COPYING.  If not, write to the Free
16
// Software Foundation, 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301,
17
// USA.
18
 
19
// 23.2.2.3 list modifiers [lib.list.modifiers]
20
 
21
#include <list>
22
#include <testsuite_hooks.h>
23
 
24
typedef __gnu_test::copy_tracker  T;
25
 
26
bool test __attribute__((unused)) = true;
27
 
28
// general single insert/erase + swap
29
void
30
test02()
31
{
32
  std::list<T> list0201;
33
  T::reset();
34
 
35
  list0201.insert(list0201.begin(), T(1));     // list should be [1]
36
  VERIFY(list0201.size() == 1);
37
  VERIFY(T::copyCount() == 1);
38
 
39
  list0201.insert(list0201.end(), T(2));     // list should be [1 2]
40
  VERIFY(list0201.size() == 2);
41
  VERIFY(T::copyCount() == 2);
42
 
43
  std::list<T>::iterator i = list0201.begin();
44
  std::list<T>::const_iterator j = i;
45
  VERIFY(i->id() == 1); ++i;
46
  VERIFY(i->id() == 2);
47
 
48
  list0201.insert(i, T(3));     // list should be [1 3 2]
49
  VERIFY(list0201.size() == 3);
50
  VERIFY(T::copyCount() == 3);
51
 
52
  std::list<T>::const_iterator k = i;
53
  VERIFY(i->id() == 2); --i;
54
  VERIFY(i->id() == 3); --i;
55
  VERIFY(i->id() == 1);
56
  VERIFY(j->id() == 1);
57
 
58
  ++i; // will point to '3'
59
  T::reset();
60
  list0201.erase(i); // should be [1 2]
61
  VERIFY(list0201.size() == 2);
62
  VERIFY(T::dtorCount() == 1);
63
  VERIFY(k->id() == 2);
64
  VERIFY(j->id() == 1);
65
 
66
  std::list<T> list0202;
67
  T::reset();
68
  VERIFY(list0202.size() == 0);
69
  VERIFY(T::copyCount() == 0);
70
  VERIFY(T::dtorCount() == 0);
71
 
72
  // member swap
73
  list0202.swap(list0201);
74
  VERIFY(list0201.size() == 0);
75
  VERIFY(list0202.size() == 2);
76
  VERIFY(T::copyCount() == 0);
77
  VERIFY(T::dtorCount() == 0);
78
 
79
  // specialized swap
80
  swap(list0201, list0202);
81
  VERIFY(list0201.size() == 2);
82
  VERIFY(list0202.size() == 0);
83
  VERIFY(T::copyCount() == 0);
84
  VERIFY(T::dtorCount() == 0);
85
}
86
 
87
int main()
88
{
89
  test02();
90
  return 0;
91
}

powered by: WebSVN 2.1.0

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