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 // FILE_DEPENDENCIES: test.dat, test2.dat
10 
11 // <fstream>
12 
13 // template <class charT, class traits = char_traits<charT> >
14 // class basic_ifstream
15 
16 // template <class charT, class traits>
17 //   void swap(basic_ifstream<charT, traits>& x, basic_ifstream<charT, traits>& y);
18 
19 #include <fstream>
20 #include <cassert>
21 
22 #include "test_macros.h"
23 
main(int,char **)24 int main(int, char**)
25 {
26     {
27         std::ifstream fs1("test.dat");
28         std::ifstream fs2("test2.dat");
29         swap(fs1, fs2);
30         double x = 0;
31         fs1 >> x;
32         assert(x == 4.5);
33         fs2 >> x;
34         assert(x == 3.25);
35     }
36 #ifndef TEST_HAS_NO_WIDE_CHARACTERS
37     {
38         std::wifstream fs1("test.dat");
39         std::wifstream fs2("test2.dat");
40         swap(fs1, fs2);
41         double x = 0;
42         fs1 >> x;
43         assert(x == 4.5);
44         fs2 >> x;
45         assert(x == 3.25);
46     }
47 #endif
48 
49   return 0;
50 }
51