]>
Commit | Line | Data |
---|---|---|
7adcbafe | 1 | // Copyright (C) 2009-2022 Free Software Foundation, Inc. |
2daad65e PC |
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; | |
2daad65e PC |
30 | |
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; | |
36 | ||
37 | unsigned long ul0 = 1; | |
38 | const unsigned long ul1 = numeric_limits<unsigned long>::max(); | |
39 | ||
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 ); | |
45 | ||
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 ); | |
53 | ||
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 ); | |
61 | ||
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 ); | |
69 | } | |
70 | ||
71 | int main() | |
72 | { | |
73 | test01(); | |
74 | return 0; | |
75 | } |