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 //===----------------------------------------------------------------------===//
16 #include "test_macros.h"
18 template <class CharT
>
20 : public std::basic_streambuf
<CharT
>
22 typedef std::basic_string
<CharT
> string_type
;
23 typedef std::basic_streambuf
<CharT
> base
;
29 testbuf(const string_type
& str
)
32 base::setg(const_cast<CharT
*>(str_
.data()),
33 const_cast<CharT
*>(str_
.data()),
34 const_cast<CharT
*>(str_
.data()) + str_
.size());
37 CharT
* eback() const {return base::eback();}
38 CharT
* gptr() const {return base::gptr();}
39 CharT
* egptr() const {return base::egptr();}
41 typename
base::pos_type
seekoff(typename
base::off_type off
,
42 std::ios_base::seekdir way
,
43 std::ios_base::openmode which
)
46 assert(way
== std::ios_base::cur
);
47 assert(which
== std::ios_base::in
);
55 testbuf
<char> sb(" 123456789");
57 assert(is
.tellg() == 5);
59 #ifndef TEST_HAS_NO_WIDE_CHARACTERS
61 testbuf
<wchar_t> sb(L
" 123456789");
62 std::wistream
is(&sb
);
63 assert(is
.tellg() == 5);