]> git.ipfire.org Git - thirdparty/gcc.git/blame - libstdc++-v3/testsuite/22_locale/num_get/get/char/13.cc
Update copyright years.
[thirdparty/gcc.git] / libstdc++-v3 / testsuite / 22_locale / num_get / get / char / 13.cc
CommitLineData
a27cf81c
PC
1// 2003-12-30 Paolo Carlini <pcarlini@suse.de>
2
a945c346 3// Copyright (C) 2003-2024 Free Software Foundation, Inc.
a27cf81c
PC
4//
5// This file is part of the GNU ISO C++ Library. This library is free
6// software; you can redistribute it and/or modify it under the
7// terms of the GNU General Public License as published by the
748086b7 8// Free Software Foundation; either version 3, or (at your option)
a27cf81c
PC
9// any later version.
10
11// This library is distributed in the hope that it will be useful,
12// but WITHOUT ANY WARRANTY; without even the implied warranty of
13// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14// GNU General Public License for more details.
15
16// You should have received a copy of the GNU General Public License along
748086b7
JJ
17// with this library; see the file COPYING3. If not see
18// <http://www.gnu.org/licenses/>.
a27cf81c
PC
19
20// 22.2.2.1.1 num_get members
21
22#include <locale>
23#include <sstream>
24#include <testsuite_hooks.h>
25
26struct Punct1: std::numpunct<char>
27{ std::string do_grouping() const { return "\003\002\001"; } };
28
29struct Punct2: std::numpunct<char>
30{ std::string do_grouping() const { return "\001\003"; } };
31
32// libstdc++/13369
33void test01()
34{
35 using namespace std;
36 typedef istreambuf_iterator<char> iterator_type;
a27cf81c
PC
37
38 istringstream iss1, iss2;
28f2a265
PC
39 iss1.imbue(locale(iss1.getloc(), new Punct1));
40 iss2.imbue(locale(iss2.getloc(), new Punct2));
a27cf81c
PC
41 const num_get<char>& ng1 = use_facet<num_get<char> >(iss1.getloc());
42 const num_get<char>& ng2 = use_facet<num_get<char> >(iss2.getloc());
43
44 ios_base::iostate err = ios_base::goodbit;
45 iterator_type end;
46 long l = 0l;
47 long l1 = 12345678l;
48 double d = 0.0;
49 double d1 = 1234567.0;
50 double d2 = 123456.0;
51
52 iss1.str("1,2,3,45,678");
53 err = ios_base::goodbit;
54 end = ng1.get(iss1.rdbuf(), 0, iss1, err, l);
55 VERIFY( err == ios_base::eofbit );
56 VERIFY( l == l1 );
57
58 iss2.str("123,456,7.0");
59 err = ios_base::goodbit;
60 end = ng2.get(iss2.rdbuf(), 0, iss2, err, d);
61 VERIFY( err == ios_base::eofbit );
62 VERIFY( d == d1 );
63
64 iss2.str("12,345,6.0");
65 iss2.clear();
66 err = ios_base::goodbit;
67 end = ng2.get(iss2.rdbuf(), 0, iss2, err, d);
68 VERIFY( err == ios_base::eofbit );
69 VERIFY( d == d2 );
70}
71
72int main()
73{
74 test01();
75 return 0;
76}