]>
git.ipfire.org Git - thirdparty/gcc.git/blob - libstdc++-v3/testsuite/27_io/basic_filebuf/underflow/char/3.cc
1 // Copyright (C) 2007-2020 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 // 27.8.1.4 Overridden virtual functions
20 // { dg-require-fileio "" }
25 #include <testsuite_hooks.h>
28 : public std::codecvt
<char, char, std::mbstate_t>
33 const extern_type
* from
, const extern_type
* from_end
,
34 const extern_type
*& from_next
,
35 intern_type
* to
, intern_type
* to_limit
,
36 intern_type
*& to_next
) const
38 from_next
= from
, to_next
= to
;
40 if (from_next
== from_end
|| to_next
== to_limit
)
43 if (std::islower(*from_next
))
44 *to_next
= std::toupper(*from_next
);
46 *to_next
= *from_next
;
47 ++from_next
, ++to_next
;
52 do_always_noconv() const throw()
56 // See Novell Bug 255122
61 const char* name
= "tmp_underflow_3.tst";
64 fbuf
.open(name
, ios_base::out
| ios_base::trunc
);
65 VERIFY( fbuf
.sputc('a') == 'a' );
66 VERIFY( fbuf
.sputc('b') == 'b' );
67 VERIFY( fbuf
.sputc('\n') == '\n' );
70 fbufx
.pubimbue(locale(locale::classic(), new Mycvtcc
));
71 fbufx
.open(name
, ios_base::in
);
72 VERIFY( fbufx
.sbumpc() == 'A' );
73 VERIFY( fbufx
.sbumpc() == 'B' );
74 VERIFY( fbufx
.sbumpc() == '\n' );
75 VERIFY( fbufx
.sbumpc() == filebuf::traits_type::eof() );