[AMDGPU] Implement IR variant of isFMAFasterThanFMulAndFAdd (#121465)
[llvm-project.git] / libcxx / test / std / input.output / iostream.format / input.streams / istream.unformatted / ignore.pass.cpp
bloba9274aab3af409ec8cffd71b51ff3c0c5194e0d4
1 //===----------------------------------------------------------------------===//
2 //
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
6 //
7 //===----------------------------------------------------------------------===//
9 // Requires 396145d in the built library.
10 // XFAIL: using-built-library-before-llvm-9
12 // <istream>
14 // basic_istream<charT,traits>&
15 // ignore(streamsize n = 1, int_type delim = traits::eof());
17 #include <istream>
18 #include <cassert>
19 #include <streambuf>
21 #include "test_macros.h"
23 template <class CharT>
24 struct testbuf
25 : public std::basic_streambuf<CharT>
27 typedef std::basic_string<CharT> string_type;
28 typedef std::basic_streambuf<CharT> base;
29 private:
30 string_type str_;
31 public:
33 testbuf() {}
34 testbuf(const string_type& str)
35 : str_(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();}
47 int main(int, char**)
50 testbuf<char> sb(" 1\n2345\n6");
51 std::istream is(&sb);
52 is.ignore();
53 assert(!is.eof());
54 assert(!is.fail());
55 assert(is.gcount() == 1);
56 is.ignore(5, '\n');
57 assert(!is.eof());
58 assert(!is.fail());
59 assert(is.gcount() == 2);
60 is.ignore(15);
61 assert( is.eof());
62 assert(!is.fail());
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);
69 is.ignore();
70 assert(!is.eof());
71 assert(!is.fail());
72 assert(is.gcount() == 1);
73 is.ignore(5, '\n');
74 assert(!is.eof());
75 assert(!is.fail());
76 assert(is.gcount() == 2);
77 is.ignore(15);
78 assert( is.eof());
79 assert(!is.fail());
80 assert(is.gcount() == 6);
82 #endif
83 #ifndef TEST_HAS_NO_EXCEPTIONS
85 testbuf<char> sb(" ");
86 std::basic_istream<char> is(&sb);
87 is.exceptions(std::ios_base::eofbit);
88 bool threw = false;
89 try {
90 is.ignore(5);
91 } catch (std::ios_base::failure&) {
92 threw = true;
94 assert(threw);
95 assert(!is.bad());
96 assert( is.eof());
97 assert(!is.fail());
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);
104 bool threw = false;
105 try {
106 is.ignore(5);
107 } catch (std::ios_base::failure&) {
108 threw = true;
110 assert(threw);
111 assert(!is.bad());
112 assert( is.eof());
113 assert(!is.fail());
115 #endif
116 #endif // TEST_HAS_NO_EXCEPTIONS
118 return 0;