1 // 2006-03-20  Paolo Carlini  <pcarlini@suse.de>
2 
3 // Copyright (C) 2006-2021 Free Software Foundation, Inc.
4 //
5 // This file is part of the GNU ISO C++ Library.  This library is free
6 // software; you can redistribute it and/or modify it under the
7 // terms of the GNU General Public License as published by the
8 // Free Software Foundation; either version 3, or (at your option)
9 // any later version.
10 
11 // This library is distributed in the hope that it will be useful,
12 // but WITHOUT ANY WARRANTY; without even the implied warranty of
13 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14 // GNU General Public License for more details.
15 
16 // You should have received a copy of the GNU General Public License along
17 // with this library; see the file COPYING3.  If not see
18 // <http://www.gnu.org/licenses/>.
19 
20 #include <iterator>
21 #include <sstream>
22 #include <algorithm>
23 #include <testsuite_hooks.h>
24 
25 // In the occasion of libstdc++/25482
test01()26 void test01()
27 {
28   using namespace std;
29 
30   typedef istreambuf_iterator<char> in_iterator_type;
31 
32   const char data1[] = "Drei Phantasien nach Friedrich Holderlin";
33   const string str1(data1);
34   istringstream iss1(str1);
35   in_iterator_type beg1(iss1);
36   in_iterator_type end1, it1;
37 
38   it1 = find(beg1, beg1, 'l');
39   VERIFY( it1 == beg1 );
40   VERIFY( *it1 == 'D' );
41 
42   it1 = find(end1, end1, 'D');
43   VERIFY( it1 == end1 );
44 
45   it1 = find(end1, end1, 'Z');
46   VERIFY( it1 == end1 );
47 
48   it1 = find(beg1, end1, 'P');
49   VERIFY( *it1 == 'P' );
50   it1 = find(beg1, end1, 't');
51   VERIFY( *it1 == 't' );
52   ++it1;
53   VERIFY( *it1 == 'a' );
54 
55   it1 = find(beg1, end1, 'H');
56   VERIFY( *it1 == 'H' );
57   it1 = find(beg1, end1, 'l');
58   VERIFY( *it1 == 'l' );
59   ++it1;
60   it1 = find(beg1, end1, 'l');
61   VERIFY( *it1 == 'l' );
62   ++it1;
63   VERIFY( *it1 == 'i' );
64   it1 = find(beg1, end1, 'Z');
65   VERIFY( it1 == end1 );
66 
67   it1 = find(beg1, end1, 'D');
68   VERIFY( it1 == end1 );
69 
70   iss1.seekg(0);
71   it1 = find(beg1, end1, 'D');
72   VERIFY( it1 != end1 );
73   VERIFY( *it1 == 'D' );
74   ++it1;
75   VERIFY( *it1 == 'r' );
76 }
77 
main()78 int main()
79 {
80   test01();
81   return 0;
82 }
83