2016-10-16 Paolo Carlini <paolo.carlini@oracle.com>
[official-gcc.git] / libstdc++-v3 / testsuite / 22_locale / num_get / get / wchar_t / 39802.cc
blobfaabb69e9ae12c5f6b23fb61cc9357d107c12441
1 // Copyright (C) 2009-2016 Free Software Foundation, Inc.
2 //
3 // This file is part of the GNU ISO C++ Library. This library is free
4 // software; you can redistribute it and/or modify it under the
5 // terms of the GNU General Public License as published by the
6 // Free Software Foundation; either version 3, or (at your option)
7 // any later version.
9 // This library is distributed in the hope that it will be useful,
10 // but WITHOUT ANY WARRANTY; without even the implied warranty of
11 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 // GNU General Public License for more details.
14 // You should have received a copy of the GNU General Public License along
15 // with this library; see the file COPYING3. If not see
16 // <http://www.gnu.org/licenses/>.
18 // 22.2.2.1.1 num_get members
20 #include <locale>
21 #include <sstream>
22 #include <limits>
23 #include <testsuite_hooks.h>
25 // libstdc++/39802
26 void test01()
28 using namespace std;
29 typedef istreambuf_iterator<wchar_t> iterator_type;
31 wstringstream ss;
32 const num_get<wchar_t>& ng = use_facet<num_get<wchar_t> >(ss.getloc());
33 ios_base::iostate err;
34 iterator_type end;
35 const wstring empty;
37 unsigned long ul0 = 1;
38 const unsigned long ul1 = numeric_limits<unsigned long>::max();
40 ss << L"-0";
41 err = ios_base::goodbit;
42 end = ng.get(ss.rdbuf(), 0, ss, err, ul0);
43 VERIFY( err == ios_base::eofbit );
44 VERIFY( ul0 == 0 );
46 ss.clear();
47 ss.str(empty);
48 ss << L"-1";
49 err = ios_base::goodbit;
50 end = ng.get(ss.rdbuf(), 0, ss, err, ul0);
51 VERIFY( err == ios_base::eofbit );
52 VERIFY( ul0 == ul1 );
54 ss.clear();
55 ss.str(empty);
56 ss << L'-' << ul1;
57 err = ios_base::goodbit;
58 end = ng.get(ss.rdbuf(), 0, ss, err, ul0);
59 VERIFY( err == ios_base::eofbit );
60 VERIFY( ul0 == 1 );
62 ss.clear();
63 ss.str(empty);
64 ss << L'-' << ul1 << L'0';
65 err = ios_base::goodbit;
66 end = ng.get(ss.rdbuf(), 0, ss, err, ul0);
67 VERIFY( err == (ios_base::eofbit | ios_base::failbit) );
68 VERIFY( ul0 == ul1 );
71 int main()
73 test01();
74 return 0;