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_WSTRING_CONVERT
13 // wbuffer_convert<Codecvt, Elem, Tr>
15 // pos_type seekoff(off_type off, ios_base::seekdir way,
16 // ios_base::openmode which = ios_base::in | ios_base::out);
17 // pos_type seekpos(pos_type sp,
18 // ios_base::openmode which = ios_base::in | ios_base::out);
20 // This test is not entirely portable
22 // XFAIL: no-wide-characters
24 // TODO: Avoid using <fstream> in this test.
25 // XFAIL: no-filesystem
33 : public std::codecvt
<wchar_t, char, std::mbstate_t>
35 typedef std::codecvt
<wchar_t, char, std::mbstate_t> base
;
37 explicit test_codecvt(std::size_t refs
= 0) : base(refs
) {}
45 typedef std::wbuffer_convert
<test_codecvt
> test_buf
;
46 typedef test_buf::pos_type pos_type
;
47 std::fstream
bs("seekoff.dat", std::ios::trunc
| std::ios::in
49 test_buf
f(bs
.rdbuf());
50 f
.pubsetbuf(buf
, sizeof(buf
)/sizeof(buf
[0]));
51 f
.sputn(L
"abcdefghijklmnopqrstuvwxyz", 26);
52 assert(buf
[0] == L
'v');
53 pos_type p
= f
.pubseekoff(-15, std::ios_base::cur
);
55 assert(f
.sgetc() == L
'l');
56 f
.pubseekoff(0, std::ios_base::beg
);
57 assert(f
.sgetc() == L
'a');
58 f
.pubseekoff(-1, std::ios_base::end
);
59 assert(f
.sgetc() == L
'z');
60 assert(f
.pubseekpos(p
) == p
);
61 assert(f
.sgetc() == L
'l');
63 std::remove("seekoff.dat");