1 //===----------------------------------------------------------------------===//
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
7 //===----------------------------------------------------------------------===//
9 // This tests that swapping filebufs works correctly even when the small buffer
10 // optimization is in use (https://github.com/llvm/llvm-project/issues/49282).
14 // template <class charT, class traits = char_traits<charT> >
15 // class basic_filebuf
17 // template <class charT, class traits>
19 // swap(basic_filebuf<charT, traits>& x, basic_filebuf<charT, traits>& y);
23 #include "test_macros.h"
24 #include "platform_support.h"
28 std::string tmpA
= get_temp_file_name();
29 std::string tmpB
= get_temp_file_name();
32 std::ofstream
sa(tmpA
), sb(tmpB
);
38 assert(f1
.open(tmpA
, std::ios_base::in
) != 0);
43 assert(f2
.open(tmpB
, std::ios_base::in
) != 0);
47 assert(f1
.sgetc() == 'A');
48 assert(f2
.sgetc() == 'B');
55 assert(f1
.sgetc() == 'B');
56 assert(f2
.sgetc() == 'A');
58 std::remove(tmpA
.c_str());
59 std::remove(tmpB
.c_str());