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 //===----------------------------------------------------------------------===//
11 // template <class charT, class traits = char_traits<charT> >
12 // class basic_fstream
14 // template <class charT, class traits>
15 // void swap(basic_fstream<charT, traits>& x, basic_fstream<charT, traits>& y);
20 #include "test_macros.h"
21 #include "platform_support.h"
24 std::pair
<std::string
, std::string
> get_temp_file_names() {
25 std::pair
<std::string
, std::string
> names
;
26 names
.first
= get_temp_file_name();
28 // Create the file so the next call to `get_temp_file_name()` doesn't
29 // return the same file.
30 std::FILE *fd1
= std::fopen(names
.first
.c_str(), "w");
32 names
.second
= get_temp_file_name();
33 assert(names
.first
!= names
.second
);
36 std::remove(names
.first
.c_str());
43 std::pair
<std::string
, std::string
> temp_files
= get_temp_file_names();
44 std::string
& temp1
= temp_files
.first
;
45 std::string
& temp2
= temp_files
.second
;
46 assert(temp1
!= temp2
);
48 std::fstream
fs1(temp1
.c_str(), std::ios_base::in
| std::ios_base::out
49 | std::ios_base::trunc
);
50 std::fstream
fs2(temp2
.c_str(), std::ios_base::in
| std::ios_base::out
51 | std::ios_base::trunc
);
68 std::remove(temp1
.c_str());
69 std::remove(temp2
.c_str());
71 #ifndef TEST_HAS_NO_WIDE_CHARACTERS
73 std::wfstream
fs1(temp1
.c_str(), std::ios_base::in
| std::ios_base::out
74 | std::ios_base::trunc
);
75 std::wfstream
fs2(temp2
.c_str(), std::ios_base::in
| std::ios_base::out
76 | std::ios_base::trunc
);
93 std::remove(temp1
.c_str());
94 std::remove(temp2
.c_str());