brintos

brintos / llvm-project-archived public Read only

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