]> git.ipfire.org Git - thirdparty/gcc.git/blob - libstdc++-v3/testsuite/27_io/basic_ofstream/cons/wchar_t/1.cc
Update copyright years.
[thirdparty/gcc.git] / libstdc++-v3 / testsuite / 27_io / basic_ofstream / cons / wchar_t / 1.cc
1 // Copyright (C) 2018-2024 Free Software Foundation, Inc.
2 //
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)
7 // any later version.
8
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.
13
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/>.
17
18 // { dg-do run { target *-*-mingw* } }
19 // { dg-require-fileio "" }
20
21 #include <fstream>
22 #include <testsuite_hooks.h>
23
24 void test01()
25 {
26 const wchar_t* name = L"ofstream_name.txt";
27 std::ofstream ofs(name);
28 VERIFY( ofs.is_open() );
29 }
30
31 void test02()
32 {
33 const wchar_t name[] = L"ofstream_name.txt";
34 std::wofstream wofs(name, std::wios::out);
35 VERIFY( wofs.is_open() );
36 }
37
38 #if __cplusplus >= 201103L
39 using std::is_constructible;
40 using std::ofstream;
41 using std::wofstream;
42 using std::ios;
43 using std::wios;
44 static_assert(is_constructible<ofstream, const wchar_t*>::value);
45 static_assert(is_constructible<ofstream, wchar_t*>::value);
46 static_assert(is_constructible<ofstream, const wchar_t(&)[1]>::value);
47 static_assert(is_constructible<ofstream, wchar_t(&)[1]>::value);
48 static_assert(is_constructible<ofstream, const wchar_t*, ios::openmode>::value);
49 static_assert(is_constructible<ofstream, wchar_t*, ios::openmode>::value);
50 static_assert(is_constructible<ofstream, const wchar_t(&)[1], ios::openmode>::value);
51 static_assert(is_constructible<ofstream, wchar_t(&)[1], ios::openmode>::value);
52 static_assert(is_constructible<wofstream, const wchar_t*>::value);
53 static_assert(is_constructible<wofstream, wchar_t*>::value);
54 static_assert(is_constructible<wofstream, const wchar_t(&)[1]>::value);
55 static_assert(is_constructible<wofstream, wchar_t(&)[1]>::value);
56 static_assert(is_constructible<wofstream, const wchar_t*, wios::openmode>::value);
57 static_assert(is_constructible<wofstream, wchar_t*, wios::openmode>::value);
58 static_assert(is_constructible<wofstream, const wchar_t(&)[1], wios::openmode>::value);
59 static_assert(is_constructible<wofstream, wchar_t(&)[1], wios::openmode>::value);
60 #endif
61
62 int
63 main()
64 {
65 test01();
66 test02();
67 }