aboutsummaryrefslogtreecommitdiff
path: root/test/std/input.output/file.streams/fstreams/ifstream.cons/path.pass.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'test/std/input.output/file.streams/fstreams/ifstream.cons/path.pass.cpp')
-rw-r--r--test/std/input.output/file.streams/fstreams/ifstream.cons/path.pass.cpp53
1 files changed, 53 insertions, 0 deletions
diff --git a/test/std/input.output/file.streams/fstreams/ifstream.cons/path.pass.cpp b/test/std/input.output/file.streams/fstreams/ifstream.cons/path.pass.cpp
new file mode 100644
index 000000000000..99eae3a28a72
--- /dev/null
+++ b/test/std/input.output/file.streams/fstreams/ifstream.cons/path.pass.cpp
@@ -0,0 +1,53 @@
+//===----------------------------------------------------------------------===//
+//
+// 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.
+//
+//===----------------------------------------------------------------------===//
+
+// UNSUPPORTED: c++98, c++03, c++11, c++14
+
+// <fstream>
+
+// template <class charT, class traits = char_traits<charT> >
+// class basic_ifstream
+
+// explicit basic_ifstream(const filesystem::path& s,
+// ios_base::openmode mode = ios_base::in);
+
+#include <fstream>
+#include <filesystem>
+#include <cassert>
+
+namespace fs = std::filesystem;
+
+int main() {
+ {
+ fs::path p;
+ static_assert(!std::is_convertible<fs::path, std::ifstream>::value,
+ "ctor should be explicit");
+ static_assert(std::is_constructible<std::ifstream, fs::path const&,
+ std::ios_base::openmode>::value,
+ "");
+ }
+ {
+ std::ifstream fs(fs::path("test.dat"));
+ double x = 0;
+ fs >> x;
+ assert(x == 3.25);
+ }
+ // std::ifstream(const fs::path&, std::ios_base::openmode) is tested in
+ // test/std/input.output/file.streams/fstreams/ofstream.cons/string.pass.cpp
+ // which creates writable files.
+ {
+ std::wifstream fs(fs::path("test.dat"));
+ double x = 0;
+ fs >> x;
+ assert(x == 3.25);
+ }
+ // std::wifstream(const fs::path&, std::ios_base::openmode) is tested in
+ // test/std/input.output/file.streams/fstreams/ofstream.cons/string.pass.cpp
+ // which creates writable files.
+}