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

Subversion Repositories openrisc

[/] [openrisc/] [trunk/] [gnu-dev/] [or1k-gcc/] [libstdc++-v3/] [testsuite/] [27_io/] [basic_streambuf/] [sputn/] [char/] [1.cc] - Blame information for rev 746

Go to most recent revision | Details | Compare with Previous | View Log

Line No. Rev Author Line
1 742 jeremybenn
// 1999-10-11 bkoz
2
 
3
// Copyright (C) 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006,
4
// 2007, 2009, 2010
5
// Free Software Foundation, Inc.
6
//
7
// This file is part of the GNU ISO C++ Library.  This library is free
8
// software; you can redistribute it and/or modify it under the
9
// terms of the GNU General Public License as published by the
10
// Free Software Foundation; either version 3, or (at your option)
11
// any later version.
12
 
13
// This library is distributed in the hope that it will be useful,
14
// but WITHOUT ANY WARRANTY; without even the implied warranty of
15
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
16
// GNU General Public License for more details.
17
 
18
// You should have received a copy of the GNU General Public License along
19
// with this library; see the file COPYING3.  If not see
20
// <http://www.gnu.org/licenses/>.
21
 
22
 
23
// 27.5.2 template class basic_streambuf
24
 
25
#include <streambuf>
26
#include <cstring>
27
#include <testsuite_hooks.h>
28
 
29
class testbuf : public std::streambuf
30
{
31
public:
32
 
33
  // Typedefs:
34
  typedef std::streambuf::traits_type traits_type;
35
  typedef std::streambuf::char_type char_type;
36
 
37
  testbuf(): std::streambuf()
38
  { }
39
 
40
  bool
41
  check_pointers()
42
  {
43
    bool test __attribute__((unused)) = true;
44
    VERIFY( !this->eback() );
45
    VERIFY( !this->gptr() );
46
    VERIFY( !this->egptr() );
47
    VERIFY( !this->pbase() );
48
    VERIFY( !this->pptr() );
49
    VERIFY( !this->epptr() );
50
    return test;
51
  }
52
 
53
  int_type
54
  pub_uflow()
55
  { return (this->uflow()); }
56
 
57
  int_type
58
  pub_overflow(int_type __c = traits_type::eof())
59
  { return (this->overflow(__c)); }
60
 
61
  int_type
62
  pub_pbackfail(int_type __c)
63
  { return (this->pbackfail(__c)); }
64
 
65
  void
66
  pub_setg(char* beg, char* cur, char *end)
67
  { this->setg(beg, cur, end); }
68
 
69
  void
70
  pub_setp(char* beg, char* end)
71
  { this->setp(beg, end); }
72
 
73
protected:
74
  int_type
75
  underflow()
76
  {
77
    int_type __retval = traits_type::eof();
78
    if (this->gptr() < this->egptr())
79
      __retval = traits_type::not_eof(0);
80
    return __retval;
81
  }
82
};
83
 
84
void test01()
85
{
86
  typedef testbuf::traits_type traits_type;
87
  typedef testbuf::int_type int_type;
88
 
89
  bool test __attribute__((unused)) = true;
90
  testbuf buf01;
91
 
92
  // sputn/xsputn
93
  char lit02[] = "isotope 217: the unstable molecule on thrill jockey";
94
  const int i02 = std::strlen(lit02);
95
 
96
  char carray[i02 + 1];
97
  std::memset(carray, 0, i02 + 1);
98
 
99
  buf01.pub_setp(carray, (carray + i02));
100
  buf01.sputn(lit02, 0);
101
  VERIFY( carray[0] == 0 );
102
  VERIFY( lit02[0] == 'i' );
103
  buf01.sputn(lit02, 1);
104
  VERIFY( lit02[0] == carray[0] );
105
  VERIFY( lit02[1] == 's' );
106
  VERIFY( carray[1] == 0 );
107
  buf01.sputn(lit02 + 1, 10);
108
  VERIFY( std::memcmp(lit02, carray, 10) == 0 );
109
  buf01.sputn(lit02 + 11, 20);
110
  VERIFY( std::memcmp(lit02, carray, 30) == 0 );
111
}
112
 
113
int main()
114
{
115
  test01();
116
  return 0;
117
}

powered by: WebSVN 2.1.0

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