• 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 // <fstream>
11 
12 // template <class charT, class traits = char_traits<charT> >
13 // class basic_ifstream
14 
15 // void open(const char* s, ios_base::openmode mode = ios_base::in);
16 
17 #include <fstream>
18 #include <cassert>
19 
main()20 int main()
21 {
22     {
23         std::ifstream fs;
24         assert(!fs.is_open());
25         char c = 'a';
26         fs >> c;
27         assert(fs.fail());
28         assert(c == 'a');
29         fs.open("test.dat");
30         assert(fs.is_open());
31         fs >> c;
32         assert(c == 'r');
33     }
34     {
35         std::wifstream fs;
36         assert(!fs.is_open());
37         wchar_t c = L'a';
38         fs >> c;
39         assert(fs.fail());
40         assert(c == L'a');
41         fs.open("test.dat");
42         assert(fs.is_open());
43         fs >> c;
44         assert(c == L'r');
45     }
46 }
47