]>
Commit | Line | Data |
---|---|---|
be803e41 | 1 | // { dg-require-namedlocale "is_IS.ISO8859-1" } |
e590fca1 | 2 | |
20752884 | 3 | // 2001-01-19 Benjamin Kosnik <bkoz@redhat.com> |
4 | ||
f1717362 | 5 | // Copyright (C) 2001-2016 Free Software Foundation, Inc. |
20752884 | 6 | // |
7 | // This file is part of the GNU ISO C++ Library. This library is free | |
8 | // software; you can redistribute it and/or modify it under the | |
9 | // terms of the GNU General Public License as published by the | |
6bc9506f | 10 | // Free Software Foundation; either version 3, or (at your option) |
20752884 | 11 | // any later version. |
12 | ||
13 | // This library is distributed in the hope that it will be useful, | |
14 | // but WITHOUT ANY WARRANTY; without even the implied warranty of | |
15 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
16 | // GNU General Public License for more details. | |
17 | ||
18 | // You should have received a copy of the GNU General Public License along | |
6bc9506f | 19 | // with this library; see the file COPYING3. If not see |
20 | // <http://www.gnu.org/licenses/>. | |
20752884 | 21 | |
2f14cd74 | 22 | // 22.1.1 - Class locale [lib.locale] |
20752884 | 23 | |
24 | #include <locale> | |
25 | #include <string> | |
0194306c | 26 | #include <testsuite_hooks.h> |
20752884 | 27 | |
20752884 | 28 | void |
29 | test02() | |
30 | { | |
31 | using namespace std; | |
f8ef786c | 32 | bool test __attribute__((unused)) = true; |
20752884 | 33 | const string name_c("C"); |
34 | const string name_no("*"); | |
35 | string str; | |
36 | ||
37 | // construct a locale object with the specialized facet. | |
38 | locale loc_c = locale::classic(); | |
be803e41 | 39 | locale loc_is = locale(ISO_8859(1,is_IS)); |
20752884 | 40 | locale loc_1(locale::classic(), |
be803e41 | 41 | new numpunct_byname<char>(ISO_8859(1,is_IS))); |
20752884 | 42 | |
43 | // check names | |
44 | VERIFY( loc_c.name() == name_c ); | |
45 | VERIFY( loc_1.name() == name_no ); | |
46 | ||
47 | // sanity check the constructed locale has the specialized facet. | |
48 | VERIFY( has_facet<numpunct<char> >(loc_1) ); | |
49 | VERIFY( has_facet<numpunct<char> >(loc_c) ); | |
50 | ||
51 | // attempt to re-synthesize classic locale | |
52 | locale loc_2 = loc_1.combine<numpunct<char> >(loc_c); | |
53 | VERIFY( loc_2.name() == name_no ); | |
54 | VERIFY( loc_2 != loc_c ); | |
55 | ||
56 | // extract facet | |
23e98236 | 57 | const numpunct<char>& nump_1 = use_facet<numpunct<char> >(loc_1); |
58 | const numpunct<char>& nump_2 = use_facet<numpunct<char> >(loc_2); | |
59 | const numpunct<char>& nump_c = use_facet<numpunct<char> >(loc_c); | |
e4a59e8f | 60 | const numpunct<char>& nump_is = use_facet<numpunct<char> >(loc_is); |
20752884 | 61 | |
62 | // sanity check the data is correct. | |
23e98236 | 63 | char dp1 = nump_c.decimal_point(); |
64 | char th1 = nump_c.thousands_sep(); | |
65 | string g1 = nump_c.grouping(); | |
66 | string t1 = nump_c.truename(); | |
67 | string f1 = nump_c.falsename(); | |
68 | ||
69 | char dp2 = nump_1.decimal_point(); | |
70 | char th2 = nump_1.thousands_sep(); | |
71 | string g2 = nump_1.grouping(); | |
72 | string t2 = nump_1.truename(); | |
73 | string f2 = nump_1.falsename(); | |
74 | ||
75 | char dp3 = nump_2.decimal_point(); | |
76 | char th3 = nump_2.thousands_sep(); | |
77 | string g3 = nump_2.grouping(); | |
78 | string t3 = nump_2.truename(); | |
79 | string f3 = nump_2.falsename(); | |
80 | ||
e4a59e8f | 81 | char dp4 = nump_is.decimal_point(); |
82 | char th4 = nump_is.thousands_sep(); | |
83 | string g4 = nump_is.grouping(); | |
84 | string t4 = nump_is.truename(); | |
85 | string f4 = nump_is.falsename(); | |
20752884 | 86 | VERIFY( dp1 != dp2 ); |
87 | VERIFY( th1 != th2 ); | |
20752884 | 88 | |
89 | VERIFY( dp1 == dp3 ); | |
90 | VERIFY( th1 == th3 ); | |
91 | VERIFY( t1 == t3 ); | |
92 | VERIFY( f1 == f3 ); | |
23e98236 | 93 | |
94 | VERIFY( dp2 == dp4 ); | |
95 | VERIFY( th2 == th4 ); | |
96 | VERIFY( t2 == t4 ); | |
97 | VERIFY( f2 == f4 ); | |
20752884 | 98 | } |
99 | ||
100 | ||
101 | int main() | |
102 | { | |
3eb7dfb2 | 103 | test02(); |
20752884 | 104 | return 0; |
105 | } |