OpenCores
URL https://opencores.org/ocsvn/openrisc_2011-10-31/openrisc_2011-10-31/trunk

Subversion Repositories openrisc_2011-10-31

[/] [openrisc/] [trunk/] [gnu-src/] [gcc-4.5.1/] [libstdc++-v3/] [testsuite/] [27_io/] [basic_ostream/] [inserters_arithmetic/] [wchar_t/] [4402.cc] - Blame information for rev 565

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 424 jeremybenn
// { dg-require-swprintf "" }
2
 
3
// Copyright (C) 2005, 2006, 2007, 2009 Free Software Foundation, Inc.
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 3, 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 COPYING3.  If not see
18
// <http://www.gnu.org/licenses/>.
19
 
20 565 jeremybenn
// { dg-do run { xfail newlib } }
21
 
22 424 jeremybenn
#include <cstdio> // for swprintf
23
#include <iostream>
24
#include <iomanip>
25
#include <sstream>
26
#include <limits>
27
#include <testsuite_hooks.h>
28
 
29
void
30
test02()
31
{
32
  using namespace std;
33
  bool test __attribute__((unused)) = true;
34
 
35
  // make sure we can output a very long float
36
  long double val = numeric_limits<long double>::max();
37
  int prec = numeric_limits<long double>::digits10;
38
 
39
  wostringstream os;
40
  os.precision(prec);
41
  os.setf(wios::scientific);
42
  os << val;
43
 
44
  wchar_t largebuf[512];
45
  swprintf(largebuf, 512, L"%.*Le", prec, val);
46
#ifdef TEST_NUMPUT_VERBOSE
47
  cout << "expect: " << largebuf << endl;
48
  cout << "result: " << os.str() << endl;
49
#endif
50
  VERIFY( os && os.str() == largebuf );
51
 
52
  // Make sure we can output a long float in fixed format
53
  // without seg-faulting (libstdc++/4402)
54
  double val2 = numeric_limits<double>::max();
55
 
56
  wostringstream os2;
57
  os2.precision(3);
58
  os2.setf(wios::fixed);
59
  os2 << val2;
60
 
61
  swprintf(largebuf, 512, L"%.*f", 3, val2);
62
#ifdef TEST_NUMPUT_VERBOSE
63
  cout << "expect: " << largebuf << endl;
64
  cout << "result: " << os2.str() << endl;
65
#endif
66
  VERIFY( os2 && os2.str() == largebuf );
67
}
68
 
69
int
70
main()
71
{
72
  test02();
73
  return 0;
74
}

powered by: WebSVN 2.1.0

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