]>
git.ipfire.org Git - thirdparty/gcc.git/blob - libstdc++-v3/testsuite/27_io/basic_filebuf/open/wchar_t/1.cc
1 // Copyright (C) 2018-2019 Free Software Foundation, Inc.
3 // This file is part of the GNU ISO C++ Library. This library is free
4 // software; you can redistribute it and/or modify it under the
5 // terms of the GNU General Public License as published by the
6 // Free Software Foundation; either version 3, or (at your option)
9 // This library is distributed in the hope that it will be useful,
10 // but WITHOUT ANY WARRANTY; without even the implied warranty of
11 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 // GNU General Public License for more details.
14 // You should have received a copy of the GNU General Public License along
15 // with this library; see the file COPYING3. If not see
16 // <http://www.gnu.org/licenses/>.
18 // { dg-do run { target *-*-mingw* } }
19 // { dg-require-fileio "" }
22 #include <testsuite_hooks.h>
24 const wchar_t name_01
[] = L
"filebuf_members-1.tst";
25 const wchar_t name_02
[] = L
"filebuf_members-1.txt";
27 // Test member functions.
30 const wchar_t* name_03
= L
"filebuf_members-w3"; // empty file, need to create
32 std::filebuf fb_01
; // in
33 std::filebuf fb_02
; // out
34 std::filebuf fb_03
; // in | out
37 VERIFY( !fb_01
.is_open() );
38 VERIFY( !fb_02
.is_open() );
39 VERIFY( !fb_03
.is_open() );
41 // filebuf_type* open(const wchar_t* __s, ios_base::openmode __mode)
42 fb_01
.open(name_01
, std::ios_base::in
| std::ios_base::ate
);
43 VERIFY( fb_01
.is_open() );
45 // Try to open two different files without closing the first:
46 // Should keep the old file attached, and disregard attempt to overthrow.
47 std::filebuf
* f
= fb_02
.open(name_02
, std::ios_base::in
| std::ios_base::out
48 | std::ios_base::trunc
);
50 VERIFY( fb_02
.is_open() );
52 f
= fb_02
.open(name_03
, std::ios_base::in
| std::ios_base::out
);
54 VERIFY( fb_02
.is_open() );
56 fb_03
.open(name_03
, std::ios_base::out
| std::ios_base::trunc
);
57 VERIFY( fb_03
.is_open() );
63 fb
.open(name_01
, std::wios::in
);
64 VERIFY( fb
.is_open() );