]>
Commit | Line | Data |
---|---|---|
cde63840 BK |
1 | // 2003-07-09 Benjamin Kosnik <bkoz@redhat.com> |
2 | ||
748086b7 | 3 | // Copyright (C) 2003, 2005, 2009 Free Software Foundation, Inc. |
cde63840 BK |
4 | // |
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 | |
748086b7 | 8 | // Free Software Foundation; either version 3, or (at your option) |
cde63840 BK |
9 | // any later version. |
10 | ||
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. | |
15 | ||
16 | // You should have received a copy of the GNU General Public License along | |
748086b7 JJ |
17 | // with this library; see the file COPYING3. If not see |
18 | // <http://www.gnu.org/licenses/>. | |
cde63840 BK |
19 | |
20 | #include <locale> | |
21 | #include <sstream> | |
22 | #include <ostream> | |
23 | #include <stdexcept> | |
cde63840 | 24 | #include <testsuite_hooks.h> |
5305b1ae | 25 | #include <testsuite_character.h> |
cde63840 BK |
26 | |
27 | // Check for numpunct and ctype dependencies. Make sure that numpunct | |
28 | // can be created without ctype. | |
29 | void test01() | |
30 | { | |
31 | using namespace std; | |
821503db BK |
32 | using __gnu_test::pod_ushort; |
33 | typedef pod_ushort::value_type value_type; | |
34 | typedef numpunct<pod_ushort>::string_type string_type; | |
35 | typedef basic_stringbuf<pod_ushort> stringbuf_type; | |
36 | typedef basic_ostream<pod_ushort> ostream_type; | |
cde63840 | 37 | |
11f10e6b | 38 | bool test __attribute__((unused)) = true; |
cde63840 BK |
39 | |
40 | // Pre-cache sanity check. | |
821503db BK |
41 | const locale loc(locale::classic(), new numpunct<pod_ushort>); |
42 | const numpunct<pod_ushort>& np = use_facet<numpunct<pod_ushort> >(loc); | |
cde63840 | 43 | |
821503db BK |
44 | pod_ushort dp = np.decimal_point(); |
45 | pod_ushort ts = np.thousands_sep(); | |
cde63840 BK |
46 | string g = np.grouping(); |
47 | string_type strue = np.truename(); | |
48 | string_type sfalse = np.falsename(); | |
49 | ||
821503db BK |
50 | pod_ushort basedp = { value_type('.') }; |
51 | pod_ushort basets = { value_type(',') }; | |
cde63840 | 52 | |
821503db | 53 | string_type basetrue(4, pod_ushort()); |
cde63840 BK |
54 | basetrue[0].value = value_type('t'); |
55 | basetrue[1].value = value_type('r'); | |
56 | basetrue[2].value = value_type('u'); | |
57 | basetrue[3].value = value_type('e'); | |
58 | ||
821503db | 59 | string_type basefalse(5, pod_ushort()); |
cde63840 BK |
60 | basefalse[0].value = value_type('f'); |
61 | basefalse[1].value = value_type('a'); | |
62 | basefalse[2].value = value_type('l'); | |
63 | basefalse[3].value = value_type('s'); | |
64 | basefalse[4].value = value_type('e'); | |
65 | ||
821503db BK |
66 | VERIFY( char_traits<pod_ushort>::eq(dp, basedp) ); |
67 | VERIFY( char_traits<pod_ushort>::eq(ts, basets) ); | |
cde63840 BK |
68 | VERIFY( g == "" ); |
69 | VERIFY( strue == basetrue ); | |
70 | VERIFY( sfalse == basefalse ); | |
71 | } | |
72 | ||
73 | int main() | |
74 | { | |
75 | test01(); | |
76 | return 0; | |
77 | } |