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++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 "test_macros.h" 23 #include "min_allocator.h" 24 25 int main(int, char**) 26 { 27 { 28 std::string s("initial text"); 29 getline(std::istringstream(" abc\n def\n ghij"), s); 30 assert(s == " abc"); 31 } 32 { 33 std::wstring s(L"initial text"); 34 getline(std::wistringstream(L" abc\n def\n ghij"), s); 35 assert(s == L" abc"); 36 } 37 { 38 typedef std::basic_string<char, std::char_traits<char>, min_allocator<char>> S; 39 S s("initial text"); 40 getline(std::istringstream(" abc\n def\n ghij"), s); 41 assert(s == " abc"); 42 } 43 { 44 typedef std::basic_string<wchar_t, std::char_traits<wchar_t>, min_allocator<wchar_t>> S; 45 S s(L"initial text"); 46 getline(std::wistringstream(L" abc\n def\n ghij"), s); 47 assert(s == L" abc"); 48 } 49 50 return 0; 51 } 52