1 // 2001-11-21 Benjamin Kosnik <bkoz@redhat.com>
3 // Copyright (C) 2001, 2002, 2003 Free Software Foundation
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 2, 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 COPYING. If not, write to the Free
18 // Software Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307,
21 // 22.2.2.1.1 num_get members
25 #include <testsuite_hooks.h>
27 // 2002-01-10 David Seymour <seymour_dj@yahoo.com>
32 bool test
__attribute__((unused
)) = true;
34 // Check num_get works with other iterators besides streambuf
35 // output iterators. (As long as output_iterator requirements are met.)
36 typedef wstring::const_iterator iter_type
;
37 typedef num_get
<wchar_t, iter_type
> num_get_type
;
38 const ios_base::iostate goodbit
= ios_base::goodbit
;
39 ios_base::iostate err
= ios_base::goodbit
;
40 const locale loc_c
= locale::classic();
41 const wstring
str(L
"20000106 Elizabeth Durack");
42 const wstring
str2(L
"0 true 0xbffff74c Durack");
44 wistringstream iss
; // need an ios, add my num_get facet
45 iss
.imbue(locale(loc_c
, new num_get_type
));
47 // Iterator advanced, state, output.
48 const num_get_type
& ng
= use_facet
<num_get_type
>(iss
.getloc());
51 // 02 get(long double)
58 iter_type end1
= ng
.get(str
.begin(), str
.end(), iss
, err
, i
);
59 wstring
rem1(end1
, str
.end());
60 VERIFY( err
== goodbit
);
61 VERIFY( i
== 20000106);
62 VERIFY( rem1
== L
" Elizabeth Durack" );
64 // 02 get(long double)
67 iter_type end2
= ng
.get(str
.begin(), str
.end(), iss
, err
, ld
);
68 wstring
rem2(end2
, str
.end());
69 VERIFY( err
== goodbit
);
70 VERIFY( ld
== 20000106);
71 VERIFY( rem2
== L
" Elizabeth Durack" );
77 iter_type end3
= ng
.get(str2
.begin(), str2
.end(), iss
, err
, b
);
78 wstring
rem3(end3
, str2
.end());
79 VERIFY( err
== goodbit
);
81 VERIFY( rem3
== L
" true 0xbffff74c Durack" );
85 iss
.setf(ios_base::boolalpha
);
86 iter_type end4
= ng
.get(++end3
, str2
.end(), iss
, err
, b
);
87 wstring
rem4(end4
, str2
.end());
88 VERIFY( err
== goodbit
);
90 VERIFY( rem4
== L
" 0xbffff74c Durack" );
96 iss
.setf(ios_base::fixed
, ios_base::floatfield
);
97 iter_type end5
= ng
.get(++end4
, str2
.end(), iss
, err
, v
);
98 wstring
rem5(end5
, str2
.end());
99 VERIFY( err
== goodbit
);
101 VERIFY( rem5
== L
" Durack" );
111 // Kathleen Hannah, humanitarian, woman, art-thief