diff options
author | redi <redi@138bc75d-0d04-0410-961f-82ee72b054a4> | 2017-06-02 18:35:37 +0000 |
---|---|---|
committer | redi <redi@138bc75d-0d04-0410-961f-82ee72b054a4> | 2017-06-02 18:35:37 +0000 |
commit | da9c33b402760a373f8eaccc6cbfdec3cdb2b600 (patch) | |
tree | 22725a70454d80b6ac8bcfee93c8c8a34c4e29bb /libstdc++-v3/testsuite/27_io | |
parent | 8107122220d66cdfaa23c4cf9e211600a201ff00 (diff) | |
download | gcc-da9c33b402760a373f8eaccc6cbfdec3cdb2b600.tar.gz |
PR libstdc++/80624 satisfy invariant for char_traits<char16_t>::eof()
PR libstdc++/80624
* doc/xml/manual/status_cxx2011.xml: Document to_int_type behaviour.
* include/bits/char_traits.h (char_traits<char16_t>::to_int_type):
Transform eof value to U+FFFD.
* testsuite/21_strings/char_traits/requirements/char16_t/eof.cc: New.
* testsuite/27_io/basic_streambuf/sgetc/char16_t/80624.cc: New.
* testsuite/27_io/basic_streambuf/sputc/char16_t/80624.cc: New.
git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@248843 138bc75d-0d04-0410-961f-82ee72b054a4
Diffstat (limited to 'libstdc++-v3/testsuite/27_io')
-rw-r--r-- | libstdc++-v3/testsuite/27_io/basic_streambuf/sgetc/char16_t/80624.cc | 56 | ||||
-rw-r--r-- | libstdc++-v3/testsuite/27_io/basic_streambuf/sputc/char16_t/80624.cc | 59 |
2 files changed, 115 insertions, 0 deletions
diff --git a/libstdc++-v3/testsuite/27_io/basic_streambuf/sgetc/char16_t/80624.cc b/libstdc++-v3/testsuite/27_io/basic_streambuf/sgetc/char16_t/80624.cc new file mode 100644 index 00000000000..c08c2274706 --- /dev/null +++ b/libstdc++-v3/testsuite/27_io/basic_streambuf/sgetc/char16_t/80624.cc @@ -0,0 +1,56 @@ +// Copyright (C) 2017 Free Software Foundation, Inc. +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 3, or (at your option) +// any later version. + +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// You should have received a copy of the GNU General Public License along +// with this library; see the file COPYING3. If not see +// <http://www.gnu.org/licenses/>. + +// { dg-do run { target c++11 } } + +#include <streambuf> +#include <testsuite_hooks.h> + +struct streambuf : std::basic_streambuf<char16_t> +{ + basic_streambuf* setbuf(char_type* s, std::streamsize n) override + { + setp(s, s + n); + setg(s, s, s + n); + return this; + } +}; + +void +test01() +{ + using traits = streambuf::traits_type; + + char16_t buf[2] = { streambuf::char_type(-1), streambuf::char_type(-2) }; + streambuf sb; + sb.pubsetbuf(buf, 2); + + streambuf::int_type res; + + res = sb.sbumpc(); + VERIFY( traits::eq_int_type(res, traits::eof()) == false ); + res = sb.sbumpc(); + VERIFY( traits::eq_int_type(res, traits::eof()) == false ); + res = sb.sbumpc(); + VERIFY( traits::eq_int_type(res, traits::eof()) == true ); +} + +int +main() +{ + test01(); +} diff --git a/libstdc++-v3/testsuite/27_io/basic_streambuf/sputc/char16_t/80624.cc b/libstdc++-v3/testsuite/27_io/basic_streambuf/sputc/char16_t/80624.cc new file mode 100644 index 00000000000..a2a19176514 --- /dev/null +++ b/libstdc++-v3/testsuite/27_io/basic_streambuf/sputc/char16_t/80624.cc @@ -0,0 +1,59 @@ +// Copyright (C) 2017 Free Software Foundation, Inc. +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 3, or (at your option) +// any later version. + +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// You should have received a copy of the GNU General Public License along +// with this library; see the file COPYING3. If not see +// <http://www.gnu.org/licenses/>. + +// { dg-do run { target c++11 } } + +#include <streambuf> +#include <testsuite_hooks.h> + +struct streambuf : std::basic_streambuf<char16_t> +{ + basic_streambuf* setbuf(char_type* s, std::streamsize n) override + { + setp(s, s + n); + setg(s, s, s + n); + return this; + } +}; + +void +test01() +{ + using traits = streambuf::traits_type; + + char16_t buf[2] = { }; + streambuf sb; + sb.pubsetbuf(buf, 2); + + streambuf::int_type res; + + res = sb.sputc(streambuf::char_type(-1)); + VERIFY( traits::eq_int_type(res, traits::eof()) == false ); + res = sb.sputc(streambuf::char_type(-2)); + VERIFY( traits::eq_int_type(res, traits::eof()) == false ); + res = sb.sputc(streambuf::char_type(1)); + VERIFY( traits::eq_int_type(res, traits::eof()) == true ); + + VERIFY( buf[0] == streambuf::char_type(-1) ); + VERIFY( buf[1] == streambuf::char_type(-2) ); +} + +int +main() +{ + test01(); +} |