]>
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, 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>
34 // Check num_get works with other iterators besides streambuf
35 // output iterators. (As long as output_iterator requirements are met.)
36 typedef string::const_iterator iter_type
;
37 typedef num_get
<char, iter_type
> num_get_type
;
38 const ios_base::iostate goodbit
= ios_base::goodbit
;
39 const ios_base::iostate eofbit
= ios_base::eofbit
;
40 ios_base::iostate err
= ios_base::goodbit
;
41 const locale loc_c
= locale::classic();
42 const string
str("20000106 Elizabeth Durack");
43 const string
str2("0 true 0xbffff74c Durack");
45 istringstream iss
; // need an ios, add my num_get facet
46 iss
.imbue(locale(loc_c
, new num_get_type
));
48 // Iterator advanced, state, output.
49 const num_get_type
& ng
= use_facet
<num_get_type
>(iss
.getloc());
52 // 02 get(long double)
59 iter_type end1
= ng
.get(str
.begin(), str
.end(), iss
, err
, i
);
60 string
rem1(end1
, str
.end());
61 VERIFY( err
== goodbit
);
62 VERIFY( i
== 20000106);
63 VERIFY( rem1
== " Elizabeth Durack" );
65 // 02 get(long double)
68 iter_type end2
= ng
.get(str
.begin(), str
.end(), iss
, err
, ld
);
69 string
rem2(end2
, str
.end());
70 VERIFY( err
== goodbit
);
71 VERIFY( ld
== 20000106);
72 VERIFY( rem2
== " Elizabeth Durack" );
78 iter_type end3
= ng
.get(str2
.begin(), str2
.end(), iss
, err
, b
);
79 string
rem3(end3
, str2
.end());
80 VERIFY( err
== goodbit
);
82 VERIFY( rem3
== " true 0xbffff74c Durack" );
86 iss
.setf(ios_base::boolalpha
);
87 iter_type end4
= ng
.get(++end3
, str2
.end(), iss
, err
, b
);
88 string
rem4(end4
, str2
.end());
89 VERIFY( err
== goodbit
);
91 VERIFY( rem4
== " 0xbffff74c Durack" );
97 iss
.setf(ios_base::fixed
, ios_base::floatfield
);
98 iter_type end5
= ng
.get(++end4
, str2
.end(), iss
, err
, v
);
99 string
rem5(end5
, str2
.end());
100 VERIFY( err
== goodbit
);
102 VERIFY( rem5
== " Durack" );
112 // Kathleen Hannah, humanitarian, woman, art-thief