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

Subversion Repositories scarts

[/] [scarts/] [trunk/] [toolchain/] [scarts-gcc/] [gcc-4.1.1/] [libstdc++-v3/] [testsuite/] [27_io/] [basic_istream/] [getline/] [wchar_t/] [1.cc] - Blame information for rev 19

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 19 jlechner
// Copyright (C) 2004 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 2, 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 COPYING.  If not, write to the Free
16
// Software Foundation, 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301,
17
// USA.
18
 
19
// 27.6.1.3 unformatted input functions
20
 
21
#include <istream>
22
#include <sstream>
23
#include <testsuite_hooks.h>
24
 
25
void
26
test02()
27
{
28
  typedef std::char_traits<wchar_t>     traits_type;
29
 
30
  bool test __attribute__((unused)) = true;
31
  const wchar_t str_lit01[] = L"\t\t\t    sun*ra \n"
32
  L"                            "
33
  L"and his myth science arkestra present\n"
34
  L"                            "
35
  L"angles and demons @ play\n"
36
  L"                            "
37
  L"the nubians of plutonia";
38
  std::wstring str01(str_lit01);
39
  std::wstring strtmp;
40
 
41
  std::wstringbuf sbuf_04(str01, std::ios_base::in);
42
 
43
  std::wistream is_00(NULL);
44
  std::wistream is_04(&sbuf_04);
45
  std::ios_base::iostate state1, state2, statefail, stateeof;
46
  statefail = std::ios_base::failbit;
47
  stateeof = std::ios_base::eofbit;
48
  wchar_t carray1[400] = L"";
49
 
50
  // istream& getline(wchar_t* s, streamsize n, wchar_t delim)
51
  // istream& getline(wchar_t* s, streamsize n)
52
  state1 = is_00.rdstate();
53
  is_00.getline(carray1, 20, L'*');
54
  state2 = is_00.rdstate();
55
  // make sure failbit was set, since we couldn't extract
56
  // from the NULL streambuf...
57
  VERIFY( state1 != state2 );
58
  VERIFY( static_cast<bool>(state2 & statefail) );
59
 
60
  VERIFY( is_04.gcount() == 0 );
61
  state1 = is_04.rdstate();
62
  is_04.getline(carray1, 1, L'\t'); // extracts, throws away
63
  state2 = is_04.rdstate();
64
  VERIFY( is_04.gcount() == 1 );
65
  VERIFY( state1 == state2 );
66
  VERIFY( state1 == 0 );
67
  VERIFY( !traits_type::compare(L"", carray1, 1) );
68
 
69
  state1 = is_04.rdstate();
70
  is_04.getline(carray1, 20, L'*');
71
  state2 = is_04.rdstate();
72
  VERIFY( is_04.gcount() == 10 );
73
  VERIFY( state1 == state2 );
74
  VERIFY( state1 == 0 );
75
  VERIFY( !traits_type::compare(L"\t\t    sun", carray1, 10) );
76
 
77
  state1 = is_04.rdstate();
78
  is_04.getline(carray1, 20);
79
  state2 = is_04.rdstate();
80
  VERIFY( is_04.gcount() == 4 );
81
  VERIFY( state1 == state2 );
82
  VERIFY( state1 == 0 );
83
  VERIFY( !traits_type::compare(L"ra ", carray1, 4) );
84
 
85
  state1 = is_04.rdstate();
86
  is_04.getline(carray1, 65);
87
  state2 = is_04.rdstate();
88
  VERIFY( is_04.gcount() == 64 );
89
  VERIFY( state1 != state2 );
90
  VERIFY( state2 == statefail );
91
  VERIFY( !traits_type::compare(
92
  L"                            and his myth science arkestra presen",
93
                                carray1, 65) );
94
 
95
  is_04.clear();
96
  state1 = is_04.rdstate();
97
  is_04.getline(carray1, 120, L'|');
98
  state2 = is_04.rdstate();
99
  VERIFY( is_04.gcount() == 106 );
100
  VERIFY( state1 != state2 );
101
  VERIFY( state2 == stateeof );
102
 
103
  is_04.clear();
104
  state1 = is_04.rdstate();
105
  is_04.getline(carray1, 100, L'|');
106
  state2 = is_04.rdstate();
107
  VERIFY( is_04.gcount() == 0 );
108
  VERIFY( state1 != state2 );
109
  VERIFY( static_cast<bool>(state2 & stateeof) );
110
  VERIFY( static_cast<bool>(state2 & statefail) );
111
}
112
 
113
int
114
main()
115
{
116
  test02();
117
  return 0;
118
}

powered by: WebSVN 2.1.0

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