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 // UNSUPPORTED: c++03 10 11 // <fstream> 12 13 // template <class charT, class traits = char_traits<charT> > 14 // class basic_filebuf 15 16 // basic_filebuf(basic_filebuf&& rhs); 17 18 #include <fstream> 19 #include <cassert> 20 #include "test_macros.h" 21 #include "platform_support.h" 22 23 int main(int, char**) 24 { 25 std::string temp = get_temp_file_name(); 26 { 27 std::filebuf f; 28 assert(f.open(temp.c_str(), std::ios_base::out | std::ios_base::in 29 | std::ios_base::trunc) != 0); 30 assert(f.is_open()); 31 assert(f.sputn("123", 3) == 3); 32 f.pubseekoff(1, std::ios_base::beg); 33 assert(f.sgetc() == '2'); 34 std::filebuf f2(move(f)); 35 assert(!f.is_open()); 36 assert(f2.is_open()); 37 assert(f2.sgetc() == '2'); 38 } 39 std::remove(temp.c_str()); 40 { 41 std::wfilebuf f; 42 assert(f.open(temp.c_str(), std::ios_base::out | std::ios_base::in 43 | std::ios_base::trunc) != 0); 44 assert(f.is_open()); 45 assert(f.sputn(L"123", 3) == 3); 46 f.pubseekoff(1, std::ios_base::beg); 47 assert(f.sgetc() == L'2'); 48 std::wfilebuf f2(move(f)); 49 assert(!f.is_open()); 50 assert(f2.is_open()); 51 assert(f2.sgetc() == L'2'); 52 } 53 std::remove(temp.c_str()); 54 55 return 0; 56 } 57