OSDN Git Service

647f8714629265fac64fcd614277f4535b84ab39
[pf3gnuchains/gcc-fork.git] / libstdc++-v3 / testsuite / 27_io / basic_ostream / inserters_arithmetic / char / 5.cc
1 // 1999-11-15 Kevin Ediger  <kediger@licor.com>
2 // test the floating point inserters (facet num_put)
3
4 // Copyright (C) 1999, 2002, 2003 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, 59 Temple Place - Suite 330, Boston, MA 02111-1307,
20 // USA.
21
22 #include <cmath> // for abs
23 #include <cfloat> // for DBL_EPSILON
24 #include <sstream>
25 #include <limits>
26 #include <testsuite_hooks.h>
27
28 using namespace std;
29
30 void
31 test05()
32 {
33   bool test = true;
34   double pi = 3.14159265358979323846;
35   ostringstream ostr;
36   ostr.precision(20);
37   ostr << pi;
38   string sval = ostr.str();
39   istringstream istr (sval);
40   double d;
41   istr >> d;
42   VERIFY( abs(pi-d)/pi < DBL_EPSILON );
43 }
44
45 int 
46 main()
47 {
48   test05();
49   return 0;
50 }