Home | History | Annotate | Download | only in ofstream.cons
      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 // explicit basic_ofstream(const wchar_t* s, ios_base::openmode mode = ios_base::out);
     16 
     17 #include <fstream>
     18 #include <cassert>
     19 #include "platform_support.h"
     20 
     21 int main()
     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