1 //===----------------------------------------------------------------------===//
3 // The LLVM Compiler Infrastructure
5 // This file is dual licensed under the MIT and the University of Illinois Open
6 // Source Licenses. See LICENSE.TXT for details.
8 //===----------------------------------------------------------------------===//
17 template <class CharT>
19 : public std::basic_streambuf<CharT>
21 typedef std::basic_string<CharT> string_type;
22 typedef std::basic_streambuf<CharT> base;
28 testbuf(const string_type& str)
31 base::setg(const_cast<CharT*>(str_.data()),
32 const_cast<CharT*>(str_.data()),
33 const_cast<CharT*>(str_.data()) + str_.size());
36 CharT* eback() const {return base::eback();}
37 CharT* gptr() const {return base::gptr();}
38 CharT* egptr() const {return base::egptr();}
44 testbuf<char> sb(" ");
50 assert(is.gcount() == 1);
53 testbuf<char> sb(" abc");
59 assert(is.gcount() == 1);
64 assert(is.gcount() == 1);
69 assert(is.gcount() == 1);
74 assert(is.gcount() == 1);
77 testbuf<wchar_t> sb(L" abc");
78 std::wistream is(&sb);
83 assert(is.gcount() == 1);
88 assert(is.gcount() == 1);
93 assert(is.gcount() == 1);
98 assert(is.gcount() == 1);