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 //===----------------------------------------------------------------------===//
9 // XFAIL: stdlib=apple-libc++ && target={{.+}}-apple-macosx10.{{9|10|11|12|13|14}}
13 // basic_istream<charT,traits>& get(char_type& c);
17 #include "test_macros.h"
19 template <class CharT
>
21 : public std::basic_streambuf
<CharT
>
23 typedef std::basic_string
<CharT
> string_type
;
24 typedef std::basic_streambuf
<CharT
> base
;
30 testbuf(const string_type
& str
)
33 base::setg(const_cast<CharT
*>(str_
.data()),
34 const_cast<CharT
*>(str_
.data()),
35 const_cast<CharT
*>(str_
.data()) + str_
.size());
38 CharT
* eback() const {return base::eback();}
39 CharT
* gptr() const {return base::gptr();}
40 CharT
* egptr() const {return base::egptr();}
46 testbuf
<char> sb(" ");
53 assert(is
.gcount() == 1);
56 testbuf
<char> sb(" abc");
63 assert(is
.gcount() == 1);
68 assert(is
.gcount() == 1);
73 assert(is
.gcount() == 1);
78 assert(is
.gcount() == 1);
80 #ifndef TEST_HAS_NO_WIDE_CHARACTERS
82 testbuf
<wchar_t> sb(L
" abc");
83 std::wistream
is(&sb
);
89 assert(is
.gcount() == 1);
94 assert(is
.gcount() == 1);
99 assert(is
.gcount() == 1);
104 assert(is
.gcount() == 1);
106 #endif // TEST_HAS_NO_WIDE_CHARACTERS
107 #ifndef TEST_HAS_NO_EXCEPTIONS
109 testbuf
<char> sb("rrrrrrrrr");
110 std::basic_istream
<char> is(&sb
);
111 is
.exceptions(std::ios_base::eofbit
);
121 } catch (std::ios_base::failure
const&) {
130 #ifndef TEST_HAS_NO_WIDE_CHARACTERS
132 testbuf
<wchar_t> sb(L
"rrrrrrrrr");
133 std::basic_istream
<wchar_t> is(&sb
);
134 is
.exceptions(std::ios_base::eofbit
);
144 } catch (std::ios_base::failure
const&) {
153 #endif // TEST_HAS_NO_WIDE_CHARACTERS
154 #endif // TEST_HAS_NO_EXCEPTIONS