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_ostream/] [inserters_character/] [wchar_t/] [7.cc] - Blame information for rev 19

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 19 jlechner
// 1999-08-16 bkoz
2
 
3
// Copyright (C) 1999, 2000, 2002, 2003 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 2, 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 COPYING.  If not, write to the Free
18
// Software Foundation, 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301,
19
// USA.
20
 
21
// 27.6.2.5.4 basic_ostream character inserters
22
 
23
#include <string>
24
#include <ostream>
25
#include <sstream>
26
#include <locale>
27
#include <testsuite_hooks.h>
28
 
29
// Global counter, needs to be reset after use.
30
bool used;
31
 
32
class gnu_ctype : public std::ctype<wchar_t>
33
{
34
protected:
35
  char_type
36
  do_widen(char c) const
37
  {
38
    used = true;
39
    return std::ctype<wchar_t>::do_widen(c);
40
  }
41
 
42
  const char*
43
  do_widen(const char* low, const char* high, char_type* dest) const
44
  {
45
    used = true;
46
    return std::ctype<wchar_t>::do_widen(low, high, dest);
47
  }
48
};
49
 
50
// 27.6.2.5.4 - Character inserter template functions 
51
// [lib.ostream.inserters.character]
52
void test07()
53
{
54
  using namespace std;
55
  bool test __attribute__((unused)) = true;
56
 
57
  const char* buffer = "SFPL 5th floor, outside carrol, the Asian side";
58
 
59
  wostringstream oss;
60
  oss.imbue(locale(locale::classic(), new gnu_ctype));
61
 
62
  // 1
63
  // template<class charT, class traits>
64
  // basic_ostream<charT,traits>& operator<<(basic_ostream<charT,traits>& out,
65
  //                                           const char* s);
66
  used = false;
67
  oss << buffer;
68
  VERIFY( used ); // Only required for char_type != char
69
  wstring str = oss.str();
70
  wchar_t c1 = oss.widen(buffer[0]);
71
  VERIFY( str[0] == c1 );
72
  wchar_t c2 = oss.widen(buffer[1]);
73
  VERIFY( str[1] == c2 );
74
 
75
  // 2
76
  // template<class charT, class traits>
77
  // basic_ostream<charT,traits>& operator<<(basic_ostream<charT,traits>& out,
78
  //                                         char c);
79
  used = false;
80
  oss.str(wstring());
81
  oss << 'b';
82
  VERIFY( used ); // Only required for char_type != char
83
  str = oss.str();
84
  wchar_t c3 = oss.widen('b');
85
  VERIFY( str[0] == c3 );
86
}
87
 
88
int main()
89
{
90
  test07();
91
  return 0;
92
}

powered by: WebSVN 2.1.0

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