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_stringbuf/] [str/] [wchar_t/] [1.cc] - Blame information for rev 19

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 19 jlechner
// 981208 bkoz test functionality of basic_stringbuf for char_type == wchar_t
2
 
3
// Copyright (C) 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005
4
// Free Software Foundation, Inc.
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 2, 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 COPYING.  If not, write to the Free
19
// Software Foundation, 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301,
20
// USA.
21
 
22
#include <sstream>
23
#include <testsuite_hooks.h>
24
 
25
std::wstring str_01(L"mykonos. . . or what?");
26
std::wstring str_02(L"paris, or sainte-maxime?");
27
std::wstring str_03;
28
std::wstringbuf strb_01(str_01);
29
std::wstringbuf strb_02(str_02, std::ios_base::in);
30
std::wstringbuf strb_03(str_03, std::ios_base::out);
31
 
32
// test member functions
33
void test03()
34
{
35
  bool test __attribute__((unused)) = true;
36
 
37
  // stringbuf::str()
38
  VERIFY( strb_01.str() == str_01 );
39
  VERIFY( strb_02.str() == str_02 );
40
  VERIFY( strb_03.str() == str_03 );
41
 
42
  // stringbuf::str(string&)
43
  strb_03.str(L"none of the above, go to the oberoi in cairo, egypt.");
44
  strb_03.str(str_01);
45
  std::streamsize d1 = strb_01.in_avail();
46
  std::streamsize d2 = strb_03.in_avail();
47
  VERIFY( d1 ); // non-zero
48
  VERIFY( d2 == -1 ); // -1, cuz ios_base::out
49
  VERIFY( d1 != d2 ); //these should be the same
50
  VERIFY( static_cast<std::streamsize>(str_01.length()) == d1 );
51
  VERIFY( strb_01.str() == strb_03.str() ); //ditto
52
 
53
  // stringbuf::str(string&) and stringbuf::stringbuf(string&), where the
54
  // string in question contains embedded NUL characters.  Note that in this
55
  // embedded-NUL situation, the size must be passed to the string ctor.
56
  std::wstring str_nulls(L"eschew \0 obfuscation", 20);  // tested in 21_strings
57
  std::wstringbuf strb_normal(str_01);
58
  std::wstringbuf strb_nulls(str_nulls);
59
  strb_normal.str(str_nulls);  // tried using 'strb_01' rather than declaring
60
                               // another variable, but then test04 broke!
61
  VERIFY( strb_nulls.in_avail() == static_cast<std::streamsize>(str_nulls.size())  );
62
  VERIFY( strb_nulls.str().size() == 20 );
63
  VERIFY( strb_normal.in_avail() == static_cast<std::streamsize>(str_nulls.size()) );
64
}
65
 
66
int main()
67
{
68
  test03();
69
  return 0;
70
}
71
 
72
 
73
 
74
// more candy!!!

powered by: WebSVN 2.1.0

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