]>
Commit | Line | Data |
---|---|---|
b32eea9c JW |
1 | // Copyright (C) 2020 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 3, 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 COPYING3. If not see | |
16 | // <http://www.gnu.org/licenses/>. | |
17 | ||
18 | // { dg-do run } | |
19 | ||
20 | // PR libstdc++/94749 | |
21 | // basic_istream::ignore(n, c) discards n+1 if next character is equal to c. | |
22 | ||
23 | #include <sstream> | |
24 | #include <testsuite_hooks.h> | |
25 | ||
26 | typedef wchar_t C; | |
27 | ||
28 | void | |
29 | test01() | |
30 | { | |
31 | std::basic_istringstream<C> s(L" + -"); | |
32 | s.ignore(1, L'+'); | |
33 | VERIFY( s.get() == L'+' ); | |
34 | s.ignore(3, L'-'); | |
35 | VERIFY( s.get() == L'-' ); | |
36 | } | |
37 | ||
38 | void | |
39 | test02() | |
40 | { | |
41 | std::basic_istringstream<C> s(L".+...-"); | |
42 | s.ignore(1, L'+'); | |
43 | VERIFY( s.get() == L'+' ); | |
44 | s.ignore(3, L'-'); | |
45 | VERIFY( s.get() == L'-' ); | |
46 | } | |
47 | ||
48 | void | |
49 | test03() | |
50 | { | |
51 | std::basic_istringstream<C, __gnu_cxx::char_traits<C> > s(L" + -"); | |
52 | s.ignore(1, L'+'); | |
53 | VERIFY( s.get() == L'+' ); | |
54 | s.ignore(3, L'-'); | |
55 | VERIFY( s.get() == L'-' ); | |
56 | } | |
57 | ||
58 | void | |
59 | test04() | |
60 | { | |
61 | std::basic_istringstream<C, __gnu_cxx::char_traits<C> > s(L".+...-"); | |
62 | s.ignore(1, L'+'); | |
63 | VERIFY( s.get() == L'+' ); | |
64 | s.ignore(3, L'-'); | |
65 | VERIFY( s.get() == L'-' ); | |
66 | } | |
67 | ||
68 | ||
69 | int | |
70 | main() | |
71 | { | |
72 | // test01(); | |
73 | // test02(); | |
74 | test03(); | |
75 | test04(); | |
76 | } |