]>
Commit | Line | Data |
---|---|---|
f1717362 | 1 | // Copyright (C) 2009-2016 Free Software Foundation, Inc. |
d0c23644 | 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. | |
8 | ||
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. | |
13 | ||
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/>. | |
17 | ||
18 | // 22.2.2.1.1 num_get members | |
19 | ||
20 | #include <locale> | |
21 | #include <sstream> | |
22 | #include <limits> | |
23 | #include <testsuite_hooks.h> | |
24 | ||
25 | // libstdc++/39802 | |
26 | void test01() | |
27 | { | |
28 | using namespace std; | |
29 | typedef istreambuf_iterator<wchar_t> iterator_type; | |
30 | ||
31 | bool test __attribute__((unused)) = true; | |
32 | ||
33 | wstringstream ss; | |
34 | const num_get<wchar_t>& ng = use_facet<num_get<wchar_t> >(ss.getloc()); | |
35 | ios_base::iostate err; | |
36 | iterator_type end; | |
37 | const wstring empty; | |
38 | ||
39 | unsigned long ul0 = 1; | |
40 | const unsigned long ul1 = numeric_limits<unsigned long>::max(); | |
41 | ||
42 | ss << L"-0"; | |
43 | err = ios_base::goodbit; | |
44 | end = ng.get(ss.rdbuf(), 0, ss, err, ul0); | |
45 | VERIFY( err == ios_base::eofbit ); | |
46 | VERIFY( ul0 == 0 ); | |
47 | ||
48 | ss.clear(); | |
49 | ss.str(empty); | |
50 | ss << L"-1"; | |
51 | err = ios_base::goodbit; | |
52 | end = ng.get(ss.rdbuf(), 0, ss, err, ul0); | |
53 | VERIFY( err == ios_base::eofbit ); | |
54 | VERIFY( ul0 == ul1 ); | |
55 | ||
56 | ss.clear(); | |
57 | ss.str(empty); | |
58 | ss << L'-' << ul1; | |
59 | err = ios_base::goodbit; | |
60 | end = ng.get(ss.rdbuf(), 0, ss, err, ul0); | |
61 | VERIFY( err == ios_base::eofbit ); | |
62 | VERIFY( ul0 == 1 ); | |
63 | ||
64 | ss.clear(); | |
65 | ss.str(empty); | |
66 | ss << L'-' << ul1 << L'0'; | |
67 | err = ios_base::goodbit; | |
68 | end = ng.get(ss.rdbuf(), 0, ss, err, ul0); | |
69 | VERIFY( err == (ios_base::eofbit | ios_base::failbit) ); | |
70 | VERIFY( ul0 == ul1 ); | |
71 | } | |
72 | ||
73 | int main() | |
74 | { | |
75 | test01(); | |
76 | return 0; | |
77 | } |