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/] [3.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, f, l) + sort + merge + unique
27
void
28
test03()
29
{
30
  const int A[] = {103, 203, 603, 303, 403, 503};
31
  const int B[] = {417, 417, 417, 417, 417};
32
  const int E[] = {103, 417, 417, 203, 603, 303, 403, 503};
33
  const int F[] = {103, 203, 303, 403, 417, 417, 503, 603};
34
  const int C[] = {103, 203, 303, 403, 417, 417, 417, 417, 417, 503, 603};
35
  const int D[] = {103, 203, 303, 403, 417, 503, 603};
36
  const int N = sizeof(A) / sizeof(int);
37
  const int M = sizeof(B) / sizeof(int);
38
  const int P = sizeof(C) / sizeof(int);
39
  const int Q = sizeof(D) / sizeof(int);
40
  const int R = sizeof(E) / sizeof(int);
41
 
42
  std::list<int> list0301(A, A + N);
43
  std::list<int> list0302(B, B + M);
44
  std::list<int> list0303(C, C + P);
45
  std::list<int> list0304(D, D + Q);
46
  std::list<int> list0305(E, E + R);
47
  std::list<int> list0306(F, F + R);
48
  std::list<int>::iterator p = list0301.begin();
49
  std::list<int>::iterator q = list0302.begin();
50
 
51
  ++p; ++q; ++q;
52
  list0301.splice(p, list0302, list0302.begin(), q);
53
  VERIFY(list0301 == list0305);
54
  VERIFY(list0301.size() == N + 2);
55
  VERIFY(list0302.size() == M - 2);
56
 
57
  list0301.sort();
58
  VERIFY(list0301 == list0306);
59
 
60
  list0301.merge(list0302);
61
  VERIFY(list0301.size() == N + M);
62
  VERIFY(list0302.size() == 0);
63
  VERIFY(list0301 == list0303);
64
 
65
  list0301.unique();
66
  VERIFY(list0301 == list0304);
67
}
68
 
69
int main(void)
70
{
71
  test03();
72
  return 0;
73
}

powered by: WebSVN 2.1.0

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