]>
git.ipfire.org Git - thirdparty/gcc.git/blob - libstdc++-v3/testsuite/27_io/basic_istream/get/char/lwg3464.cc
1 // Copyright (C) 2020-2022 Free Software Foundation, Inc.
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)
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.
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/>.
18 // { dg-do run { target { { ! lp64 } && { ! simulator } } } }
19 // { dg-timeout-factor 2 }
24 #include <testsuite_hooks.h>
28 struct buff
: std::basic_streambuf
<C
>
30 typedef std::streamsize streamsize
;
31 typedef std::numeric_limits
<streamsize
> limits
;
33 buff() : count(0), buf() { }
37 // Number of characters left until we overflow the counter
38 const streamsize headroom
= limits::max() - count
;
41 return traits_type::eof();
46 count
= limits::max();
48 this->setg(buf
+ 1, buf
+ 1, buf
+ bufsz
);
53 int_type
overflow(int_type c
)
55 if (traits_type::eq_int_type(c
, traits_type::eof()))
57 this->setp(buf
, buf
+ bufsz
- 1);
58 return traits_type::not_eof(c
);
63 static const streamsize bufsz
= (2048 << limits::digits10
) + 1;
70 // Not possible to overflow 64-bit streamsize in reasonable time.
71 if (std::numeric_limits
<std::streamsize
>::digits
> 32)
74 std::basic_istream
<C
> in(new buff
);
77 VERIFY( in
.gcount() == std::numeric_limits
<std::streamsize
>::max() );
79 delete in
.rdbuf(new buff
);
82 VERIFY( in
.gcount() == 1 );
85 VERIFY( in
.gcount() == std::numeric_limits
<std::streamsize
>::max() );