]>
git.ipfire.org Git - thirdparty/gcc.git/blob - libstdc++-v3/testsuite/22_locale/num_get/get/wchar_t/11.cc
1 // Copyright (C) 2003-2021 Free Software Foundation, Inc.
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)
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
22 #include <testsuite_hooks.h>
24 struct Punct1
: std::numpunct
<wchar_t>
26 std::string
do_grouping() const { return "\1"; }
27 wchar_t do_thousands_sep() const { return L
'2'; }
28 wchar_t do_decimal_point() const { return L
'4'; }
31 struct Punct2
: std::numpunct
<wchar_t>
33 std::string
do_grouping() const { return "\1"; }
34 wchar_t do_thousands_sep() const { return L
'2'; }
35 wchar_t do_decimal_point() const { return L
'2'; }
38 // http://gcc.gnu.org/ml/libstdc++/2003-12/msg00201.html
42 typedef istreambuf_iterator
<wchar_t> iterator_type
;
44 wistringstream iss1
, iss2
;
45 iss1
.imbue(locale(iss1
.getloc(), new Punct1
));
46 iss2
.imbue(locale(iss2
.getloc(), new Punct2
));
47 const num_get
<wchar_t>& ng1
= use_facet
<num_get
<wchar_t> >(iss1
.getloc());
48 const num_get
<wchar_t>& ng2
= use_facet
<num_get
<wchar_t> >(iss2
.getloc());
50 ios_base::iostate err
= ios_base::goodbit
;
61 err
= ios_base::goodbit
;
62 end
= ng1
.get(iss1
.rdbuf(), 0, iss1
, err
, d
);
63 VERIFY( err
== ios_base::eofbit
);
68 err
= ios_base::goodbit
;
69 end
= ng1
.get(iss1
.rdbuf(), 0, iss1
, err
, d
);
70 VERIFY( err
== ios_base::goodbit
);
75 err
= ios_base::goodbit
;
76 end
= ng1
.get(iss1
.rdbuf(), 0, iss1
, err
, d
);
77 VERIFY( err
== ios_base::goodbit
);
82 err
= ios_base::goodbit
;
83 end
= ng1
.get(iss1
.rdbuf(), 0, iss1
, err
, l
);
84 VERIFY( err
== ios_base::goodbit
);
88 err
= ios_base::goodbit
;
89 end
= ng2
.get(iss2
.rdbuf(), 0, iss2
, err
, d
);
90 VERIFY( err
== ios_base::eofbit
);
95 err
= ios_base::goodbit
;
96 end
= ng2
.get(iss2
.rdbuf(), 0, iss2
, err
, l
);
97 VERIFY( err
== ios_base::eofbit
);