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++98, 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 "platform_support.h"
21 
22 int main(int, char**)
23 {
24     std::string temp = get_temp_file_name();
25     {
26         std::filebuf f;
27         assert(f.open(temp.c_str(), std::ios_base::out | std::ios_base::in
28                                                | std::ios_base::trunc) != 0);
29         assert(f.is_open());
30         assert(f.sputn("123", 3) == 3);
31         f.pubseekoff(1, std::ios_base::beg);
32         assert(f.sgetc() == '2');
33         std::filebuf f2(move(f));
34         assert(!f.is_open());
35         assert(f2.is_open());
36         assert(f2.sgetc() == '2');
37     }
38     std::remove(temp.c_str());
39     {
40         std::wfilebuf f;
41         assert(f.open(temp.c_str(), std::ios_base::out | std::ios_base::in
42                                                | std::ios_base::trunc) != 0);
43         assert(f.is_open());
44         assert(f.sputn(L"123", 3) == 3);
45         f.pubseekoff(1, std::ios_base::beg);
46         assert(f.sgetc() == L'2');
47         std::wfilebuf f2(move(f));
48         assert(!f.is_open());
49         assert(f2.is_open());
50         assert(f2.sgetc() == L'2');
51     }
52     std::remove(temp.c_str());
53 
54   return 0;
55 }
56