]> git.ipfire.org Git - thirdparty/gcc.git/blob - libstdc++-v3/testsuite/22_locale/moneypunct/members/wchar_t/1.cc
744c46d13a2a7ad604094cbff06c2ed105e520dc
[thirdparty/gcc.git] / libstdc++-v3 / testsuite / 22_locale / moneypunct / members / wchar_t / 1.cc
1 // 2001-08-23 Benjamin Kosnik <bkoz@redhat.com>
2
3 // Copyright (C) 2001-2014 Free Software Foundation, Inc.
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 3, 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 COPYING3. If not see
18 // <http://www.gnu.org/licenses/>.
19
20 // 22.2.6.3.1 moneypunct members
21
22 #include <locale>
23 #include <string>
24 #include <testsuite_hooks.h>
25
26 void test01()
27 {
28 using namespace std;
29 typedef money_base::part part;
30 typedef money_base::pattern pattern;
31
32 bool test __attribute__((unused)) = true;
33
34 // basic construction
35 locale loc_c = locale::classic();
36
37 // cache the moneypunct facets
38 typedef moneypunct<wchar_t, true> __money_true;
39 typedef moneypunct<wchar_t, false> __money_false;
40 const __money_true& monp_c_t = use_facet<__money_true>(loc_c);
41 const __money_false& monp_c_f = use_facet<__money_false>(loc_c);
42
43 // quick sanity check for data.
44 wchar_t q1 = monp_c_t.decimal_point();
45 wchar_t q2 = monp_c_t.thousands_sep();
46 wchar_t q3 = monp_c_f.decimal_point();
47 wchar_t q4 = monp_c_f.thousands_sep();
48 string g1 = monp_c_t.grouping();
49 string g2 = monp_c_f.grouping();
50 wstring cs1 = monp_c_t.curr_symbol();
51 wstring cs2 = monp_c_f.curr_symbol();
52 wstring ps1 = monp_c_t.positive_sign();
53 wstring ns1 = monp_c_t.negative_sign();
54 wstring ps2 = monp_c_f.positive_sign();
55 wstring ns2 = monp_c_f.negative_sign();
56 int fd1 = monp_c_t.frac_digits();
57 int fd2 = monp_c_f.frac_digits();
58 pattern pos1 = monp_c_t.pos_format();
59 pattern neg1 = monp_c_t.neg_format();
60 pattern pos2 = monp_c_f.pos_format();
61 pattern neg2 = monp_c_f.neg_format();
62 neg1 = neg1;
63 neg2 = neg2;
64
65 VERIFY( q1 == L'.' );
66 VERIFY( q3 == L'.' );
67 VERIFY( q2 == L',' );
68 VERIFY( q4 == L',' );
69 VERIFY( g1 == "" );
70 VERIFY( g2 == "" );
71 VERIFY( cs1 == L"" );
72 VERIFY( cs2 == L"" );
73 VERIFY( ps1 == L"" );
74 VERIFY( ps2 == L"" );
75 VERIFY( ns1 == L"" );
76 VERIFY( ns2 == L"" );
77 VERIFY( fd1 == 0 );
78 VERIFY( fd2 == 0 );
79
80 VERIFY(static_cast<part>(pos1.field[0]) == static_cast<part>(pos2.field[0]));
81 VERIFY(static_cast<part>(pos1.field[1]) == static_cast<part>(pos2.field[1]));
82 VERIFY(static_cast<part>(pos1.field[2]) == static_cast<part>(pos2.field[2]));
83 VERIFY(static_cast<part>(pos1.field[3]) == static_cast<part>(pos2.field[3]));
84
85 #if 0
86 VERIFY( pos1[0] == money_base::_S_default_pattern[0] );
87 VERIFY( pos1[1] == money_base::_S_default_pattern[1] );
88 VERIFY( pos1[2] == money_base::_S_default_pattern[2] );
89 VERIFY( pos1[3] == money_base::_S_default_pattern[3] );
90 VERIFY( pos2 == money_base::_S_default_pattern );
91 VERIFY( neg1 == money_base::_S_default_pattern );
92 VERIFY( neg2 == money_base::_S_default_pattern );
93 #endif
94 }
95
96 int main()
97 {
98 test01();
99 return 0;
100 }