2003-12-26 Guilhem Lavaux <guilhem@kaffe.org>
[official-gcc.git] / libstdc++-v3 / testsuite / 22_locale / moneypunct / members / char / 1.cc
blob7c8ca599f62577fa3a1f15bc93b9c980a6f07da8
1 // 2001-08-23 Benjamin Kosnik <bkoz@redhat.com>
3 // Copyright (C) 2001, 2002, 2003 Free Software Foundation
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.
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 COPYING. If not, write to the Free
18 // Software Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307,
19 // USA.
21 // 22.2.6.3.1 moneypunct members
23 #include <locale>
24 #include <string>
25 #include <testsuite_hooks.h>
27 void test01()
29 using namespace std;
30 typedef money_base::part part;
31 typedef money_base::pattern pattern;
33 bool test __attribute__((unused)) = true;
35 // basic construction
36 locale loc_c = locale::classic();
38 // cache the moneypunct facets
39 typedef moneypunct<char, true> __money_true;
40 typedef moneypunct<char, false> __money_false;
41 const __money_true& monp_c_t = use_facet<__money_true>(loc_c);
42 const __money_false& monp_c_f = use_facet<__money_false>(loc_c);
44 // quick sanity check for data.
45 char q1 = monp_c_t.decimal_point();
46 char q2 = monp_c_t.thousands_sep();
47 char q3 = monp_c_f.decimal_point();
48 char q4 = monp_c_f.thousands_sep();
49 string g1 = monp_c_t.grouping();
50 string g2 = monp_c_f.grouping();
51 string cs1 = monp_c_t.curr_symbol();
52 string cs2 = monp_c_f.curr_symbol();
53 string ps1 = monp_c_t.positive_sign();
54 string ns1 = monp_c_t.negative_sign();
55 string ps2 = monp_c_f.positive_sign();
56 string ns2 = monp_c_f.negative_sign();
57 int fd1 = monp_c_t.frac_digits();
58 int fd2 = monp_c_f.frac_digits();
59 pattern pos1 = monp_c_t.pos_format();
60 pattern neg1 = monp_c_t.neg_format();
61 pattern pos2 = monp_c_f.pos_format();
62 pattern neg2 = monp_c_f.neg_format();
64 VERIFY( q1 == '.' );
65 VERIFY( q3 == '.' );
66 VERIFY( q2 == ',' );
67 VERIFY( q4 == ',' );
68 VERIFY( g1 == "" );
69 VERIFY( g2 == "" );
70 VERIFY( cs1 == "" );
71 VERIFY( cs2 == "" );
72 VERIFY( ps1 == "" );
73 VERIFY( ps2 == "" );
74 VERIFY( ns1 == "" );
75 VERIFY( ns2 == "" );
76 VERIFY( fd1 == 0 );
77 VERIFY( fd2 == 0 );
79 VERIFY(static_cast<part>(pos1.field[0]) == static_cast<part>(pos2.field[0]));
80 VERIFY(static_cast<part>(pos1.field[1]) == static_cast<part>(pos2.field[1]));
81 VERIFY(static_cast<part>(pos1.field[2]) == static_cast<part>(pos2.field[2]));
82 VERIFY(static_cast<part>(pos1.field[3]) == static_cast<part>(pos2.field[3]));
84 #if 0
85 VERIFY( pos1[0] == money_base::_S_default_pattern[0] );
86 VERIFY( pos1[1] == money_base::_S_default_pattern[1] );
87 VERIFY( pos1[2] == money_base::_S_default_pattern[2] );
88 VERIFY( pos1[3] == money_base::_S_default_pattern[3] );
89 VERIFY( pos2 == money_base::_S_default_pattern );
90 VERIFY( neg1 == money_base::_S_default_pattern );
91 VERIFY( neg2 == money_base::_S_default_pattern );
92 #endif
95 int main()
97 test01();
98 return 0;