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 char* s, ios_base::openmode mode = ios_base::out);
15 
16 #include <fstream>
17 #include <cassert>
18 #include "platform_support.h"
19 
20 int main(int, char**)
21 {
22     std::string temp = get_temp_file_name();
23     {
24         std::ofstream fs(temp.c_str());
25         fs << 3.25;
26     }
27     {
28         std::ifstream fs(temp.c_str());
29         double x = 0;
30         fs >> x;
31         assert(x == 3.25);
32     }
33     {
34         std::ifstream fs(temp.c_str(), std::ios_base::out);
35         double x = 0;
36         fs >> x;
37         assert(x == 3.25);
38     }
39     std::remove(temp.c_str());
40     {
41         std::wofstream fs(temp.c_str());
42         fs << 3.25;
43     }
44     {
45         std::wifstream fs(temp.c_str());
46         double x = 0;
47         fs >> x;
48         assert(x == 3.25);
49     }
50     {
51         std::wifstream fs(temp.c_str(), std::ios_base::out);
52         double x = 0;
53         fs >> x;
54         assert(x == 3.25);
55     }
56     std::remove(temp.c_str());
57 
58   return 0;
59 }
60