]> gcc.gnu.org Git - gcc.git/blame - libstdc++-v3/testsuite/27_io/basic_streambuf/sgetn/wchar_t/1.cc
Update copyright years.
[gcc.git] / libstdc++-v3 / testsuite / 27_io / basic_streambuf / sgetn / wchar_t / 1.cc
CommitLineData
6f422965
PC
1// 1999-10-11 bkoz
2
818ab71a 3// Copyright (C) 1999-2016 Free Software Foundation, Inc.
6f422965
PC
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)
6f422965
PC
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/>.
6f422965 19
6f422965
PC
20
21// 27.5.2 template class basic_streambuf
22
23#include <streambuf>
24#include <cwchar>
25#include <testsuite_hooks.h>
26
27class testbuf : public std::wstreambuf
28{
29public:
30
31 // Typedefs:
32 typedef std::wstreambuf::traits_type traits_type;
33 typedef std::wstreambuf::char_type char_type;
34
35 testbuf(): std::wstreambuf()
36 { }
37
38 bool
39 check_pointers()
40 {
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() );
6f422965
PC
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(wchar_t* beg, wchar_t* cur, wchar_t* end)
65 { this->setg(beg, cur, end); }
66
67 void
68 pub_setp(wchar_t* beg, wchar_t* end)
69 { this->setp(beg, end); }
70
71protected:
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
82void test02()
83{
84 typedef testbuf::traits_type traits_type;
85 typedef testbuf::int_type int_type;
86
87 bool test __attribute__((unused)) = true;
88
894b1dff
MF
89 wchar_t lit01[] = L"chicago underground trio/possible cube on delmark";
90 size_t i01 = traits_type::length(lit01);
6f422965
PC
91
92 testbuf buf01;
93
94 // 27.5.2.1 basic_streambuf ctors
95 // default ctor initializes
96 // - all pointer members to null pointers
97 // - locale to current global locale
98 VERIFY( buf01.check_pointers() );
99 VERIFY( buf01.getloc() == std::locale() );
100
101 // 27.5.2.2.5 Put area
102
103 wchar_t carray01[i01];
104 std::wmemset(carray01, 0, i01);
105
106 buf01.pub_setg(lit01, lit01, lit01 + i01);
107 buf01.sgetn(carray01, 0);
108 VERIFY( carray01[0] == 0 );
109 buf01.sgetn(carray01, 1);
110 VERIFY( carray01[0] == L'c' );
111 buf01.sgetn(carray01 + 1, i01 - 1);
112 VERIFY( carray01[0] == L'c' );
113 VERIFY( carray01[1] == L'h' );
114 VERIFY( carray01[i01 - 1] == L'k' );
115}
116
117int main()
118{
119 test02();
120 return 0;
121}
This page took 0.988345 seconds and 5 git commands to generate.