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

Subversion Repositories openrisc

[/] [openrisc/] [trunk/] [gnu-dev/] [or1k-gcc/] [libstdc++-v3/] [testsuite/] [27_io/] [basic_filebuf/] [seekoff/] [wchar_t/] [2.cc] - Blame information for rev 742

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 742 jeremybenn
// { dg-require-namedlocale "se_NO.UTF-8" }
2
 
3
// 2003-09-08  Petur Runolfsson  <peturr02@ru.is>
4
 
5
// Copyright (C) 2003, 2005, 2009 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
// 27.8.1.4 Overridden virtual functions
23
 
24
#include <fstream>
25
#include <locale>
26
#include <cstdio>
27
#include <testsuite_hooks.h>
28
 
29
// Check that basic_filebuf::seekoff handles UTF-8 when open for input and
30
// output.
31
void test02()
32
{
33
  using namespace std;
34
  typedef wfilebuf::int_type int_type;
35
  bool test __attribute__((unused)) = true;
36
  const char name[] = "tmp_seekoff-2.tst";
37
 
38
  locale loc = locale("se_NO.UTF-8");
39
 
40
  const size_t size = 10;
41
  wchar_t buf[size];
42
  streamsize n;
43
 
44
  wfilebuf fb;
45
  fb.pubimbue(loc);
46
  fb.open(name, ios_base::in | ios_base::out | ios_base::trunc);
47
 
48
  n = fb.sputn(L"\xa0st", 3);
49
  VERIFY( n == 3 );
50
 
51
  fb.pubseekoff(0, ios_base::beg);
52
  n = fb.sgetn(buf, 2);
53
  VERIFY( n == 2 );
54
  VERIFY( !wmemcmp(buf, L"\xa0s", 2) );
55
 
56
  fb.pubseekoff(0, ios_base::cur);
57
  n = fb.sputn(L"\xb2R", 2);
58
  VERIFY( n == 2 );
59
 
60
  fb.pubseekoff(0, ios_base::beg);
61
  n = fb.sgetn(buf, size);
62
  VERIFY( n == 4 );
63
  VERIFY( !wmemcmp(buf, L"\xa0s\xb2R", 4) );
64
 
65
  fb.pubseekoff(0, ios_base::beg);
66
  n = fb.sputn(L"\x90m\x92n\x94", 5);
67
  VERIFY( n == 5 );
68
 
69
  fb.pubseekoff(0, ios_base::beg);
70
  n = fb.sgetn(buf, 2);
71
  VERIFY( n == 2 );
72
  VERIFY( !wmemcmp(buf, L"\x90m", 2) );
73
 
74
  fb.pubseekoff(0, ios_base::end);
75
  n = fb.sputn(L"I\xbfJ", 3);
76
  VERIFY( n == 3 );
77
 
78
  fb.pubseekoff(0, ios_base::beg);
79
  n = fb.sgetn(buf, size);
80
  VERIFY( n == 8 );
81
  VERIFY( !wmemcmp(buf, L"\x90m\x92n\x94I\xbfJ", 8) );
82
 
83
  fb.close();
84
}
85
 
86
int main()
87
{
88
  test02();
89
  return 0;
90
}

powered by: WebSVN 2.1.0

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