| 1 |
// Copyright (C) 2018-2025 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 |
// C++17 30.9.3.1 basic_ifstream constructors [ifstream.cons] |
| 19 |
|
| 20 |
// { dg-do run { target *-*-mingw* } } |
| 21 |
// { dg-require-fileio "" } |
| 22 |
// { dg-additional-files "ifstream_members-1.tst" } |
| 23 |
|
| 24 |
#include <fstream> |
| 25 |
#include <testsuite_hooks.h> |
| 26 |
|
| 27 |
const wchar_t name_01[] = L"ifstream_members-1.tst"; |
| 28 |
|
| 29 |
void test01() |
| 30 |
{ |
| 31 |
std::ifstream ifs1; |
| 32 |
ifs1.close(); |
| 33 |
|
| 34 |
VERIFY( !ifs1.is_open() ); |
| 35 |
VERIFY( !(ifs1) ); |
| 36 |
|
| 37 |
ifs1.open(name_01); |
| 38 |
VERIFY( ifs1.is_open() ); |
| 39 |
|
| 40 |
VERIFY( (ifs1) ); |
| 41 |
VERIFY( ifs1.rdstate() == std::ios_base::goodbit ); |
| 42 |
|
| 43 |
ifs1.close(); |
| 44 |
} |
| 45 |
|
| 46 |
void test02() |
| 47 |
{ |
| 48 |
std::wifstream wifs1; |
| 49 |
wifs1.open(name_01, std::wios::in); |
| 50 |
VERIFY( wifs1.is_open() ); |
| 51 |
|
| 52 |
VERIFY( (wifs1) ); |
| 53 |
VERIFY( wifs1.rdstate() == std::ios_base::goodbit ); |
| 54 |
} |
| 55 |
|
| 56 |
int main() |
| 57 |
{ |
| 58 |
test01(); |
| 59 |
test02(); |
| 60 |
} |