1 // 2003-07-09 Benjamin Kosnik <bkoz@redhat.com>
3 // Copyright (C) 2003 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 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,
25 #include <ext/pod_char_traits.h>
26 #include <testsuite_hooks.h>
28 // Check for numpunct and ctype dependencies. Make sure that numpunct
29 // can be created without ctype.
33 using __gnu_test::pod_type
;
35 typedef numpunct
<pod_type
>::string_type string_type
;
36 typedef basic_ostringstream
<pod_type
> ostream_type
;
40 // Test formatted output.
42 const locale loc
= locale::classic();
44 os
.setf(ios_base::boolalpha
);
45 os
.exceptions(ios_base::badbit
);
47 // 1: fail, no num_put.
50 // Calls to num_put.put will fail, as there's no num_put facet.
54 catch(const bad_cast
& obj
)
61 const locale
loc2(loc
, new num_put
<pod_type
>);
66 // Calls to ctype.widen will fail, as there's no ctype facet.
70 catch(const bad_cast
& obj
)
76 // 3: fail, no numpunct
77 const locale
loc3(loc
, new ctype
<pod_type
>);
82 // Formatted output fails as no numpunct.
86 catch(const bad_cast
& obj
)
93 const locale
loc4(loc3
, new numpunct
<pod_type
>);
99 string_type s
= os
.str();
100 VERIFY( s
.length() == 3 );
102 VERIFY( os
.narrow(s
[0], char()) == '5' );
103 VERIFY( os
.narrow(s
[1], char()) == '0' );
104 VERIFY( os
.narrow(s
[2], char()) == '0' );
106 catch(const bad_cast
& obj
)