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

Subversion Repositories scarts

[/] [scarts/] [trunk/] [toolchain/] [scarts-gcc/] [gcc-4.1.1/] [libstdc++-v3/] [testsuite/] [22_locale/] [time_put/] [put/] [wchar_t/] [12439_2.cc] - Blame information for rev 19

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 19 jlechner
// Copyright (C) 2003 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
// 22.2.5.3.1 time_put members
20
 
21
#include <locale>
22
#include <sstream>
23
#include <ctime>
24
#include <cstring>
25
#include <testsuite_hooks.h>
26
 
27
// libstdc++/12439
28
// time_put::put writes narrowed characters to output iterator
29
void test02()
30
{
31
  using namespace std;
32
  bool test __attribute__((unused)) = true;
33
 
34
  typedef time_put<wchar_t> tp_type;
35
 
36
  const wchar_t fmt[] = {
37
    0xa0, 0x103, 0xfc, 0xb3, 0xa0c3,
38
    L'%', L'c'
39
  };
40
 
41
  const size_t len = sizeof(fmt) / sizeof(fmt[0]);
42
  const size_t cmplen = wcschr(fmt, L'%') - fmt;
43
 
44
  locale loc;
45
  const tp_type& tp = use_facet<tp_type>(loc);
46
  time_t tt = time(NULL);
47
  wostringstream stream;
48
 
49
  tp.put(tp_type::iter_type(stream), stream, stream.fill(),
50
         localtime(&tt), fmt, fmt + len);
51
  wstring str = stream.str();
52
  VERIFY( str.length() >= cmplen );
53
  VERIFY( !wmemcmp(str.data(), fmt, cmplen) );
54
}
55
 
56
int main()
57
{
58
  test02();
59
  return 0;
60
}

powered by: WebSVN 2.1.0

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