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

Subversion Repositories openrisc_me

[/] [openrisc/] [trunk/] [gnu-src/] [gcc-4.5.1/] [libstdc++-v3/] [testsuite/] [27_io/] [basic_istream/] [get/] [wchar_t/] [1.cc] - Blame information for rev 424

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 424 jeremybenn
// Copyright (C) 2004, 2009 Free Software Foundation
2
//
3
// This file is part of the GNU ISO C++ Library.  This library is free
4
// software; you can redistribute it and/or modify it under the
5
// terms of the GNU General Public License as published by the
6
// Free Software Foundation; either version 3, or (at your option)
7
// any later version.
8
 
9
// This library is distributed in the hope that it will be useful,
10
// but WITHOUT ANY WARRANTY; without even the implied warranty of
11
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
12
// GNU General Public License for more details.
13
 
14
// You should have received a copy of the GNU General Public License along
15
// with this library; see the file COPYING3.  If not see
16
// <http://www.gnu.org/licenses/>.
17
 
18
// 27.6.1.3 unformatted input functions
19
 
20
#include <istream>
21
#include <sstream>
22
#include <testsuite_hooks.h>
23
 
24
void
25
test03()
26
{
27
  typedef std::char_traits<wchar_t>     traits_type;
28
 
29
  bool test __attribute__((unused)) = true;
30
  const wchar_t str_lit01[] =
31
  L"   sun*ra \n\t\t\t   & his arkestra, featuring john gilmore: \n"
32
  L"                         "
33
    L"jazz in silhouette: images and forecasts of tomorrow";
34
 
35
  std::wstring str01(str_lit01);
36
  std::wstring strtmp;
37
 
38
  std::wstringbuf sbuf_03;
39
  std::wstringbuf sbuf_04(str01, std::ios_base::in);
40
  std::wstringbuf sbuf_05(str01, std::ios_base::in);
41
 
42
  std::wistream is_00(NULL);
43
  std::wistream is_04(&sbuf_04);
44
  std::wistream is_05(&sbuf_05);
45
  std::ios_base::iostate statefail, stateeof;
46
  statefail = std::ios_base::failbit;
47
  stateeof = std::ios_base::eofbit;
48
  wchar_t carray1[400] = L"";
49
 
50
  // int_type get()
51
  // istream& get(wchar_t*, streamsize, wchar_t delim)
52
  // istream& get(wchar_t*, streamsize)
53
  // istream& get(streambuf&, wchar_t delim)
54
  // istream& get(streambuf&)
55
  is_00.get(carray1, 2);
56
  VERIFY( static_cast<bool>(is_00.rdstate() & statefail) );
57
  VERIFY( is_00.gcount() == 0 );
58
 
59
  is_04.get(carray1, 4);
60
  VERIFY( !(is_04.rdstate() & statefail) );
61
  VERIFY( !traits_type::compare(carray1, L"   ", 4) );
62
  VERIFY( is_04.gcount() == 3 );
63
 
64
  is_04.clear();
65
  is_04.get(carray1 + 3, 200);
66
  VERIFY( !(is_04.rdstate() & statefail) );
67
  VERIFY( !(is_04.rdstate() & stateeof) );
68
  VERIFY( !traits_type::compare(carray1, str_lit01, 10) );
69
  VERIFY( is_04.gcount() == 7 );
70
 
71
  is_04.clear();
72
  is_04.get(carray1, 200);
73
  VERIFY( !(is_04.rdstate() & stateeof) );
74
  VERIFY( static_cast<bool>(is_04.rdstate() & statefail) ); // delimiter
75
  VERIFY( is_04.gcount() == 0 );
76
  is_04.clear();
77
  is_04.get(carray1, 200, L'[');
78
  VERIFY( static_cast<bool>(is_04.rdstate() & stateeof) );
79
  VERIFY( !(is_04.rdstate() & statefail) );
80
  VERIFY( is_04.gcount() == 125 );
81
  is_04.clear();
82
  is_04.get(carray1, 200);
83
  VERIFY( static_cast<bool>(is_04.rdstate() & stateeof) );
84
  VERIFY( static_cast<bool>(is_04.rdstate() & statefail) );
85
  VERIFY( is_04.gcount() == 0 );
86
 
87
  std::wstringbuf sbuf_02(std::ios_base::in);
88
  is_05.clear();
89
  is_05.get(sbuf_02);
90
  VERIFY( is_05.gcount() == 0 );
91
  VERIFY( static_cast<bool>(is_05.rdstate() & statefail) );
92
  VERIFY( !(is_05.rdstate() & stateeof) );
93
 
94
  is_05.clear();
95
  is_05.get(sbuf_03);
96
  VERIFY( is_05.gcount() == 10 );
97
  VERIFY( sbuf_03.str() == L"   sun*ra " );
98
  VERIFY( !(is_05.rdstate() & statefail) );
99
  VERIFY( !(is_05.rdstate() & stateeof) );
100
 
101
  is_05.clear();
102
  is_05.get(sbuf_03, L'|');
103
  VERIFY( is_05.gcount() == 125 );
104
  VERIFY( sbuf_03.str() == str_lit01 );
105
  VERIFY( !(is_05.rdstate() & statefail) );
106
  VERIFY( static_cast<bool>(is_05.rdstate() & stateeof) );
107
 
108
  is_05.clear();
109
  is_05.get(sbuf_03, L'|');
110
  VERIFY( is_05.gcount() == 0 );
111
  VERIFY( static_cast<bool>(is_05.rdstate() & stateeof) );
112
  VERIFY( static_cast<bool>(is_05.rdstate() & statefail) );
113
}
114
 
115
int
116
main()
117
{
118
  test03();
119
  return 0;
120
}

powered by: WebSVN 2.1.0

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