]>
git.ipfire.org Git - thirdparty/gcc.git/blob - libstdc++-v3/testsuite/22_locale/numpunct/members/pod/2.cc
1 // 2003-07-09 Benjamin Kosnik <bkoz@redhat.com>
3 // Copyright (C) 2003-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/>.
25 #include <testsuite_hooks.h>
26 #include <testsuite_character.h>
28 // Check for numpunct and ctype dependencies. Make sure that numpunct
29 // can be created without ctype.
33 using __gnu_test::pod_ushort
;
35 typedef numpunct
<pod_ushort
>::string_type string_type
;
36 typedef basic_ostringstream
<pod_ushort
> 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_ushort
>);
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(loc2
, new ctype
<pod_ushort
>);
82 // Formatted output fails as no numpunct.
86 catch(const bad_cast
& obj
)
93 const locale
loc4(loc3
, new numpunct
<pod_ushort
>);
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
)