]>
git.ipfire.org Git - thirdparty/gcc.git/blob - libstdc++-v3/testsuite/27_io/basic_streambuf/overflow/char/1.cc
3 // Copyright (C) 1999-2024 Free Software Foundation, Inc.
5 // This file is part of the GNU ISO C++ Library. This library is free
6 // software; you can redistribute it and/or modify it under the
7 // terms of the GNU General Public License as published by the
8 // Free Software Foundation; either version 3, or (at your option)
11 // This library is distributed in the hope that it will be useful,
12 // but WITHOUT ANY WARRANTY; without even the implied warranty of
13 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 // GNU General Public License for more details.
16 // You should have received a copy of the GNU General Public License along
17 // with this library; see the file COPYING3. If not see
18 // <http://www.gnu.org/licenses/>.
21 // 27.5.2 template class basic_streambuf
25 #include <testsuite_hooks.h>
27 class testbuf
: public std::streambuf
32 typedef std::streambuf::traits_type traits_type
;
33 typedef std::streambuf::char_type char_type
;
35 testbuf(): std::streambuf()
41 VERIFY( !this->eback() );
42 VERIFY( !this->gptr() );
43 VERIFY( !this->egptr() );
44 VERIFY( !this->pbase() );
45 VERIFY( !this->pptr() );
46 VERIFY( !this->epptr() );
51 { return (this->uflow()); }
54 pub_overflow(int_type __c
= traits_type::eof())
55 { return (this->overflow(__c
)); }
58 pub_pbackfail(int_type __c
)
59 { return (this->pbackfail(__c
)); }
62 pub_setg(char* beg
, char* cur
, char *end
)
63 { this->setg(beg
, cur
, end
); }
66 pub_setp(char* beg
, char* end
)
67 { this->setp(beg
, end
); }
73 int_type __retval
= traits_type::eof();
74 if (this->gptr() < this->egptr())
75 __retval
= traits_type::not_eof(0);
82 typedef testbuf::traits_type traits_type
;
83 typedef testbuf::int_type int_type
;
86 std::strcpy(lit01
, "chicago underground trio/possible cube on delmark");
91 buf01
.pub_setg(lit01
, lit01
, (lit01
+ i01
));
92 VERIFY( i01
== buf01
.in_avail() );
93 int_type intt01
= traits_type::to_int_type('b');
94 VERIFY( traits_type::eof() == buf01
.pub_pbackfail(intt01
) );
97 VERIFY( traits_type::eof() == buf01
.pub_overflow(intt01
) );
98 VERIFY( traits_type::eof() == buf01
.pub_overflow() );
99 VERIFY( buf01
.sgetc() == traits_type::to_int_type(lit01
[0]) );