]> git.ipfire.org Git - thirdparty/gcc.git/blob - libstdc++-v3/testsuite/25_algorithms/find/istreambuf_iterators/wchar_t/1.cc
Update copyright years.
[thirdparty/gcc.git] / libstdc++-v3 / testsuite / 25_algorithms / find / istreambuf_iterators / wchar_t / 1.cc
1 // 2006-03-20 Paolo Carlini <pcarlini@suse.de>
2
3 // Copyright (C) 2006-2020 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
26 void test01()
27 {
28 using namespace std;
29
30 typedef istreambuf_iterator<wchar_t> in_iterator_type;
31
32 const wchar_t data1[] = L"Drei Phantasien nach Friedrich Holderlin";
33 const wstring str1(data1);
34 wistringstream iss1(str1);
35 in_iterator_type beg1(iss1);
36 in_iterator_type end1, it1;
37
38 it1 = find(beg1, beg1, L'l');
39 VERIFY( it1 == beg1 );
40 VERIFY( *it1 == L'D' );
41
42 it1 = find(end1, end1, L'D');
43 VERIFY( it1 == end1 );
44
45 it1 = find(end1, end1, L'Z');
46 VERIFY( it1 == end1 );
47
48 it1 = find(beg1, end1, L'P');
49 VERIFY( *it1 == L'P' );
50 it1 = find(beg1, end1, L't');
51 VERIFY( *it1 == L't' );
52 ++it1;
53 VERIFY( *it1 == L'a' );
54
55 it1 = find(beg1, end1, L'H');
56 VERIFY( *it1 == L'H' );
57 it1 = find(beg1, end1, L'l');
58 VERIFY( *it1 == L'l' );
59 ++it1;
60 it1 = find(beg1, end1, L'l');
61 VERIFY( *it1 == L'l' );
62 ++it1;
63 VERIFY( *it1 == L'i' );
64 it1 = find(beg1, end1, L'Z');
65 VERIFY( it1 == end1 );
66
67 it1 = find(beg1, end1, L'D');
68 VERIFY( it1 == end1 );
69
70 iss1.seekg(0);
71 it1 = find(beg1, end1, L'D');
72 VERIFY( it1 != end1 );
73 VERIFY( *it1 == L'D' );
74 ++it1;
75 VERIFY( *it1 == L'r' );
76 }
77
78 int main()
79 {
80 test01();
81 return 0;
82 }