]> git.ipfire.org Git - thirdparty/gcc.git/blame - libstdc++-v3/testsuite/22_locale/num_get/get/char/11.cc
locale_facets.tcc (num_get::_M_extract_int, [...]): According to 22.2.2.1.2, p8-9...
[thirdparty/gcc.git] / libstdc++-v3 / testsuite / 22_locale / num_get / get / char / 11.cc
CommitLineData
cc16f8b9
PC
1// Copyright (C) 2003 Free Software Foundation
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 2, 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 COPYING. If not, write to the Free
16// Software Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307,
17// USA.
18
19// 22.2.2.1.1 num_get members
20
21#include <locale>
22#include <sstream>
23#include <testsuite_hooks.h>
24
25struct Punct: std::numpunct<char>
26{
27 std::string do_grouping() const { return "\1"; }
28 char do_thousands_sep() const { return '2'; }
29 char do_decimal_point() const { return '4'; }
30};
31
32void test01()
33{
34 using namespace std;
35 typedef istreambuf_iterator<char> iterator_type;
36
37 bool test __attribute__((unused)) = true;
38
39 istringstream iss;
40 iss.imbue(locale(iss.getloc(), static_cast<numpunct<char>*>(new Punct)));
41 const num_get<char>& ng = use_facet<num_get<char> >(iss.getloc());
42 ios_base::iostate err = ios_base::goodbit;
43 iterator_type end;
44 double d = 0.0;
45 double d1 = 13.0;
46 long l = 0l;
47 long l1 = 13l;
48
49 iss.str("1234");
50 err = ios_base::goodbit;
51 end = ng.get(iss.rdbuf(), 0, iss, err, d);
52 VERIFY( err == ios_base::eofbit );
53 VERIFY( d == d1 );
54
55 iss.str("1234");
56 iss.clear();
57 err = ios_base::goodbit;
58 end = ng.get(iss.rdbuf(), 0, iss, err, l);
59 VERIFY( err == ios_base::goodbit );
60 VERIFY( l == l1 );
61}
62
63
64int main()
65{
66 test01();
67 return 0;
68}