1 //===----------------------------------------------------------------------===// 2 // 3 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. 4 // See https://llvm.org/LICENSE.txt for license information. 5 // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception 6 // 7 //===----------------------------------------------------------------------===// 8 9 // <fstream> 10 11 // template <class charT, class traits = char_traits<charT> > 12 // class basic_ofstream 13 14 // explicit basic_ofstream(const wchar_t* s, ios_base::openmode mode = ios_base::out); 15 16 #include <fstream> 17 #include <cassert> 18 #include "test_macros.h" 19 #include "platform_support.h" 20 main(int,char **)21int main(int, char**) 22 { 23 #ifdef _LIBCPP_HAS_OPEN_WITH_WCHAR 24 std::wstring temp = get_wide_temp_file_name(); 25 { 26 std::ofstream fs(temp.c_str()); 27 fs << 3.25; 28 } 29 { 30 std::ifstream fs(temp.c_str()); 31 double x = 0; 32 fs >> x; 33 assert(x == 3.25); 34 } 35 { 36 std::ifstream fs(temp.c_str(), std::ios_base::out); 37 double x = 0; 38 fs >> x; 39 assert(x == 3.25); 40 } 41 _wremove(temp.c_str()); 42 { 43 std::wofstream fs(temp.c_str()); 44 fs << 3.25; 45 } 46 { 47 std::wifstream fs(temp.c_str()); 48 double x = 0; 49 fs >> x; 50 assert(x == 3.25); 51 } 52 { 53 std::wifstream fs(temp.c_str(), std::ios_base::out); 54 double x = 0; 55 fs >> x; 56 assert(x == 3.25); 57 } 58 _wremove(temp.c_str()); 59 #endif 60 61 return 0; 62 } 63