diff options
author | Dimitry Andric <dim@FreeBSD.org> | 2015-09-06 18:46:46 +0000 |
---|---|---|
committer | Dimitry Andric <dim@FreeBSD.org> | 2015-09-06 18:46:46 +0000 |
commit | 61b9a7258a7693d7f3674a5a1daf7b036ff1d382 (patch) | |
tree | ec41ed70ffca97240e76f9a78bb2dedba28f310c /test/std/strings/basic.string/string.nonmembers/string.io/get_line.pass.cpp | |
parent | f857581820d15e410e9945d2fcd5f7163be25a96 (diff) | |
download | src-61b9a7258a7693d7f3674a5a1daf7b036ff1d382.tar.gz src-61b9a7258a7693d7f3674a5a1daf7b036ff1d382.zip |
Import libc++ 3.7.0 release (r246257).vendor/libc++/libc++-release_370-r246257
Notes
Notes:
svn path=/vendor/libc++/dist/; revision=287518
svn path=/vendor/libc++/libc++-release_370-r246257/; revision=287519; tag=vendor/libc++/libc++-release_370-r246257
Diffstat (limited to 'test/std/strings/basic.string/string.nonmembers/string.io/get_line.pass.cpp')
-rw-r--r-- | test/std/strings/basic.string/string.nonmembers/string.io/get_line.pass.cpp | 81 |
1 files changed, 81 insertions, 0 deletions
diff --git a/test/std/strings/basic.string/string.nonmembers/string.io/get_line.pass.cpp b/test/std/strings/basic.string/string.nonmembers/string.io/get_line.pass.cpp new file mode 100644 index 000000000000..4a912eaec6fa --- /dev/null +++ b/test/std/strings/basic.string/string.nonmembers/string.io/get_line.pass.cpp @@ -0,0 +1,81 @@ +//===----------------------------------------------------------------------===// +// +// The LLVM Compiler Infrastructure +// +// This file is dual licensed under the MIT and the University of Illinois Open +// Source Licenses. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// + +// <string> + +// template<class charT, class traits, class Allocator> +// basic_istream<charT,traits>& +// getline(basic_istream<charT,traits>& is, +// basic_string<charT,traits,Allocator>& str); + +#include <string> +#include <sstream> +#include <cassert> + +#include "min_allocator.h" + +int main() +{ + { + std::istringstream in(" abc\n def\n ghij"); + std::string s("initial text"); + getline(in, s); + assert(in.good()); + assert(s == " abc"); + getline(in, s); + assert(in.good()); + assert(s == " def"); + getline(in, s); + assert(in.eof()); + assert(s == " ghij"); + } + { + std::wistringstream in(L" abc\n def\n ghij"); + std::wstring s(L"initial text"); + getline(in, s); + assert(in.good()); + assert(s == L" abc"); + getline(in, s); + assert(in.good()); + assert(s == L" def"); + getline(in, s); + assert(in.eof()); + assert(s == L" ghij"); + } +#if __cplusplus >= 201103L + { + typedef std::basic_string<char, std::char_traits<char>, min_allocator<char>> S; + std::istringstream in(" abc\n def\n ghij"); + S s("initial text"); + getline(in, s); + assert(in.good()); + assert(s == " abc"); + getline(in, s); + assert(in.good()); + assert(s == " def"); + getline(in, s); + assert(in.eof()); + assert(s == " ghij"); + } + { + typedef std::basic_string<wchar_t, std::char_traits<wchar_t>, min_allocator<wchar_t>> S; + std::wistringstream in(L" abc\n def\n ghij"); + S s(L"initial text"); + getline(in, s); + assert(in.good()); + assert(s == L" abc"); + getline(in, s); + assert(in.good()); + assert(s == L" def"); + getline(in, s); + assert(in.eof()); + assert(s == L" ghij"); + } +#endif +} |