brintos

brintos / llvm-project-archived public Read only

0
0
Text · 1.5 KiB · 7f162b0 Raw
58 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// UNSUPPORTED: c++03, c++11, c++1410 11// <fstream>12 13// plate <class charT, class traits = char_traits<charT> >14// class basic_fstream15 16// void open(const filesystem::path& s, ios_base::openmode mode = ios_base::in|ios_base::out);17 18#include <fstream>19#include <filesystem>20#include <cassert>21#include "test_macros.h"22#include "platform_support.h"23 24int main(int, char**) {25  std::filesystem::path p = get_temp_file_name();26  {27    std::fstream stream;28    assert(!stream.is_open());29    stream.open(p,30                std::ios_base::in | std::ios_base::out | std::ios_base::trunc);31    assert(stream.is_open());32    double x = 0;33    stream << 3.25;34    stream.seekg(0);35    stream >> x;36    assert(x == 3.25);37  }38  std::remove(p.string().c_str());39 40#ifndef TEST_HAS_NO_WIDE_CHARACTERS41  {42    std::wfstream stream;43    assert(!stream.is_open());44    stream.open(p,45                std::ios_base::in | std::ios_base::out | std::ios_base::trunc);46    assert(stream.is_open());47    double x = 0;48    stream << 3.25;49    stream.seekg(0);50    stream >> x;51    assert(x == 3.25);52  }53  std::remove(p.string().c_str());54#endif55 56  return 0;57}58