42 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_ofstream13 14// basic_filebuf<charT,traits>* rdbuf() const;15 16#include <fstream>17#include <cassert>18#include "test_macros.h"19#include "platform_support.h"20 21int main(int, char**)22{23 std::string temp = get_temp_file_name();24 {25 std::ofstream fs(temp.c_str());26 std::filebuf* fb = fs.rdbuf();27 assert(fb->sputc('r') == 'r');28 }29 std::remove(temp.c_str());30 31#ifndef TEST_HAS_NO_WIDE_CHARACTERS32 {33 std::wofstream fs(temp.c_str());34 std::wfilebuf* fb = fs.rdbuf();35 assert(fb->sputc(L'r') == L'r');36 }37 std::remove(temp.c_str());38#endif39 40 return 0;41}42