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