• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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 // <fstream>
9 
10 // template <class charT, class traits = char_traits<charT> >
11 // class basic_fstream
12 
13 // close();
14 
15 //	Inspired by PR#38052 - std::fstream still good after closing and updating content
16 
17 #include <fstream>
18 #include <cassert>
19 #include "test_macros.h"
20 #include "platform_support.h"
21 
main(int,char **)22 int main(int, char**)
23 {
24     std::string temp = get_temp_file_name();
25 
26     std::fstream ofs(temp, std::ios::out | std::ios::trunc);
27     ofs << "Hello, World!\n";
28     assert( ofs.good());
29     ofs.close();
30     assert( ofs.good());
31     ofs << "Hello, World!\n";
32     assert(!ofs.good());
33 
34     std::remove(temp.c_str());
35 
36   return 0;
37 }
38