]> git.ipfire.org Git - thirdparty/gcc.git/blame - libstdc++-v3/testsuite/27_io/basic_streambuf/sgetc/char/1.cc
Check MAX_FIXED_MODE_SIZE on bit-field in C++.
[thirdparty/gcc.git] / libstdc++-v3 / testsuite / 27_io / basic_streambuf / sgetc / char / 1.cc
CommitLineData
23cac885
BK
1// 1999-10-11 bkoz
2
748086b7 3// Copyright (C) 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2009
1b716e90 4// Free Software Foundation, Inc.
23cac885
BK
5//
6// This file is part of the GNU ISO C++ Library. This library is free
7// software; you can redistribute it and/or modify it under the
8// terms of the GNU General Public License as published by the
748086b7 9// Free Software Foundation; either version 3, or (at your option)
23cac885
BK
10// any later version.
11
12// This library is distributed in the hope that it will be useful,
13// but WITHOUT ANY WARRANTY; without even the implied warranty of
14// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15// GNU General Public License for more details.
16
17// You should have received a copy of the GNU General Public License along
748086b7
JJ
18// with this library; see the file COPYING3. If not see
19// <http://www.gnu.org/licenses/>.
23cac885 20
23cac885
BK
21
22// 27.5.2 template class basic_streambuf
23
24#include <streambuf>
1b716e90 25#include <cstring>
23cac885
BK
26#include <testsuite_hooks.h>
27
28class testbuf : public std::streambuf
29{
30public:
31
32 // Typedefs:
33 typedef std::streambuf::traits_type traits_type;
34 typedef std::streambuf::char_type char_type;
35
36 testbuf(): std::streambuf()
cd16e04b 37 { }
23cac885
BK
38
39 bool
40 check_pointers()
41 {
11f10e6b 42 bool test __attribute__((unused)) = true;
23cac885
BK
43 VERIFY( this->eback() == NULL );
44 VERIFY( this->gptr() == NULL );
45 VERIFY( this->egptr() == NULL );
46 VERIFY( this->pbase() == NULL );
47 VERIFY( this->pptr() == NULL );
48 VERIFY( this->epptr() == NULL );
49 return test;
50 }
51
52 int_type
53 pub_uflow()
54 { return (this->uflow()); }
55
56 int_type
57 pub_overflow(int_type __c = traits_type::eof())
58 { return (this->overflow(__c)); }
59
60 int_type
61 pub_pbackfail(int_type __c)
62 { return (this->pbackfail(__c)); }
63
64 void
65 pub_setg(char* beg, char* cur, char *end)
66 { this->setg(beg, cur, end); }
67
68 void
69 pub_setp(char* beg, char* end)
70 { this->setp(beg, end); }
71
72protected:
73 int_type
74 underflow()
75 {
76 int_type __retval = traits_type::eof();
77 if (this->gptr() < this->egptr())
78 __retval = traits_type::not_eof(0);
79 return __retval;
80 }
81};
82
83void test01()
84{
85 typedef testbuf::traits_type traits_type;
86 typedef testbuf::int_type int_type;
87
11f10e6b
BK
88 bool test __attribute__((unused)) = true;
89 char lit01[52];
1b716e90 90 std::strcpy(lit01, "chicago underground trio/possible cube on delmark");
23cac885
BK
91 testbuf buf01;
92
93 // 27.5.2.3.1 get area
94 // 27.5.2.2.3 get area
95 // 27.5.2.4.3 get area
96 int i01 = 3;
97 buf01.pub_setg(lit01, lit01, (lit01 + i01));
98 VERIFY( i01 == buf01.in_avail() );
99
7919bb2f 100 VERIFY( buf01.pub_uflow() == traits_type::to_int_type(lit01[0]) );
23cac885 101 VERIFY( buf01.sgetc() == traits_type::to_int_type(lit01[1]) );
7919bb2f 102 VERIFY( buf01.pub_uflow() == traits_type::to_int_type(lit01[1]) );
23cac885 103 VERIFY( buf01.sgetc() == traits_type::to_int_type(lit01[2]) );
7919bb2f 104 VERIFY( buf01.pub_uflow() == traits_type::to_int_type(lit01[2]) );
23cac885
BK
105 VERIFY( buf01.sgetc() == traits_type::eof() );
106}
107
108int main()
109{
110 test01();
111 return 0;
112}