]>
Commit | Line | Data |
---|---|---|
0214010c BK |
1 | // 2001-01-19 Benjamin Kosnik <bkoz@redhat.com> |
2 | ||
5f8d36fe | 3 | // Copyright (C) 2001, 2003 Free Software Foundation |
0214010c 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 | |
8 | // Free Software Foundation; either version 2, or (at your option) | |
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 | |
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, | |
19 | // USA. | |
20 | ||
5f8d36fe | 21 | // 22.1.1 - Class locale [lib.locale] |
0214010c BK |
22 | |
23 | #include <locale> | |
24 | #include <string> | |
fe413112 | 25 | #include <testsuite_hooks.h> |
0214010c | 26 | |
0214010c BK |
27 | void |
28 | test02() | |
29 | { | |
30 | using namespace std; | |
11f10e6b | 31 | bool test __attribute__((unused)) = true; |
0214010c BK |
32 | const string name_c("C"); |
33 | const string name_no("*"); | |
34 | string str; | |
35 | ||
36 | // construct a locale object with the specialized facet. | |
37 | locale loc_c = locale::classic(); | |
aecf642c | 38 | locale loc_fr = __gnu_test::try_named_locale("fr_FR"); |
0214010c BK |
39 | locale loc_1(locale::classic(), |
40 | new numpunct_byname<char>("fr_FR")); | |
0214010c BK |
41 | |
42 | // check names | |
43 | VERIFY( loc_c.name() == name_c ); | |
44 | VERIFY( loc_1.name() == name_no ); | |
45 | ||
46 | // sanity check the constructed locale has the specialized facet. | |
47 | VERIFY( has_facet<numpunct<char> >(loc_1) ); | |
48 | VERIFY( has_facet<numpunct<char> >(loc_c) ); | |
49 | ||
50 | // attempt to re-synthesize classic locale | |
51 | locale loc_2 = loc_1.combine<numpunct<char> >(loc_c); | |
52 | VERIFY( loc_2.name() == name_no ); | |
53 | VERIFY( loc_2 != loc_c ); | |
54 | ||
55 | // extract facet | |
13f83598 BK |
56 | const numpunct<char>& nump_1 = use_facet<numpunct<char> >(loc_1); |
57 | const numpunct<char>& nump_2 = use_facet<numpunct<char> >(loc_2); | |
58 | const numpunct<char>& nump_c = use_facet<numpunct<char> >(loc_c); | |
59 | const numpunct<char>& nump_fr = use_facet<numpunct<char> >(loc_fr); | |
0214010c BK |
60 | |
61 | // sanity check the data is correct. | |
13f83598 BK |
62 | char dp1 = nump_c.decimal_point(); |
63 | char th1 = nump_c.thousands_sep(); | |
64 | string g1 = nump_c.grouping(); | |
65 | string t1 = nump_c.truename(); | |
66 | string f1 = nump_c.falsename(); | |
67 | ||
68 | char dp2 = nump_1.decimal_point(); | |
69 | char th2 = nump_1.thousands_sep(); | |
70 | string g2 = nump_1.grouping(); | |
71 | string t2 = nump_1.truename(); | |
72 | string f2 = nump_1.falsename(); | |
73 | ||
74 | char dp3 = nump_2.decimal_point(); | |
75 | char th3 = nump_2.thousands_sep(); | |
76 | string g3 = nump_2.grouping(); | |
77 | string t3 = nump_2.truename(); | |
78 | string f3 = nump_2.falsename(); | |
79 | ||
80 | char dp4 = nump_fr.decimal_point(); | |
81 | char th4 = nump_fr.thousands_sep(); | |
82 | string g4 = nump_fr.grouping(); | |
83 | string t4 = nump_fr.truename(); | |
84 | string f4 = nump_fr.falsename(); | |
0214010c BK |
85 | VERIFY( dp1 != dp2 ); |
86 | VERIFY( th1 != th2 ); | |
0214010c BK |
87 | |
88 | VERIFY( dp1 == dp3 ); | |
89 | VERIFY( th1 == th3 ); | |
90 | VERIFY( t1 == t3 ); | |
91 | VERIFY( f1 == f3 ); | |
13f83598 BK |
92 | |
93 | VERIFY( dp2 == dp4 ); | |
94 | VERIFY( th2 == th4 ); | |
95 | VERIFY( t2 == t4 ); | |
96 | VERIFY( f2 == f4 ); | |
0214010c BK |
97 | } |
98 | ||
99 | ||
100 | int main() | |
101 | { | |
3d838e28 | 102 | test02(); |
0214010c BK |
103 | return 0; |
104 | } |