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

Subversion Repositories openrisc

[/] [openrisc/] [trunk/] [gnu-dev/] [or1k-gcc/] [libstdc++-v3/] [testsuite/] [ext/] [stdio_sync_filebuf/] [char/] [1.cc] - Blame information for rev 820

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

Line No. Rev Author Line
1 742 jeremybenn
// 2003-05-01 Petur Runolfsson <peturr02@ru.is>
2
 
3
// Copyright (C) 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010 
4
// Free Software Foundation
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
// { dg-require-fileio "" }
22
 
23
#include <ext/stdio_sync_filebuf.h>
24
#include <cstring>
25
#include <testsuite_hooks.h>
26
 
27
void test01()
28
{
29
  using namespace std;
30
 
31
  bool test __attribute__((unused)) = true;
32
  const char* c_lit = "black pearl jasmine tea";
33
  unsigned size = strlen(c_lit);
34
  const char* name = "stdiobuf-1.txt";
35
 
36
  FILE* fout = fopen(name, "w");
37
  VERIFY( fwrite(c_lit, 1, size, fout) == size );
38
  fclose(fout);
39
 
40
  FILE* fin = fopen(name, "r");
41
  __gnu_cxx::stdio_sync_filebuf<char> sbuf(fin);
42
 
43
  VERIFY( sbuf.sgetc() == c_lit[0] );
44
  VERIFY( getc(fin) == c_lit[0] );
45
  VERIFY( sbuf.sgetc() == c_lit[1] );
46
  VERIFY( sbuf.sbumpc() == c_lit[1] );
47
  VERIFY( ungetc('Z', fin) == 'Z' );
48
  VERIFY( sbuf.sbumpc() == 'Z' );
49
  VERIFY( getc(fin) == c_lit[2] );
50
  VERIFY( sbuf.sputbackc('X') == 'X' );
51
  VERIFY( getc(fin) == 'X' );
52
 
53
  char buf[5];
54
  memset(buf, 'x', 5);
55
  VERIFY( sbuf.sgetn(buf, 5) == 5 );
56
  VERIFY( !memcmp(buf, c_lit + 3, 5) );
57
  VERIFY( getc(fin) == c_lit[8] );
58
 
59
  fclose(fin);
60
}
61
 
62
int main ()
63
{
64
  test01();
65
  return 0;
66
}

powered by: WebSVN 2.1.0

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