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 // Requires 396145d in the built library.
10 // XFAIL: using-built-library-before-llvm-9
14 // basic_istream<charT,traits>&
15 // ignore(streamsize n = 1, int_type delim = traits::eof());
21 #include "test_macros.h"
23 template <class CharT
>
25 : public std::basic_streambuf
<CharT
>
27 typedef std::basic_string
<CharT
> string_type
;
28 typedef std::basic_streambuf
<CharT
> base
;
34 testbuf(const string_type
& str
)
37 base::setg(const_cast<CharT
*>(str_
.data()),
38 const_cast<CharT
*>(str_
.data()),
39 const_cast<CharT
*>(str_
.data()) + str_
.size());
42 CharT
* eback() const {return base::eback();}
43 CharT
* gptr() const {return base::gptr();}
44 CharT
* egptr() const {return base::egptr();}
50 testbuf
<char> sb(" 1\n2345\n6");
55 assert(is
.gcount() == 1);
59 assert(is
.gcount() == 2);
63 assert(is
.gcount() == 6);
65 #ifndef TEST_HAS_NO_WIDE_CHARACTERS
67 testbuf
<wchar_t> sb(L
" 1\n2345\n6");
68 std::wistream
is(&sb
);
72 assert(is
.gcount() == 1);
76 assert(is
.gcount() == 2);
80 assert(is
.gcount() == 6);
83 #ifndef TEST_HAS_NO_EXCEPTIONS
85 testbuf
<char> sb(" ");
86 std::basic_istream
<char> is(&sb
);
87 is
.exceptions(std::ios_base::eofbit
);
91 } catch (std::ios_base::failure
&) {
99 #ifndef TEST_HAS_NO_WIDE_CHARACTERS
101 testbuf
<wchar_t> sb(L
" ");
102 std::basic_istream
<wchar_t> is(&sb
);
103 is
.exceptions(std::ios_base::eofbit
);
107 } catch (std::ios_base::failure
&) {
116 #endif // TEST_HAS_NO_EXCEPTIONS