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/] [2.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, i) + remove_if + operator==
27
void
28
test02()
29
{
30
  const int A[] = {1, 2, 3, 4, 5};
31
  const int B[] = {2, 1, 3, 4, 5};
32
  const int C[] = {1, 3, 4, 5, 2};
33
  const int N = sizeof(A) / sizeof(int);
34
  std::list<int> list0201(A, A + N);
35
  std::list<int> list0202(A, A + N);
36
  std::list<int> list0203(B, B + N);
37
  std::list<int> list0204(C, C + N);
38
  std::list<int>::iterator i = list0201.begin();
39
 
40
  // result should be unchanged
41
  list0201.splice(list0201.begin(), list0201, i);
42
  VERIFY(list0201 == list0202);
43
 
44
  // result should be [2 1 3 4 5]
45
  ++i;
46
  list0201.splice(list0201.begin(), list0201, i);
47
  VERIFY(list0201 != list0202);
48
  VERIFY(list0201 == list0203);
49
 
50
  // result should be [1 3 4 5 2]
51
  list0201.splice(list0201.end(), list0201, i);
52
  VERIFY(list0201 == list0204);
53
}
54
 
55
int main()
56
{
57
  test02();
58
  return 0;
59
}

powered by: WebSVN 2.1.0

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