OpenCores
URL https://opencores.org/ocsvn/openrisc/openrisc/trunk

Subversion Repositories openrisc

[/] [openrisc/] [trunk/] [gnu-stable/] [gcc-4.5.1/] [libstdc++-v3/] [testsuite/] [27_io/] [basic_ostream/] [inserters_other/] [char/] [9424-out.cc] - Blame information for rev 826

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 424 jeremybenn
// 1999-10-11 bkoz
2
 
3
// Copyright (C) 1999, 2000, 2001, 2002, 2003, 2009
4
// Free Software Foundation, Inc.
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
9
// Free Software Foundation; either version 3, or (at your option)
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
18
// with this library; see the file COPYING3.  If not see
19
// <http://www.gnu.org/licenses/>.
20
 
21
 
22
// 27.5.2 template class basic_streambuf
23
 
24
#include <cstring> // for memset, memcmp
25
#include <streambuf>
26
#include <sstream>
27
#include <ostream>
28
#include <testsuite_hooks.h>
29
 
30
// libstdc++/9424
31
class Outbuf_2 : public std::streambuf
32
{
33
  char buf[1];
34
 
35
public:
36
  Outbuf_2()
37
  {
38
    setp(buf, buf + 1);
39
  }
40
 
41
  int_type overflow(int_type c)
42
  {
43
    int_type eof = traits_type::eof();
44
 
45
    if (pptr() < epptr())
46
      {
47
        if (traits_type::eq_int_type(c, eof))
48
          return traits_type::not_eof(c);
49
 
50
        *pptr() = traits_type::to_char_type(c);
51
        pbump(1);
52
        return c;
53
      }
54
 
55
    return eof;
56
  }
57
};
58
 
59
class Inbuf_2 : public std::streambuf
60
{
61
  static const char buf[];
62
  const char* current;
63
  int size;
64
 
65
public:
66
  Inbuf_2()
67
  {
68
    current = buf;
69
    size = std::strlen(buf);
70
  }
71
 
72
  int_type underflow()
73
  {
74
    if (current < buf + size)
75
      return traits_type::to_int_type(*current);
76
    return traits_type::eof();
77
  }
78
 
79
  int_type uflow()
80
  {
81
    if (current < buf + size)
82
      return traits_type::to_int_type(*current++);
83
    return traits_type::eof();
84
  }
85
};
86
 
87
const char Inbuf_2::buf[] = "Atteivlis";
88
 
89
void test12()
90
{
91
  bool test __attribute__((unused)) = true;
92
 
93
  Outbuf_2 outbuf2;
94
  std::ostream os (&outbuf2);
95
  Inbuf_2 inbuf2;
96
  os << &inbuf2;
97
  VERIFY( inbuf2.sgetc() == 't' );
98
  VERIFY( os.good() );
99
}
100
 
101
int main()
102
{
103
  test12();
104
  return 0;
105
}

powered by: WebSVN 2.1.0

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