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_ofstream 14 15 // void open(const wchar_t* s, ios_base::openmode mode = ios_base::out); 16 17 #include <fstream> 18 #include <cassert> 19 #include "platform_support.h" 20 main()21int main() 22 { 23 #ifdef _LIBCPP_HAS_OPEN_WITH_WCHAR 24 std::wstring temp = get_wide_temp_file_name(); 25 { 26 std::ofstream fs; 27 assert(!fs.is_open()); 28 char c = 'a'; 29 fs << c; 30 assert(fs.fail()); 31 fs.open(temp.c_str()); 32 assert(fs.is_open()); 33 fs << c; 34 } 35 { 36 std::ifstream fs(temp.c_str()); 37 char c = 0; 38 fs >> c; 39 assert(c == 'a'); 40 } 41 _wremove(temp.c_str()); 42 { 43 std::wofstream fs; 44 assert(!fs.is_open()); 45 wchar_t c = L'a'; 46 fs << c; 47 assert(fs.fail()); 48 fs.open(temp.c_str()); 49 assert(fs.is_open()); 50 fs << c; 51 } 52 { 53 std::wifstream fs(temp.c_str()); 54 wchar_t c = 0; 55 fs >> c; 56 assert(c == L'a'); 57 } 58 _wremove(temp.c_str()); 59 #endif 60 } 61