• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 //===----------------------------------------------------------------------===//
2 //
3 //                     The LLVM Compiler Infrastructure
4 //
5 // This file is dual licensed under the MIT and the University of Illinois Open
6 // Source Licenses. See LICENSE.TXT for details.
7 //
8 //===----------------------------------------------------------------------===//
9 
10 // UNSUPPORTED: c++98, c++03, c++11, c++14
11 
12 // <fstream>
13 
14 // template <class charT, class traits = char_traits<charT> >
15 // class basic_ifstream
16 
17 // void open(const filesystem::path& s, ios_base::openmode mode = ios_base::in);
18 
19 #include <fstream>
20 #include <filesystem>
21 #include <cassert>
22 
main()23 int main() {
24   {
25     std::ifstream fs;
26     assert(!fs.is_open());
27     char c = 'a';
28     fs >> c;
29     assert(fs.fail());
30     assert(c == 'a');
31     fs.open(std::filesystem::path("test.dat"));
32     assert(fs.is_open());
33     fs >> c;
34     assert(c == 'r');
35   }
36   {
37     std::wifstream fs;
38     assert(!fs.is_open());
39     wchar_t c = L'a';
40     fs >> c;
41     assert(fs.fail());
42     assert(c == L'a');
43     fs.open(std::filesystem::path("test.dat"));
44     assert(fs.is_open());
45     fs >> c;
46     assert(c == L'r');
47   }
48 }
49