Reverting merge from trunk
[official-gcc.git] / libstdc++-v3 / testsuite / 22_locale / num_get / get / char / 39802.cc
blob3f65e6bbf8c7b62b29d31162d2174c4acc69d647
1 // Copyright (C) 2009-2013 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<char> iterator_type;
31 bool test __attribute__((unused)) = true;
33 stringstream ss;
34 const num_get<char>& ng = use_facet<num_get<char> >(ss.getloc());
35 ios_base::iostate err;
36 iterator_type end;
37 const string empty;
39 unsigned long ul0 = 1;
40 const unsigned long ul1 = numeric_limits<unsigned long>::max();
42 ss << "-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 );
48 ss.clear();
49 ss.str(empty);
50 ss << "-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 );
56 ss.clear();
57 ss.str(empty);
58 ss << '-' << 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 );
64 ss.clear();
65 ss.str(empty);
66 ss << '-' << ul1 << '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 );
73 int main()
75 test01();
76 return 0;