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_fstream 13 14 // void open(const wchar_t* s, ios_base::openmode mode = ios_base::in|ios_base::out); 15 16 // This extension is only provided on Windows. 17 // REQUIRES: windows 18 // UNSUPPORTED: no-wide-characters 19 20 // TODO: This should not be necessary 21 // ADDITIONAL_COMPILE_FLAGS:-D_LIBCPP_ENABLE_CXX26_REMOVED_CODECVT 22 23 #include <fstream> 24 #include <cassert> 25 #include "test_macros.h" 26 #include "wide_temp_file.h" 27 main(int,char **)28int main(int, char**) { 29 std::wstring temp = get_wide_temp_file_name(); 30 { 31 std::fstream fs; 32 assert(!fs.is_open()); 33 fs.open(temp.c_str(), std::ios_base::in | std::ios_base::out 34 | std::ios_base::trunc); 35 assert(fs.is_open()); 36 double x = 0; 37 fs << 3.25; 38 fs.seekg(0); 39 fs >> x; 40 assert(x == 3.25); 41 } 42 _wremove(temp.c_str()); 43 { 44 std::wfstream fs; 45 assert(!fs.is_open()); 46 fs.open(temp.c_str(), std::ios_base::in | std::ios_base::out 47 | std::ios_base::trunc); 48 assert(fs.is_open()); 49 double x = 0; 50 fs << 3.25; 51 fs.seekg(0); 52 fs >> x; 53 assert(x == 3.25); 54 } 55 _wremove(temp.c_str()); 56 57 return 0; 58 } 59