OpenCores
URL https://opencores.org/ocsvn/scarts/scarts/trunk

Subversion Repositories scarts

[/] [scarts/] [trunk/] [toolchain/] [scarts-gcc/] [gcc-4.1.1/] [libstdc++-v3/] [testsuite/] [22_locale/] [locale/] [cons/] [7.cc] - Blame information for rev 19

Details | Compare with Previous | View Log

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

powered by: WebSVN 2.1.0

© copyright 1999-2024 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.