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