1 // Copyright (C) 2004 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 2, 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 COPYING. If not, write to the Free
16 // Software Foundation, 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301,
19 // 27.6.1.2.2 arithmetic extractors
21 #include <cstdio> // for printf
25 #include <testsuite_hooks.h>
28 std::wstring
str_02(L
"true false 0 1 110001");
29 std::wstring
str_03(L
"-19999999 777777 -234234 233 -234 33 1 66300.25 .315 1.5");
30 std::wstring
str_04(L
"0123");
32 std::wstringbuf
isbuf_01(std::ios_base::in
);
33 std::wstringbuf
isbuf_02(str_02
, std::ios_base::in
);
34 std::wstringbuf
isbuf_03(str_03
, std::ios_base::in
);
35 std::wstringbuf
isbuf_04(str_04
, std::ios_base::in
);
37 std::wistream
is_01(NULL
);
38 std::wistream
is_02(&isbuf_02
);
39 std::wistream
is_03(&isbuf_03
);
40 std::wistream
is_04(&isbuf_04
);
41 std::wstringstream
ss_01(str_01
);
43 // minimal sanity check
46 bool test
__attribute__((unused
)) = true;
53 unsigned short us1
= 0;
55 unsigned long ul1
= 0;
57 // Floating-point Types:
62 // process alphanumeric versions of bool values
63 std::ios_base::fmtflags fmt
= is_02
.flags();
64 bool testfmt
= fmt
& std::ios_base::boolalpha
;
65 is_02
.setf(std::ios_base::boolalpha
);
67 testfmt
= fmt
& std::ios_base::boolalpha
;
73 // process numeric versions of of bool values
74 is_02
.unsetf(std::ios_base::boolalpha
);
76 testfmt
= fmt
& std::ios_base::boolalpha
;
82 // is_03 == "-19999999 777777 -234234 233 -234 33 1 66300.25 .315 1.5"
84 VERIFY( l1
== -19999999 );
86 VERIFY( ul1
== 777777 );
88 VERIFY( i1
== -234234 );
98 VERIFY( ld1
== 66300.25 );
100 VERIFY( d1
== .315 );
104 is_04
>> std::hex
>> i1
;
105 std::printf ("%d %d %d\n", i1
, i1
== 0x123, test
);
106 VERIFY( i1
== 0x123 );
107 std::printf ("%d %d %d\n", i1
, i1
== 0x123, test
);
109 // test void pointers
116 std::printf ("%p %p\n", pi
, po
);