]> git.ipfire.org Git - thirdparty/gcc.git/blame - libstdc++-v3/testsuite/22_locale/num_get/get/wchar_t/10.cc
Update copyright years.
[thirdparty/gcc.git] / libstdc++-v3 / testsuite / 22_locale / num_get / get / wchar_t / 10.cc
CommitLineData
1b451306
PC
1// 2003-12-19 Paolo Carlini <pcarlini@suse.de>
2
83ffe9cd 3// Copyright (C) 2003-2023 Free Software Foundation, Inc.
1b451306
PC
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
748086b7 8// Free Software Foundation; either version 3, or (at your option)
1b451306
PC
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
748086b7
JJ
17// with this library; see the file COPYING3. If not see
18// <http://www.gnu.org/licenses/>.
1b451306
PC
19
20// 22.2.2.1.1 num_get members
21
22#include <locale>
23#include <sstream>
24#include <testsuite_hooks.h>
25
26void test01()
27{
28 using namespace std;
29 typedef istreambuf_iterator<wchar_t> iterator_type;
1b451306
PC
30
31 wistringstream iss;
32 const num_get<wchar_t>& ng = use_facet<num_get<wchar_t> >(iss.getloc());
33 ios_base::iostate err = ios_base::goodbit;
34 iterator_type end;
1304d581
PC
35 float f = 1.0f;
36 double d = 1.0;
37 long double ld = 1.0l;
1b451306
PC
38
39 iss.str(L"1e.");
40 err = ios_base::goodbit;
41 end = ng.get(iss.rdbuf(), 0, iss, err, f);
5ef46f95 42 VERIFY( err == ios_base::failbit );
1b451306 43 VERIFY( *end == L'.' );
5ef46f95 44 VERIFY( f == 0.0f );
1b451306
PC
45
46 iss.str(L"3e+");
47 iss.clear();
48 err = ios_base::goodbit;
49 end = ng.get(iss.rdbuf(), 0, iss, err, d);
5ef46f95
PC
50 VERIFY( err == (ios_base::failbit | ios_base::eofbit) );
51 VERIFY( d == 0.0 );
1b451306
PC
52
53 iss.str(L"6e ");
54 iss.clear();
55 err = ios_base::goodbit;
56 end = ng.get(iss.rdbuf(), 0, iss, err, ld);
1b451306 57 VERIFY( *end == L' ' );
1304d581
PC
58
59 // libstdc++/37624. We can't always obtain the required behavior
60 // when sscanf is involved, because of, e.g., glibc/1765.
61#if defined(_GLIBCXX_HAVE_STRTOLD) && !defined(_GLIBCXX_HAVE_BROKEN_STRTOLD)
62 VERIFY( err == ios_base::failbit );
5ef46f95 63 VERIFY( ld == 0.0l );
1304d581 64#endif
1b451306
PC
65}
66
67int main()
68{
69 test01();
70 return 0;
71}