OSDN Git Service

Licensing changes to GPLv3 resp. GPLv3 with GCC Runtime Exception.
[pf3gnuchains/gcc-fork.git] / libstdc++-v3 / testsuite / 27_io / basic_stringbuf / in_avail / char / 21955.cc
1 // 2005-06-07 Benjamin Kosnik
2
3 // Copyright (C) 2005, 2006, 2009
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 3, 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 COPYING3.  If not see
19 // <http://www.gnu.org/licenses/>.
20
21 #include <sstream>
22 #include <testsuite_hooks.h>
23 #include <stdexcept>
24
25 double  
26 test_stringstream()
27 {
28   double result;
29   const char* source = "1918"; 
30   std::stringstream s;
31   s << source;
32
33   std::string tmp = s.str();
34   std::streambuf* sb = s.rdbuf();
35   int i = sb->in_avail();
36
37   if (i)
38     {
39       s >> result;
40     }
41   else
42     {
43       throw std::runtime_error("conversion failed");
44     }
45   return result;
46 }
47
48
49 int main ()
50 {
51   test_stringstream();
52   return 0;
53 }