1 // Copyright (C) 2005 Free Software Foundation, Inc.
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)
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.
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, 59 Temple Place - Suite 330, Boston, MA 02111-1307,
19 // 25.1.5 [lib.alg.search]
22 #include <testsuite_hooks.h>
23 #include <testsuite_iterators.h>
25 using __gnu_test::test_container
;
26 using __gnu_test::forward_iterator_wrapper
;
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};
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
);
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
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
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
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
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
96 VERIFY(search(con2
.begin(), con2
.end(), endcon
.begin(), endcon
.end()).ptr
98 VERIFY(search(con3
.begin(), con3
.end(), endcon
.begin(), endcon
.end()).ptr
100 VERIFY(search(con4
.begin(), con4
.end(), endcon
.begin(), endcon
.end()).ptr