summaryrefslogtreecommitdiffstats
path: root/libcxx/test/std/input.output/file.streams/fstreams/ifstream.assign
diff options
context:
space:
mode:
Diffstat (limited to 'libcxx/test/std/input.output/file.streams/fstreams/ifstream.assign')
-rw-r--r--libcxx/test/std/input.output/file.streams/fstreams/ifstream.assign/member_swap.pass.cpp42
-rw-r--r--libcxx/test/std/input.output/file.streams/fstreams/ifstream.assign/move_assign.pass.cpp40
-rw-r--r--libcxx/test/std/input.output/file.streams/fstreams/ifstream.assign/nonmember_swap.pass.cpp43
-rw-r--r--libcxx/test/std/input.output/file.streams/fstreams/ifstream.assign/test.dat1
-rw-r--r--libcxx/test/std/input.output/file.streams/fstreams/ifstream.assign/test2.dat1
5 files changed, 127 insertions, 0 deletions
diff --git a/libcxx/test/std/input.output/file.streams/fstreams/ifstream.assign/member_swap.pass.cpp b/libcxx/test/std/input.output/file.streams/fstreams/ifstream.assign/member_swap.pass.cpp
new file mode 100644
index 00000000000..18443cedb8d
--- /dev/null
+++ b/libcxx/test/std/input.output/file.streams/fstreams/ifstream.assign/member_swap.pass.cpp
@@ -0,0 +1,42 @@
+//===----------------------------------------------------------------------===//
+//
+// 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.
+//
+//===----------------------------------------------------------------------===//
+
+// <fstream>
+
+// template <class charT, class traits = char_traits<charT> >
+// class basic_ifstream
+
+// void swap(basic_ifstream& rhs);
+
+#include <fstream>
+#include <cassert>
+
+int main()
+{
+ {
+ std::ifstream fs1("test.dat");
+ std::ifstream fs2("test2.dat");
+ fs1.swap(fs2);
+ double x = 0;
+ fs1 >> x;
+ assert(x == 4.5);
+ fs2 >> x;
+ assert(x == 3.25);
+ }
+ {
+ std::wifstream fs1("test.dat");
+ std::wifstream fs2("test2.dat");
+ fs1.swap(fs2);
+ double x = 0;
+ fs1 >> x;
+ assert(x == 4.5);
+ fs2 >> x;
+ assert(x == 3.25);
+ }
+}
diff --git a/libcxx/test/std/input.output/file.streams/fstreams/ifstream.assign/move_assign.pass.cpp b/libcxx/test/std/input.output/file.streams/fstreams/ifstream.assign/move_assign.pass.cpp
new file mode 100644
index 00000000000..9c2fcad33a3
--- /dev/null
+++ b/libcxx/test/std/input.output/file.streams/fstreams/ifstream.assign/move_assign.pass.cpp
@@ -0,0 +1,40 @@
+//===----------------------------------------------------------------------===//
+//
+// 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.
+//
+//===----------------------------------------------------------------------===//
+
+// <fstream>
+
+// template <class charT, class traits = char_traits<charT> >
+// class basic_ifstream
+
+// basic_ifstream& operator=(basic_ifstream&& rhs);
+
+#include <fstream>
+#include <cassert>
+
+int main()
+{
+#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
+ {
+ std::ifstream fso("test.dat");
+ std::ifstream fs;
+ fs = move(fso);
+ double x = 0;
+ fs >> x;
+ assert(x == 3.25);
+ }
+ {
+ std::wifstream fso("test.dat");
+ std::wifstream fs;
+ fs = move(fso);
+ double x = 0;
+ fs >> x;
+ assert(x == 3.25);
+ }
+#endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES
+}
diff --git a/libcxx/test/std/input.output/file.streams/fstreams/ifstream.assign/nonmember_swap.pass.cpp b/libcxx/test/std/input.output/file.streams/fstreams/ifstream.assign/nonmember_swap.pass.cpp
new file mode 100644
index 00000000000..5700720a064
--- /dev/null
+++ b/libcxx/test/std/input.output/file.streams/fstreams/ifstream.assign/nonmember_swap.pass.cpp
@@ -0,0 +1,43 @@
+//===----------------------------------------------------------------------===//
+//
+// 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.
+//
+//===----------------------------------------------------------------------===//
+
+// <fstream>
+
+// template <class charT, class traits = char_traits<charT> >
+// class basic_ifstream
+
+// template <class charT, class traits>
+// void swap(basic_ifstream<charT, traits>& x, basic_ifstream<charT, traits>& y);
+
+#include <fstream>
+#include <cassert>
+
+int main()
+{
+ {
+ std::ifstream fs1("test.dat");
+ std::ifstream fs2("test2.dat");
+ swap(fs1, fs2);
+ double x = 0;
+ fs1 >> x;
+ assert(x == 4.5);
+ fs2 >> x;
+ assert(x == 3.25);
+ }
+ {
+ std::wifstream fs1("test.dat");
+ std::wifstream fs2("test2.dat");
+ swap(fs1, fs2);
+ double x = 0;
+ fs1 >> x;
+ assert(x == 4.5);
+ fs2 >> x;
+ assert(x == 3.25);
+ }
+}
diff --git a/libcxx/test/std/input.output/file.streams/fstreams/ifstream.assign/test.dat b/libcxx/test/std/input.output/file.streams/fstreams/ifstream.assign/test.dat
new file mode 100644
index 00000000000..64064d34a8e
--- /dev/null
+++ b/libcxx/test/std/input.output/file.streams/fstreams/ifstream.assign/test.dat
@@ -0,0 +1 @@
+3.25 \ No newline at end of file
diff --git a/libcxx/test/std/input.output/file.streams/fstreams/ifstream.assign/test2.dat b/libcxx/test/std/input.output/file.streams/fstreams/ifstream.assign/test2.dat
new file mode 100644
index 00000000000..958d30d86d0
--- /dev/null
+++ b/libcxx/test/std/input.output/file.streams/fstreams/ifstream.assign/test2.dat
@@ -0,0 +1 @@
+4.5 \ No newline at end of file
OpenPOWER on IntegriCloud