diff options
Diffstat (limited to 'libstdc++-v3/testsuite/27_io/basic_istream/extractors_character/wchar_t')
-rw-r--r-- | libstdc++-v3/testsuite/27_io/basic_istream/extractors_character/wchar_t/pr106248.cc | 40 |
1 files changed, 40 insertions, 0 deletions
diff --git a/libstdc++-v3/testsuite/27_io/basic_istream/extractors_character/wchar_t/pr106248.cc b/libstdc++-v3/testsuite/27_io/basic_istream/extractors_character/wchar_t/pr106248.cc new file mode 100644 index 00000000000..7c226600b9e --- /dev/null +++ b/libstdc++-v3/testsuite/27_io/basic_istream/extractors_character/wchar_t/pr106248.cc @@ -0,0 +1,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(); +} |