summaryrefslogtreecommitdiffstats
path: root/libcxx/test/strings/basic.string/string.nonmembers/string.io
diff options
context:
space:
mode:
Diffstat (limited to 'libcxx/test/strings/basic.string/string.nonmembers/string.io')
-rw-r--r--libcxx/test/strings/basic.string/string.nonmembers/string.io/get_line.pass.cpp49
-rw-r--r--libcxx/test/strings/basic.string/string.nonmembers/string.io/get_line_delim.pass.cpp49
-rw-r--r--libcxx/test/strings/basic.string/string.nonmembers/string.io/get_line_delim_rv.pass.cpp35
-rw-r--r--libcxx/test/strings/basic.string/string.nonmembers/string.io/get_line_rv.pass.cpp35
-rw-r--r--libcxx/test/strings/basic.string/string.nonmembers/string.io/stream_extract.pass.cpp67
-rw-r--r--libcxx/test/strings/basic.string/string.nonmembers/string.io/stream_insert.pass.cpp53
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());
+ }
+}
OpenPOWER on IntegriCloud