]>
git.ipfire.org Git - thirdparty/gcc.git/blob - libstdc++-v3/testsuite/22_locale/num_get/get/char/4.cc
1 // 2001-11-21 Benjamin Kosnik <bkoz@redhat.com>
3 // Copyright (C) 2001-2013 Free Software Foundation, Inc.
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
8 // Free Software Foundation; either version 3, or (at your option)
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.
16 // You should have received a copy of the GNU General Public License along
17 // with this library; see the file COPYING3. If not see
18 // <http://www.gnu.org/licenses/>.
20 // 22.2.2.1.1 num_get members
24 #include <testsuite_hooks.h>
26 // 2002-01-10 David Seymour <seymour_dj@yahoo.com>
31 bool test
__attribute__((unused
)) = true;
33 // Check num_get works with other iterators besides streambuf
34 // output iterators. (As long as output_iterator requirements are met.)
35 typedef string::const_iterator iter_type
;
36 typedef num_get
<char, iter_type
> num_get_type
;
37 const ios_base::iostate goodbit
= ios_base::goodbit
;
38 ios_base::iostate err
= ios_base::goodbit
;
39 const locale loc_c
= locale::classic();
40 const string
str("20000106 Elizabeth Durack");
41 const string
str2("0 true 0xbffff74c Durack");
43 istringstream iss
; // need an ios, add my num_get facet
44 iss
.imbue(locale(loc_c
, new num_get_type
));
46 // Iterator advanced, state, output.
47 const num_get_type
& ng
= use_facet
<num_get_type
>(iss
.getloc());
50 // 02 get(long double)
57 iter_type end1
= ng
.get(str
.begin(), str
.end(), iss
, err
, i
);
58 string
rem1(end1
, str
.end());
59 VERIFY( err
== goodbit
);
60 VERIFY( i
== 20000106);
61 VERIFY( rem1
== " Elizabeth Durack" );
63 // 02 get(long double)
66 iter_type end2
= ng
.get(str
.begin(), str
.end(), iss
, err
, ld
);
67 string
rem2(end2
, str
.end());
68 VERIFY( err
== goodbit
);
69 VERIFY( ld
== 20000106);
70 VERIFY( rem2
== " Elizabeth Durack" );
76 iter_type end3
= ng
.get(str2
.begin(), str2
.end(), iss
, err
, b
);
77 string
rem3(end3
, str2
.end());
78 VERIFY( err
== goodbit
);
80 VERIFY( rem3
== " true 0xbffff74c Durack" );
84 iss
.setf(ios_base::boolalpha
);
85 iter_type end4
= ng
.get(++end3
, str2
.end(), iss
, err
, b
);
86 string
rem4(end4
, str2
.end());
87 VERIFY( err
== goodbit
);
89 VERIFY( rem4
== " 0xbffff74c Durack" );
95 iss
.setf(ios_base::fixed
, ios_base::floatfield
);
96 iter_type end5
= ng
.get(++end4
, str2
.end(), iss
, err
, v
);
97 string
rem5(end5
, str2
.end());
98 VERIFY( err
== goodbit
);
100 VERIFY( rem5
== " Durack" );
110 // Kathleen Hannah, humanitarian, woman, art-thief