xref: /llvm-project/libcxx/test/std/strings/basic.string/string.nonmembers/string.io/get_line_rv.pass.cpp (revision 57b08b0944046a6a57ee9b7b479181f548a5b9b4)
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 //===----------------------------------------------------------------------===//
8 
9 // UNSUPPORTED: c++98, c++03
10 
11 // <string>
12 
13 // template<class charT, class traits, class Allocator>
14 //   basic_istream<charT,traits>&
15 //   getline(basic_istream<charT,traits>&& is,
16 //           basic_string<charT,traits,Allocator>& str);
17 
18 #include <string>
19 #include <sstream>
20 #include <cassert>
21 
22 #include "min_allocator.h"
23 
24 int main()
25 {
26     {
27         std::string s("initial text");
28         getline(std::istringstream(" abc\n  def\n   ghij"), s);
29         assert(s == " abc");
30     }
31     {
32         std::wstring s(L"initial text");
33         getline(std::wistringstream(L" abc\n  def\n   ghij"), s);
34         assert(s == L" abc");
35     }
36     {
37         typedef std::basic_string<char, std::char_traits<char>, min_allocator<char>> S;
38         S s("initial text");
39         getline(std::istringstream(" abc\n  def\n   ghij"), s);
40         assert(s == " abc");
41     }
42     {
43         typedef std::basic_string<wchar_t, std::char_traits<wchar_t>, min_allocator<wchar_t>> S;
44         S s(L"initial text");
45         getline(std::wistringstream(L" abc\n  def\n   ghij"), s);
46         assert(s == L" abc");
47     }
48 }
49