diff options
author | Howard Hinnant <hhinnant@apple.com> | 2010-05-11 19:42:16 +0000 |
---|---|---|
committer | Howard Hinnant <hhinnant@apple.com> | 2010-05-11 19:42:16 +0000 |
commit | 3e519524c118651123eecf60c2bbc5d65ad9bac3 (patch) | |
tree | b2dd4168cfe448920a602cd7d2e40f95da187153 /libcxx/test/strings/basic.string/string.nonmembers/string.io | |
parent | 9132c59d43b6c590c9bb33496eebf9f192d6857a (diff) | |
download | bcm5719-llvm-3e519524c118651123eecf60c2bbc5d65ad9bac3.tar.gz bcm5719-llvm-3e519524c118651123eecf60c2bbc5d65ad9bac3.zip |
libcxx initial import
llvm-svn: 103490
Diffstat (limited to 'libcxx/test/strings/basic.string/string.nonmembers/string.io')
6 files changed, 288 insertions, 0 deletions
diff --git a/libcxx/test/strings/basic.string/string.nonmembers/string.io/get_line.pass.cpp b/libcxx/test/strings/basic.string/string.nonmembers/string.io/get_line.pass.cpp new file mode 100644 index 00000000000..5991c1c9c3a --- /dev/null +++ b/libcxx/test/strings/basic.string/string.nonmembers/string.io/get_line.pass.cpp @@ -0,0 +1,49 @@ +//===----------------------------------------------------------------------===// +// +// ΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚThe LLVM Compiler Infrastructure +// +// This file is distributed under the University of Illinois Open Source +// License. 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> + +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"); + } +} diff --git a/libcxx/test/strings/basic.string/string.nonmembers/string.io/get_line_delim.pass.cpp b/libcxx/test/strings/basic.string/string.nonmembers/string.io/get_line_delim.pass.cpp new file mode 100644 index 00000000000..97f4ffd0112 --- /dev/null +++ b/libcxx/test/strings/basic.string/string.nonmembers/string.io/get_line_delim.pass.cpp @@ -0,0 +1,49 @@ +//===----------------------------------------------------------------------===// +// +// ΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚThe LLVM Compiler Infrastructure +// +// This file is distributed under the University of Illinois Open Source +// License. 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, charT delim); + +#include <string> +#include <sstream> +#include <cassert> + +int main() +{ + { + std::istringstream in(" abc* def* 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* def* ghij"); + std::wstring s(L"initial text"); + getline(in, s, L'*'); + assert(in.good()); + assert(s == L" abc"); + getline(in, s, L'*'); + assert(in.good()); + assert(s == L" def"); + getline(in, s, L'*'); + assert(in.eof()); + assert(s == L" ghij"); + } +} diff --git a/libcxx/test/strings/basic.string/string.nonmembers/string.io/get_line_delim_rv.pass.cpp b/libcxx/test/strings/basic.string/string.nonmembers/string.io/get_line_delim_rv.pass.cpp new file mode 100644 index 00000000000..cd9b711b0e3 --- /dev/null +++ b/libcxx/test/strings/basic.string/string.nonmembers/string.io/get_line_delim_rv.pass.cpp @@ -0,0 +1,35 @@ +//===----------------------------------------------------------------------===// +// +// ΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚThe LLVM Compiler Infrastructure +// +// This file is distributed under the University of Illinois Open Source +// License. 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, charT delim); + +#include <string> +#include <sstream> +#include <cassert> + +int main() +{ +#ifdef _LIBCPP_MOVE + { + std::string s("initial text"); + getline(std::istringstream(" abc* def* ghij"), s, '*'); + assert(s == " abc"); + } + { + std::wstring s(L"initial text"); + getline(std::wistringstream(L" abc* def* ghij"), s, L'*'); + assert(s == L" abc"); + } +#endif +} diff --git a/libcxx/test/strings/basic.string/string.nonmembers/string.io/get_line_rv.pass.cpp b/libcxx/test/strings/basic.string/string.nonmembers/string.io/get_line_rv.pass.cpp new file mode 100644 index 00000000000..6541f46ec38 --- /dev/null +++ b/libcxx/test/strings/basic.string/string.nonmembers/string.io/get_line_rv.pass.cpp @@ -0,0 +1,35 @@ +//===----------------------------------------------------------------------===// +// +// ΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚThe LLVM Compiler Infrastructure +// +// This file is distributed under the University of Illinois Open Source +// License. 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> + +int main() +{ +#ifdef _LIBCPP_MOVE + { + std::string s("initial text"); + getline(std::istringstream(" abc\n def\n ghij"), s); + assert(s == " abc"); + } + { + std::wstring s(L"initial text"); + getline(std::wistringstream(L" abc\n def\n ghij"), s); + assert(s == L" abc"); + } +#endif +} diff --git a/libcxx/test/strings/basic.string/string.nonmembers/string.io/stream_extract.pass.cpp b/libcxx/test/strings/basic.string/string.nonmembers/string.io/stream_extract.pass.cpp new file mode 100644 index 00000000000..cf50090d860 --- /dev/null +++ b/libcxx/test/strings/basic.string/string.nonmembers/string.io/stream_extract.pass.cpp @@ -0,0 +1,67 @@ +//===----------------------------------------------------------------------===// +// +// ΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚThe LLVM Compiler Infrastructure +// +// This file is distributed under the University of Illinois Open Source +// License. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// + +// <string> + +// template<class charT, class traits, class Allocator> +// basic_istream<charT,traits>& +// operator>>(basic_istream<charT,traits>& is, +// basic_string<charT,traits,Allocator>& str); + +#include <string> +#include <sstream> +#include <cassert> + +int main() +{ + { + std::istringstream in("a bc defghij"); + std::string s("initial text"); + in >> s; + assert(in.good()); + assert(s == "a"); + assert(in.peek() == ' '); + in >> s; + assert(in.good()); + assert(s == "bc"); + assert(in.peek() == ' '); + in.width(3); + in >> s; + assert(in.good()); + assert(s == "def"); + assert(in.peek() == 'g'); + in >> s; + assert(in.eof()); + assert(s == "ghij"); + in >> s; + assert(in.fail()); + } + { + std::wistringstream in(L"a bc defghij"); + std::wstring s(L"initial text"); + in >> s; + assert(in.good()); + assert(s == L"a"); + assert(in.peek() == L' '); + in >> s; + assert(in.good()); + assert(s == L"bc"); + assert(in.peek() == L' '); + in.width(3); + in >> s; + assert(in.good()); + assert(s == L"def"); + assert(in.peek() == L'g'); + in >> s; + assert(in.eof()); + assert(s == L"ghij"); + in >> s; + assert(in.fail()); + } +} diff --git a/libcxx/test/strings/basic.string/string.nonmembers/string.io/stream_insert.pass.cpp b/libcxx/test/strings/basic.string/string.nonmembers/string.io/stream_insert.pass.cpp new file mode 100644 index 00000000000..d50c4982dda --- /dev/null +++ b/libcxx/test/strings/basic.string/string.nonmembers/string.io/stream_insert.pass.cpp @@ -0,0 +1,53 @@ +//===----------------------------------------------------------------------===// +// +// ΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚThe LLVM Compiler Infrastructure +// +// This file is distributed under the University of Illinois Open Source +// License. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// + +// <string> + +// template<class charT, class traits, class Allocator> +// basic_ostream<charT, traits>& +// operator<<(basic_ostream<charT, traits>& os, +// const basic_string<charT,traits,Allocator>& str); + +#include <string> +#include <sstream> +#include <cassert> + +int main() +{ + { + std::ostringstream out; + std::string s("some text"); + out << s; + assert(out.good()); + assert(s == out.str()); + } + { + std::ostringstream out; + std::string s("some text"); + out.width(12); + out << s; + assert(out.good()); + assert(" " + s == out.str()); + } + { + std::wostringstream out; + std::wstring s(L"some text"); + out << s; + assert(out.good()); + assert(s == out.str()); + } + { + std::wostringstream out; + std::wstring s(L"some text"); + out.width(12); + out << s; + assert(out.good()); + assert(L" " + s == out.str()); + } +} |