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

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.1.5 [lib.alg.search]
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::forward_iterator_wrapper;
27
using std::search;
28
 
29
typedef test_container<int, forward_iterator_wrapper> Container;
30
int array1[] = {0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 1};
31
int array2[] = {0, 0, 0};
32
 
33
void
34
test1()
35
{
36
  bool test __attribute__((unused)) = true;
37
  Container con1(array1, array1);
38
  Container con2(array1, array1 + 1);
39
  VERIFY(search(con1.begin(), con1.end(), con2.begin(), con2.end()).ptr == array1);
40
  VERIFY(search(con2.begin(), con2.end(), con1.begin(), con1.end()).ptr == array1);
41
}
42
 
43
void
44
test2()
45
{
46
  bool test __attribute__((unused)) = true;
47
  Container con1(array1, array1 + 3);
48
  Container con2(array2, array2 + 3);
49
  VERIFY(search(con1.begin(), con1.end(), con2.begin(), con2.end()).ptr
50
         == array1);
51
}
52
 
53
void
54
test3()
55
{
56
  bool test __attribute__((unused)) = true;
57
  Container con1(array1 + 3, array1 + 10);
58
  Container con2(array2, array2 + 3);
59
  VERIFY(search(con1.begin(), con1.end(), con2.begin(), con2.end()).ptr
60
         == array1 + 10);
61
}
62
 
63
void
64
test4()
65
{
66
  bool test __attribute__((unused)) = true;
67
  Container con1(array1, array1 + 10);
68
  Container con2(array2, array2 + 1);
69
  VERIFY(search(con1.begin(), con1.end(), con2.begin(), con2.end()).ptr
70
         == array1);
71
}
72
 
73
void
74
test5()
75
{
76
  bool test __attribute__((unused)) = true;
77
  Container con1(array1 + 6, array1 + 10);
78
  Container con2(array2, array2 + 1);
79
  VERIFY(search(con1.begin(), con1.end(), con2.begin(), con2.end()).ptr
80
         == array1 + 10);
81
}
82
 
83
void
84
test6()
85
{
86
  bool test __attribute__((unused)) = true;
87
  int array3[]={2, 2, 1, 2, 3, 5};
88
  int array4[]={1, 2, 3, 4};
89
  Container con1(array3, array3 + 3);
90
  Container con2(array3, array3 + 4);
91
  Container con3(array3, array3 + 5);
92
  Container con4(array3, array3 + 6);
93
  Container endcon(array4, array4 + 4);
94
  VERIFY(search(con1.begin(), con1.end(), endcon.begin(), endcon.end()).ptr
95
         == array3 + 3);
96
  VERIFY(search(con2.begin(), con2.end(), endcon.begin(), endcon.end()).ptr
97
         == array3 + 4);
98
  VERIFY(search(con3.begin(), con3.end(), endcon.begin(), endcon.end()).ptr
99
         == array3 + 5);
100
  VERIFY(search(con4.begin(), con4.end(), endcon.begin(), endcon.end()).ptr
101
         == array3 + 6);
102
}
103
 
104
int
105
main()
106
{
107
  test1();
108
  test2();
109
  test3();
110
  test4();
111
  test5();
112
  test6();
113
}

powered by: WebSVN 2.1.0

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