123353Sdfr// 2003-12-19  Paolo Carlini  <pcarlini@suse.de>
223353Sdfr
323353Sdfr// Copyright (C) 2003-2015 Free Software Foundation, Inc.
423353Sdfr//
523353Sdfr// This file is part of the GNU ISO C++ Library.  This library is free
623353Sdfr// software; you can redistribute it and/or modify it under the
723353Sdfr// terms of the GNU General Public License as published by the
823353Sdfr// Free Software Foundation; either version 3, or (at your option)
923353Sdfr// any later version.
1023353Sdfr
1123353Sdfr// This library is distributed in the hope that it will be useful,
1223353Sdfr// but WITHOUT ANY WARRANTY; without even the implied warranty of
1323353Sdfr// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
1423353Sdfr// GNU General Public License for more details.
1523353Sdfr
1623353Sdfr// You should have received a copy of the GNU General Public License along
1723353Sdfr// with this library; see the file COPYING3.  If not see
1823353Sdfr// <http://www.gnu.org/licenses/>.
1923353Sdfr
2023353Sdfr// 22.2.2.1.1  num_get members
2123353Sdfr
2223353Sdfr#include <locale>
2323353Sdfr#include <sstream>
2423353Sdfr#include <testsuite_hooks.h>
2523353Sdfr
2623353Sdfrvoid test01()
2723353Sdfr{
2823353Sdfr  using namespace std;
2950476Speter  typedef istreambuf_iterator<char> iterator_type;
3023353Sdfr
3123353Sdfr  bool test __attribute__((unused)) = true;
32206622Suqs
3323353Sdfr  istringstream iss;
3423353Sdfr  const num_get<char>& ng = use_facet<num_get<char> >(iss.getloc());
3523353Sdfr  ios_base::iostate err = ios_base::goodbit;
3623353Sdfr  iterator_type end;
3723353Sdfr  float f = 1.0f;
3884306Sru  double d = 1.0;
3984306Sru  long double ld = 1.0l;
4084306Sru
4123353Sdfr  iss.str("1e.");
4223353Sdfr  err = ios_base::goodbit;
4323353Sdfr  end = ng.get(iss.rdbuf(), 0, iss, err, f);
4423353Sdfr  VERIFY( err == ios_base::failbit );
4523353Sdfr  VERIFY( *end == '.' );
46115440Shmp  VERIFY( f == 0.0f );
47140931Sru
48115440Shmp  iss.str("3e+");
49140931Sru  iss.clear();
50115440Shmp  err = ios_base::goodbit;
51140931Sru  end = ng.get(iss.rdbuf(), 0, iss, err, d);
5223353Sdfr  VERIFY( err == (ios_base::failbit | ios_base::eofbit) );
5323353Sdfr  VERIFY( d == 0.0 );
5423353Sdfr
5523353Sdfr  iss.str("6e ");
5623353Sdfr  iss.clear();
5723353Sdfr  err = ios_base::goodbit;
5823467Smpp  end = ng.get(iss.rdbuf(), 0, iss, err, ld);
5923353Sdfr  VERIFY( *end == ' ' );
60103534Struckman
6123353Sdfr  // libstdc++/37624.  We can't always obtain the required behavior
6223353Sdfr  // when sscanf is involved, because of, e.g., glibc/1765.
6329966Swosch#if defined(_GLIBCXX_HAVE_STRTOLD) && !defined(_GLIBCXX_HAVE_BROKEN_STRTOLD)
6429966Swosch  VERIFY( err == ios_base::failbit );
6523353Sdfr  VERIFY( ld == 0.0l );
66147647Shmp#endif
6734504Scharnier}
68
69int main()
70{
71  test01();
72  return 0;
73}
74