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 //===----------------------------------------------------------------------===//
10 // XFAIL: with_system_cxx_lib=macosx10.7
11 // XFAIL: with_system_cxx_lib=macosx10.8
15 // streamsize readsome(char_type* s, streamsize n);
20 template <class CharT>
22 : public std::basic_streambuf<CharT>
24 typedef std::basic_string<CharT> string_type;
25 typedef std::basic_streambuf<CharT> base;
31 testbuf(const string_type& str)
34 base::setg(const_cast<CharT*>(str_.data()),
35 const_cast<CharT*>(str_.data()),
36 const_cast<CharT*>(str_.data()) + str_.size());
39 CharT* eback() const {return base::eback();}
40 CharT* gptr() const {return base::gptr();}
41 CharT* egptr() const {return base::egptr();}
47 testbuf<char> sb(" 1234567890");
50 assert(is.readsome(s, 5) == 5);
53 assert(std::string(s, 5) == " 1234");
54 assert(is.gcount() == 5);
58 assert(std::string(s, 5) == "56789");
59 assert(is.gcount() == 5);
63 assert(is.gcount() == 1);
64 assert(std::string(s, 1) == "0");
65 assert(is.readsome(s, 5) == 0);
68 testbuf<wchar_t> sb(L" 1234567890");
69 std::wistream is(&sb);
71 assert(is.readsome(s, 5) == 5);
74 assert(std::wstring(s, 5) == L" 1234");
75 assert(is.gcount() == 5);
79 assert(std::wstring(s, 5) == L"56789");
80 assert(is.gcount() == 5);
84 assert(is.gcount() == 1);
85 assert(std::wstring(s, 1) == L"0");
86 assert(is.readsome(s, 5) == 0);