xref: /llvm-project/libcxx/test/std/input.output/file.streams/fstreams/ifstream.members/rdbuf.pass.cpp (revision f4c1258d5633fcf06385ff3fd1f4bf57ab971964)
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 // basic_filebuf<charT,traits>* rdbuf() const;
17 
18 #include <fstream>
19 #include <cassert>
20 
21 #include "test_macros.h"
22 
main(int,char **)23 int main(int, char**)
24 {
25     {
26         std::ifstream fs("test.dat");
27         std::filebuf* fb = fs.rdbuf();
28         assert(fb->sgetc() == 'r');
29     }
30 #ifndef TEST_HAS_NO_WIDE_CHARACTERS
31     {
32         std::wifstream fs("test.dat");
33         std::wfilebuf* fb = fs.rdbuf();
34         assert(fb->sgetc() == L'r');
35     }
36 #endif
37 
38   return 0;
39 }
40