OpenCores
URL https://opencores.org/ocsvn/openrisc_2011-10-31/openrisc_2011-10-31/trunk

Subversion Repositories openrisc_2011-10-31

[/] [openrisc/] [trunk/] [gnu-src/] [gcc-4.5.1/] [libstdc++-v3/] [testsuite/] [27_io/] [basic_filebuf/] [seekoff/] [wchar_t/] [11543.cc] - Blame information for rev 565

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 424 jeremybenn
// Copyright (C) 2003, 2009
2
// Free Software Foundation, Inc.
3
//
4
// This file is part of the GNU ISO C++ Library.  This library is free
5
// software; you can redistribute it and/or modify it under the
6
// terms of the GNU General Public License as published by the
7
// Free Software Foundation; either version 3, or (at your option)
8
// any later version.
9
 
10
// This library is distributed in the hope that it will be useful,
11
// but WITHOUT ANY WARRANTY; without even the implied warranty of
12
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
13
// GNU General Public License for more details.
14
 
15
// You should have received a copy of the GNU General Public License along
16
// with this library; see the file COPYING3.  If not see
17
// <http://www.gnu.org/licenses/>.
18
 
19
// 27.8.1.4 Overridden virtual functions
20
 
21 565 jeremybenn
// { dg-xfail-run-if "not supported on OR32 newlib" { or32-*-elf } }
22
 
23 424 jeremybenn
#include <fstream>
24
#include <locale>
25
#include <testsuite_hooks.h>
26
 
27
struct MyState
28
{
29
};
30
 
31
struct MyCharTraits : std::char_traits<wchar_t>
32
{
33
  typedef std::fpos<MyState> pos_type;
34
  typedef MyState state_type;
35
};
36
 
37
namespace std
38
{
39
  template <>
40
    class codecvt<wchar_t, char, MyState> :
41
      public locale::facet, public codecvt_base
42
    {
43
    public:
44
      typedef wchar_t intern_type;
45
      typedef char extern_type;
46
      typedef MyState state_type;
47
 
48
      explicit codecvt(size_t refs = 0)
49
      : locale::facet(refs) { }
50
 
51
      result out(state_type& state, const intern_type* from,
52
                 const intern_type* from_end,  const intern_type*& from_next,
53
                 extern_type* to, extern_type* to_limit,
54
                 extern_type*& to_next) const
55
      { return do_out(state, from, from_end, from_next,
56
                      to, to_limit, to_next); }
57
 
58
      result unshift(state_type& state, extern_type* to, extern_type* to_limit,
59
                     extern_type*& to_next) const
60
      { return do_unshift(state, to, to_limit, to_next); }
61
 
62
      result in(state_type& state, const extern_type* from,
63
                const extern_type* from_end, const extern_type*& from_next,
64
                intern_type* to, intern_type* to_limit,
65
                intern_type*& to_next) const
66
      { return do_in(state, from, from_end, from_next,
67
                     to, to_limit, to_next); }
68
 
69
      int encoding() const throw()
70
      { return do_encoding(); }
71
 
72
      bool always_noconv() const throw()
73
      { return do_always_noconv(); }
74
 
75
      int length(state_type& state, const extern_type* from,
76
                 const extern_type* end, size_t max) const
77
      { return do_length(state, from, end, max); }
78
 
79
      int max_length() const throw()
80
      { return do_max_length(); }
81
 
82
      static locale::id id;
83
 
84
    protected:
85
      virtual ~codecvt();
86
 
87
      virtual result do_out(state_type&, const intern_type*,
88
                            const intern_type*, const intern_type*&,
89
                            extern_type*, extern_type*, extern_type*&) const
90
      { return error; }
91
 
92
      virtual result do_in(state_type&, const extern_type*, const extern_type*,
93
                           const extern_type*&, intern_type*, intern_type*,
94
                           intern_type*&) const
95
      { return error; }
96
 
97
      virtual result do_unshift(state_type&, extern_type*, extern_type*,
98
                                extern_type*&) const
99
      { return noconv; }
100
 
101
      virtual int do_encoding() const throw()
102
      { return 1; }
103
 
104
      virtual bool do_always_noconv() const throw()
105
      { return false; }
106
 
107
      virtual int do_length(state_type&, const extern_type* from,
108
                            const extern_type* end, size_t max) const
109
      {
110
        size_t len = end - from;
111
        return std::min(max, len);
112
      }
113
 
114
      virtual int do_max_length() const throw()
115
      { return 1; }
116
    };
117
 
118
  locale::id codecvt<wchar_t, char, MyState>::id;
119
 
120
  codecvt<wchar_t, char, MyState>::~codecvt()
121
  { }
122
}
123
 
124
void test01()
125
{
126
  bool test __attribute__((unused)) = true;
127
 
128
  std::locale loc(std::locale::classic(),
129
                  new std::codecvt<wchar_t, char, MyState>);
130
  std::basic_filebuf<wchar_t, MyCharTraits> fb;
131
  fb.pubimbue(loc);
132
  fb.open("tmp_11543", std::ios_base::out);
133
  VERIFY( fb.is_open() );
134
  MyCharTraits::pos_type pos = fb.pubseekoff(0, std::ios_base::beg);
135
  VERIFY( pos != MyCharTraits::pos_type(MyCharTraits::off_type(-1)) );
136
  fb.close();
137
}
138
 
139
int main()
140
{
141
  test01();
142
  return 0;
143
}

powered by: WebSVN 2.1.0

© copyright 1999-2024 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.