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 //===----------------------------------------------------------------------===//
11 // template<class charT, class traits, class Allocator>
12 // basic_istream<charT,traits>&
13 // getline(basic_istream<charT,traits>& is,
14 // basic_string<charT,traits,Allocator>& str);
20 #include "min_allocator.h"
21 #include "test_macros.h"
23 template <template <class> class Alloc
>
25 using S
= std::basic_string
<char, std::char_traits
<char>, Alloc
<char> >;
26 #ifndef TEST_HAS_NO_WIDE_CHARACTERS
27 using WS
= std::basic_string
<wchar_t, std::char_traits
<wchar_t>, Alloc
<wchar_t> >;
30 std::istringstream
in(" abc\n def\n ghij");
42 #ifndef TEST_HAS_NO_WIDE_CHARACTERS
44 std::wistringstream
in(L
" abc\n def\n ghij");
45 WS
s(L
"initial text");
54 assert(s
== L
" ghij");
58 #ifndef TEST_HAS_NO_EXCEPTIONS
60 std::basic_stringbuf
<char> sb("hello");
61 std::basic_istream
<char> is(&sb
);
62 is
.exceptions(std::ios_base::eofbit
);
68 } catch (std::ios::failure
const&) {
78 # ifndef TEST_HAS_NO_WIDE_CHARACTERS
80 std::basic_stringbuf
<wchar_t> sb(L
"hello");
81 std::basic_istream
<wchar_t> is(&sb
);
82 is
.exceptions(std::ios_base::eofbit
);
88 } catch (std::ios::failure
const&) {
96 assert(s
== L
"hello");
101 std::basic_stringbuf
<char> sb
;
102 std::basic_istream
<char> is(&sb
);
103 is
.exceptions(std::ios_base::failbit
);
109 } catch (std::ios::failure
const&) {
119 # ifndef TEST_HAS_NO_WIDE_CHARACTERS
121 std::basic_stringbuf
<wchar_t> sb
;
122 std::basic_istream
<wchar_t> is(&sb
);
123 is
.exceptions(std::ios_base::failbit
);
129 } catch (std::ios::failure
const&) {
140 #endif // TEST_HAS_NO_EXCEPTIONS
143 int main(int, char**) {
144 test_string
<std::allocator
>();
145 #if TEST_STD_VER >= 11
146 test_string
<min_allocator
>();