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
13 // wbuffer_convert<Codecvt, Elem, Tr>
15 // int_type underflow();
17 // This test is not entirely portable
19 // XFAIL: no-wide-characters
26 #include "test_macros.h"
29 : public std::wbuffer_convert
<std::codecvt_utf8
<wchar_t> >
31 typedef std::wbuffer_convert
<std::codecvt_utf8
<wchar_t> > base
;
32 typedef base::char_type char_type
;
33 typedef base::int_type int_type
;
34 typedef base::traits_type traits_type
;
36 explicit test_buf(std::streambuf
* sb
) : base(sb
) {}
38 char_type
* eback() const {return base::eback();}
39 char_type
* gptr() const {return base::gptr();}
40 char_type
* egptr() const {return base::egptr();}
41 void gbump(int n
) {base::gbump(n
);}
43 virtual int_type
underflow() {return base::underflow();}
49 std::string s
= "123456789";
50 std::istringstream
bs(s
);
51 test_buf
f(bs
.rdbuf());
52 assert(f
.eback() == 0);
53 assert(f
.gptr() == 0);
54 assert(f
.egptr() == 0);
55 assert(f
.underflow() == L
'1');
56 assert(f
.eback() != 0);
57 assert(f
.eback() == f
.gptr());
58 assert(*f
.gptr() == L
'1');
59 assert(f
.egptr() - f
.eback() == 9);
62 std::string s
= "123456789";
63 std::istringstream
bs(s
);
64 test_buf
f(bs
.rdbuf());
65 assert(f
.eback() == 0);
66 assert(f
.gptr() == 0);
67 assert(f
.egptr() == 0);
68 assert(f
.underflow() == L
'1');
69 assert(f
.eback() != 0);
70 assert(f
.eback() == f
.gptr());
71 assert(*f
.gptr() == L
'1');
72 assert(f
.egptr() - f
.eback() == 9);
74 assert(f
.sgetc() == L
'9');
75 assert(f
.eback()[0] == L
'1');
76 assert(f
.eback()[1] == L
'2');
77 assert(f
.eback()[2] == L
'3');
78 assert(f
.eback()[3] == L
'4');
79 assert(f
.gptr() - f
.eback() == 8);
80 assert(*f
.gptr() == L
'9');
81 assert(f
.egptr() - f
.gptr() == 1);
84 std::string s
= "乑乒乓";
85 std::istringstream
bs(s
);
86 test_buf
f(bs
.rdbuf());
87 assert(f
.sbumpc() == 0x4E51);
88 assert(f
.sbumpc() == 0x4E52);
89 assert(f
.sbumpc() == 0x4E53);
90 assert(f
.sbumpc() == test_buf::traits_type::eof());