]>
git.ipfire.org Git - thirdparty/gcc.git/blob - libstdc++-v3/testsuite/27_io/basic_filebuf/seekoff/char/11543.cc
1 // Copyright (C) 2003-2013 Free Software Foundation, Inc.
3 // This file is part of the GNU ISO C++ Library. This library is free
4 // software; you can redistribute it and/or modify it under the
5 // terms of the GNU General Public License as published by the
6 // Free Software Foundation; either version 3, or (at your option)
9 // This library is distributed in the hope that it will be useful,
10 // but WITHOUT ANY WARRANTY; without even the implied warranty of
11 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 // GNU General Public License for more details.
14 // You should have received a copy of the GNU General Public License along
15 // with this library; see the file COPYING3. If not see
16 // <http://www.gnu.org/licenses/>.
18 // 27.8.1.4 Overridden virtual functions
20 // { dg-require-fileio "" }
24 #include <testsuite_hooks.h>
30 struct MyCharTraits
: std::char_traits
<char>
32 typedef std::fpos
<MyState
> pos_type
;
33 typedef MyState state_type
;
39 class codecvt
<char, char, MyState
> :
40 public locale::facet
, public codecvt_base
43 typedef char intern_type
;
44 typedef char extern_type
;
45 typedef MyState state_type
;
47 explicit codecvt(size_t refs
= 0)
48 : locale::facet(refs
) { }
50 result
out(state_type
& state
, const intern_type
* from
,
51 const intern_type
* from_end
, const intern_type
*& from_next
,
52 extern_type
* to
, extern_type
* to_limit
,
53 extern_type
*& to_next
) const
54 { return do_out(state
, from
, from_end
, from_next
,
55 to
, to_limit
, to_next
); }
57 result
unshift(state_type
& state
, extern_type
* to
, extern_type
* to_limit
,
58 extern_type
*& to_next
) const
59 { return do_unshift(state
, to
, to_limit
, to_next
); }
61 result
in(state_type
& state
, const extern_type
* from
,
62 const extern_type
* from_end
, const extern_type
*& from_next
,
63 intern_type
* to
, intern_type
* to_limit
,
64 intern_type
*& to_next
) const
65 { return do_in(state
, from
, from_end
, from_next
,
66 to
, to_limit
, to_next
); }
68 int encoding() const throw()
69 { return do_encoding(); }
71 bool always_noconv() const throw()
72 { return do_always_noconv(); }
74 int length(state_type
& state
, const extern_type
* from
,
75 const extern_type
* end
, size_t max
) const
76 { return do_length(state
, from
, end
, max
); }
78 int max_length() const throw()
79 { return do_max_length(); }
86 virtual result
do_out(state_type
&, const intern_type
* from
,
87 const intern_type
*, const intern_type
*& from_next
,
88 extern_type
* to
, extern_type
*,
89 extern_type
*& to_next
) const
96 virtual result
do_in(state_type
&, const extern_type
* from
,
97 const extern_type
*, const extern_type
*& from_next
,
98 intern_type
* to
, intern_type
*,
99 intern_type
*& to_next
) const
106 virtual result
do_unshift(state_type
&, extern_type
*, extern_type
*,
110 virtual int do_encoding() const throw()
113 virtual bool do_always_noconv() const throw()
116 virtual int do_length(state_type
&, const extern_type
* from
,
117 const extern_type
* end
, size_t max
) const
119 size_t len
= end
- from
;
120 return std::min(max
, len
);
123 virtual int do_max_length() const throw()
127 locale::id codecvt
<char, char, MyState
>::id
;
129 codecvt
<char, char, MyState
>::~codecvt()
135 bool test
__attribute__((unused
)) = true;
137 std::locale
loc(std::locale::classic(),
138 new std::codecvt
<char, char, MyState
>);
139 std::basic_filebuf
<char, MyCharTraits
> fb
;
141 fb
.open("tmp_11543", std::ios_base::out
);
142 VERIFY( fb
.is_open() );
143 MyCharTraits::pos_type pos
= fb
.pubseekoff(0, std::ios_base::beg
);
144 VERIFY( pos
!= MyCharTraits::pos_type(MyCharTraits::off_type(-1)) );