| 1 |
// { dg-do run } |
| 2 |
|
| 3 |
#include <sstream> |
| 4 |
#include <limits> |
| 5 |
#include <climits> |
| 6 |
#include <testsuite_hooks.h> |
| 7 |
|
| 8 |
// PR 93672 was a bug in std::istream that never affected std::wistream. |
| 9 |
// This test ensures that the bug doesn't get introduced to std::wistream. |
| 10 |
void |
| 11 |
test_pr93672() |
| 12 |
{ |
| 13 |
std::wstring str = L".x..x."; |
| 14 |
str[1] = (wchar_t)-2; |
| 15 |
str[4] = (wchar_t)-3; |
| 16 |
std::wistringstream in(str); |
| 17 |
|
| 18 |
// This should find the character even on platforms where wchar_t is signed, |
| 19 |
// because the delimiter is correctly converted to the stream's int_type. |
| 20 |
in.ignore(100, std::char_traits<wchar_t>::to_int_type((wchar_t)-2)); |
| 21 |
VERIFY( in.gcount() == 2 ); |
| 22 |
VERIFY( ! in.eof() ); |
| 23 |
|
| 24 |
// This also works, because std::char_traits<wchar_t>::to_int_type(wc) is |
| 25 |
// equivalent to (int_type)wc so using to_int_type isn't needed. |
| 26 |
in.ignore(100, (wchar_t)-3); |
| 27 |
VERIFY( in.gcount() == 3 ); |
| 28 |
VERIFY( ! in.eof() ); |
| 29 |
} |
| 30 |
|
| 31 |
int main() |
| 32 |
{ |
| 33 |
test_pr93672(); |
| 34 |
} |