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

Subversion Repositories scarts

[/] [scarts/] [trunk/] [toolchain/] [scarts-gcc/] [gcc-4.1.1/] [libstdc++-v3/] [testsuite/] [25_algorithms/] [partial_sort_copy/] [1.cc] - Blame information for rev 20

Go to most recent revision | Details | Compare with Previous | View Log

Line No. Rev Author Line
1 19 jlechner
// Copyright (C) 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 even 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
// 25.3.1.4 [lib.partial.sort.copy]
20
 
21
#include <algorithm>
22
#include <testsuite_hooks.h>
23
#include <testsuite_iterators.h>
24
 
25
using __gnu_test::test_container;
26
using __gnu_test::random_access_iterator_wrapper;
27
using __gnu_test::input_iterator_wrapper;
28
using std::partial_sort_copy;
29
 
30
typedef test_container<int, random_access_iterator_wrapper> Rcontainer;
31
typedef test_container<int, input_iterator_wrapper> Icontainer;
32
 
33
void
34
test1()
35
{
36
  int array[]={2,1,0};
37
  Rcontainer rcon1(array, array);
38
  Rcontainer rcon2(array, array + 2);
39
  Icontainer icon1(array, array);
40
  Icontainer icon2(array, array + 2);
41
  partial_sort_copy(icon1.begin(), icon1.end(), rcon1.begin(), rcon1.end());
42
  partial_sort_copy(icon1.begin(), icon1.end(), rcon2.begin(), rcon2.end());
43
  partial_sort_copy(icon2.begin(), icon2.end(), rcon1.begin(), rcon1.end());
44
  partial_sort_copy(icon2.begin(), icon2.end(), rcon2.begin(), rcon2.end());
45
}
46
 
47
void
48
test2()
49
{
50
  int array1[] = {4, 3, 2, 1, 0};
51
  int array2[5];
52
  Icontainer icon(array1, array1 + 5);
53
  Rcontainer rcon(array2, array2 + 5);
54
  partial_sort_copy(icon.begin(), icon.end(), rcon.begin(), rcon.end());
55
  VERIFY(array2[0] == 0 && array2[1] == 1 && array2[2] == 2 &&
56
         array2[3] == 3 && array2[4] == 4);
57
}
58
 
59
void
60
test3()
61
{
62
  int array1[] = {4, 0, 1, 3, 2};
63
  int array2[5];
64
  Icontainer icon(array1, array1 + 5);
65
  Rcontainer rcon(array2, array2 + 2);
66
  partial_sort_copy(icon.begin(), icon.end(), rcon.begin(), rcon.end());
67
  VERIFY(array2[0] == 0 && array2[1] == 1);
68
}
69
 
70
void
71
test4()
72
{
73
  int array1[] = {4, 1, 3, 2, 0};
74
  int array2[20];
75
  Icontainer icon(array1, array1 + 5);
76
  Rcontainer rcon(array2, array2 + 20);
77
  partial_sort_copy(icon.begin(), icon.end(), rcon.begin(), rcon.end());
78
  VERIFY(array2[0] == 0 && array2[1] == 1 && array2[2] == 2 &&
79
         array2[3] == 3 && array2[4] == 4);
80
}
81
 
82
int
83
main()
84
{
85
  test1();
86
  test2();
87
  test3();
88
  test4();
89
}

powered by: WebSVN 2.1.0

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