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_istream/] [extractors_character/] [wchar_t/] [4.cc] - Blame information for rev 565

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 424 jeremybenn
// 2005-07-22  Paolo Carlini  <pcarlini@suse.de>
2
 
3
// Copyright (C) 2005, 2006, 2007, 2009 Free Software Foundation
4
//
5
// This file is part of the GNU ISO C++ Library.  This library is free
6
// software; you can redistribute it and/or modify it under the
7
// terms of the GNU General Public License as published by the
8
// Free Software Foundation; either version 3, or (at your option)
9
// any later version.
10
 
11
// This library is distributed in the hope that it will be useful,
12
// but WITHOUT ANY WARRANTY; without even the implied warranty of
13
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14
// GNU General Public License for more details.
15
 
16
// You should have received a copy of the GNU General Public License along
17
// with this library; see the file COPYING3.  If not see
18
// <http://www.gnu.org/licenses/>.
19
 
20
// 27.6.1.2.3 basic_istream::operator>>
21
 
22 565 jeremybenn
// { dg-xfail-run-if "not supported on OR32 newlib" { or32-*-elf } }
23
 
24 424 jeremybenn
#include <istream>
25
#include <string>
26
#include <fstream>
27
#include <cstdlib>
28
#include <testsuite_hooks.h>
29
 
30
using namespace std;
31
 
32
wstring prepare(wstring::size_type len, unsigned nchunks)
33
{
34
  wstring ret;
35
  for (unsigned i = 0; i < nchunks; ++i)
36
    {
37
      for (wstring::size_type j = 0; j < len; ++j)
38
        ret.push_back(L'a' + rand() % 26);
39
      len *= 2;
40
      ret.push_back(L' ');
41
    }
42
  return ret;
43
}
44
 
45
void check(wistream& stream, const wstring& str, unsigned nchunks)
46
{
47
  bool test __attribute__((unused)) = true;
48
 
49
  wchar_t* chunk = new wchar_t[str.size()];
50
  wmemset(chunk, L'X', str.size());
51
 
52
  wstring::size_type index = 0, index_new = 0;
53
  unsigned n = 0;
54
 
55
  while (stream >> chunk)
56
    {
57
      index_new = str.find(' ', index);
58
      VERIFY( !str.compare(index, index_new - index, chunk) );
59
      index = index_new + 1;
60
      ++n;
61
      wmemset(chunk, L'X', str.size());
62
    }
63
  VERIFY( stream.eof() );
64
  VERIFY( n == nchunks );
65
 
66
  delete[] chunk;
67
}
68
 
69
// istream& operator>>(istream&, charT*)
70
void test01()
71
{
72
  const char filename[] = "inserters_extractors-4.txt";
73
 
74
  const unsigned nchunks = 10;
75
  const wstring data = prepare(666, nchunks);
76
 
77
  wofstream ofstrm;
78
  ofstrm.open(filename);
79
  ofstrm.write(data.data(), data.size());
80
  ofstrm.close();
81
 
82
  wifstream ifstrm;
83
  ifstrm.open(filename);
84
  check(ifstrm, data, nchunks);
85
  ifstrm.close();
86
}
87
 
88
int main()
89
{
90
  test01();
91
  return 0;
92
}

powered by: WebSVN 2.1.0

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