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/] [operators/] [1.cc] - Blame information for rev 19

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 19 jlechner
// Copyright (C) 2001, 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.4 list operations [lib.list.ops]
20
 
21
#include <list>
22
#include <testsuite_hooks.h>
23
 
24
bool test __attribute__((unused)) = true;
25
 
26
// splice(p, x) + remove + reverse
27
void
28
test01()
29
{
30
  const int K = 417;
31
  const int A[] = {1, 2, 3, 4, 5};
32
  const int B[] = {K, K, K, K, K};
33
  const std::size_t N = sizeof(A) / sizeof(int);
34
  const std::size_t M = sizeof(B) / sizeof(int);
35
 
36
  std::list<int> list0101(A, A + N);
37
  std::list<int> list0102(B, B + M);
38
  std::list<int>::iterator p = list0101.begin();
39
 
40
  VERIFY(list0101.size() == N);
41
  VERIFY(list0102.size() == M);
42
 
43
  ++p;
44
  list0101.splice(p, list0102); // [1 K K K K K 2 3 4 5]
45
  VERIFY(list0101.size() == N + M);
46
  VERIFY(list0102.size() == 0);
47
 
48
  // remove range from middle
49
  list0101.remove(K);
50
  VERIFY(list0101.size() == N);
51
 
52
  // remove first element
53
  list0101.remove(1);
54
  VERIFY(list0101.size() == N - 1);
55
 
56
  // remove last element
57
  list0101.remove(5);
58
  VERIFY(list0101.size() == N - 2);
59
 
60
  // reverse
61
  list0101.reverse();
62
  p = list0101.begin();
63
  VERIFY(*p == 4); ++p;
64
  VERIFY(*p == 3); ++p;
65
  VERIFY(*p == 2); ++p;
66
  VERIFY(p == list0101.end());
67
}
68
 
69
int main(void)
70
{
71
  test01();
72
  return 0;
73
}
74
 

powered by: WebSVN 2.1.0

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