blob: 7c226600b9e20b644bd139be07b29336a94988fd (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
|
// { dg-do run }
#include <sstream>
#include <testsuite_hooks.h>
void
test_pr106248()
{
wchar_t buf[5] = {L'x', L'x', L'x', L'x', L'x'};
std::wstring s(L" four");
std::wistringstream in(s);
in >> buf;
#if __cplusplus >= 202002L
// Extraction stops because buffer is full.
VERIFY( in.good() );
#else
// PR libstdc++/106248
// Extraction stops because all input has been consumed and eofbit is set.
VERIFY( in.eof() );
#endif
// Extracted string must be null-terminated.
VERIFY( buf[4] == L'\0' );
VERIFY( std::wstring(buf) == L"four" );
in.clear();
in.str(s);
for (int i = 0; i < 5; ++i)
s[i] = L'x';
in.width(5);
in >> buf;
// Extraction stops due to field width, eofbit not set.
VERIFY( in.good() );
VERIFY( std::wstring(buf) == L"four" );
}
int main()
{
test_pr106248();
}
|