1 //===----------------------------------------------------------------------===//
3 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4 // See https://llvm.org/LICENSE.txt for license information.
5 // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
7 //===----------------------------------------------------------------------===//
11 // ADDITIONAL_COMPILE_FLAGS: -D_LIBCPP_DISABLE_DEPRECATION_WARNINGS -D_LIBCPP_ENABLE_CXX26_REMOVED_CODECVT -D_LIBCPP_ENABLE_CXX26_REMOVED_WSTRING_CONVERT
13 // wbuffer_convert<Codecvt, Elem, Tr>
15 // int_type pbackfail(int_type c = traits::eof());
17 // This test is not entirely portable
19 // XFAIL: no-wide-characters
27 : public std::wbuffer_convert
<std::codecvt_utf8
<wchar_t> >
29 typedef std::wbuffer_convert
<std::codecvt_utf8
<wchar_t> > base
;
30 typedef base::char_type char_type
;
31 typedef base::int_type int_type
;
32 typedef base::traits_type traits_type
;
34 explicit test_buf(std::streambuf
* sb
) : base(sb
) {}
36 char_type
* eback() const {return base::eback();}
37 char_type
* gptr() const {return base::gptr();}
38 char_type
* egptr() const {return base::egptr();}
39 void gbump(int n
) {base::gbump(n
);}
41 virtual int_type
pbackfail(int_type c
= traits_type::eof()) {return base::pbackfail(c
);}
46 std::string
const s
= "123456789";
48 std::istringstream
in(s
);
49 test_buf
f(in
.rdbuf());
50 assert(f
.sbumpc() == L
'1');
51 assert(f
.sgetc() == L
'2');
52 assert(f
.pbackfail(L
'a') == test_buf::traits_type::eof());
55 std::istringstream
in(s
);
56 test_buf
f(in
.rdbuf());
57 assert(f
.sbumpc() == L
'1');
58 assert(f
.sgetc() == L
'2');
59 assert(f
.pbackfail(L
'a') == test_buf::traits_type::eof());
60 assert(f
.sbumpc() == L
'2');
61 assert(f
.sgetc() == L
'3');