Debian Codegraph @

libstdc++-v3/testsuite/27_io/basic_filebuf/sputn/char/63746.cc

raw
1 // { dg-require-fileio "" }
2
3 #include <fstream>
4 #include <testsuite_hooks.h>
5
6 class testbuf : public std::filebuf {
7 public:
8 char_type* pub_pprt() const
9 {
10 return this->pptr();
11 }
12
13 char_type* pub_pbase() const
14 {
15 return this->pbase();
16 }
17 };
18
19 void test01()
20 {
21 using namespace std;
22
23 // Leave capacity to avoid flush.
24 const streamsize chunk_size = BUFSIZ - 1 - 1;
25 const char data[chunk_size] = {};
26
27 testbuf a_f;
28 VERIFY( a_f.open("tmp_63746_sputn", ios_base::out) );
29 VERIFY( chunk_size == a_f.sputn(data, chunk_size) );
30 VERIFY( (a_f.pub_pprt() - a_f.pub_pbase()) == chunk_size );
31 VERIFY( a_f.close() );
32 }
33
34 int main()
35 {
36 test01();
37 return 0;
38 }