| 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 |
| 10 |
|
| 11 |
// <fstream> |
| 12 |
|
| 13 |
// template <class charT, class traits = char_traits<charT> > |
| 14 |
// class basic_ifstream |
| 15 |
|
| 16 |
// explicit basic_ifstream(const char* s, ios_base::openmode mode = ios_base::in); |
| 17 |
|
| 18 |
#include <fstream> |
| 19 |
#include <cassert> |
| 20 |
|
| 21 |
#include "test_macros.h" |
| 22 |
|
| 23 |
int main(int, char**) |
| 24 |
{ |
| 25 |
{ |
| 26 |
std::ifstream fs("test.dat"); |
| 27 |
double x = 0; |
| 28 |
fs >> x; |
| 29 |
assert(x == 3.25); |
| 30 |
} |
| 31 |
// std::ifstream(const char*, std::ios_base::openmode) is tested in |
| 32 |
// test/std/input.output/file.streams/fstreams/ofstream.cons/pointer.pass.cpp |
| 33 |
// which creates writable files. |
| 34 |
|
| 35 |
#ifndef TEST_HAS_NO_WIDE_CHARACTERS |
| 36 |
{ |
| 37 |
std::wifstream fs("test.dat"); |
| 38 |
double x = 0; |
| 39 |
fs >> x; |
| 40 |
assert(x == 3.25); |
| 41 |
} |
| 42 |
// std::wifstream(const char*, std::ios_base::openmode) is tested in |
| 43 |
// test/std/input.output/file.streams/fstreams/ofstream.cons/pointer.pass.cpp |
| 44 |
// which creates writable files. |
| 45 |
#endif |
| 46 |
|
| 47 |
return 0; |
| 48 |
} |