1 //===----------------------------------------------------------------------===//
2 //
3 // The LLVM Compiler Infrastructure
4 //
5 // This file is dual licensed under the MIT and the University of Illinois Open
6 // Source Licenses. See LICENSE.TXT for details.
7 //
8 //===----------------------------------------------------------------------===//
9
10 // REQUIRES: locale.en_US.UTF-8
11 // REQUIRES: locale.fr_FR.UTF-8
12 // REQUIRES: locale.ru_RU.UTF-8
13 // REQUIRES: locale.zh_CN.UTF-8
14
15 // Russia uses ',' for the decimal separator. GLIBC returns '.'
16 // XFAIL: linux
17
18 // <locale>
19
20 // class moneypunct_byname<charT, International>
21
22 // charT decimal_point() const;
23
24 #include <locale>
25 #include <limits>
26 #include <cassert>
27
28 #include "platform_support.h" // locale name macros
29
30 class Fnf
31 : public std::moneypunct_byname<char, false>
32 {
33 public:
Fnf(const std::string & nm,std::size_t refs=0)34 explicit Fnf(const std::string& nm, std::size_t refs = 0)
35 : std::moneypunct_byname<char, false>(nm, refs) {}
36 };
37
38 class Fnt
39 : public std::moneypunct_byname<char, true>
40 {
41 public:
Fnt(const std::string & nm,std::size_t refs=0)42 explicit Fnt(const std::string& nm, std::size_t refs = 0)
43 : std::moneypunct_byname<char, true>(nm, refs) {}
44 };
45
46 class Fwf
47 : public std::moneypunct_byname<wchar_t, false>
48 {
49 public:
Fwf(const std::string & nm,std::size_t refs=0)50 explicit Fwf(const std::string& nm, std::size_t refs = 0)
51 : std::moneypunct_byname<wchar_t, false>(nm, refs) {}
52 };
53
54 class Fwt
55 : public std::moneypunct_byname<wchar_t, true>
56 {
57 public:
Fwt(const std::string & nm,std::size_t refs=0)58 explicit Fwt(const std::string& nm, std::size_t refs = 0)
59 : std::moneypunct_byname<wchar_t, true>(nm, refs) {}
60 };
61
main()62 int main()
63 {
64 {
65 Fnf f("C", 1);
66 assert(f.decimal_point() == std::numeric_limits<char>::max());
67 }
68 {
69 Fnt f("C", 1);
70 assert(f.decimal_point() == std::numeric_limits<char>::max());
71 }
72 {
73 Fwf f("C", 1);
74 assert(f.decimal_point() == std::numeric_limits<wchar_t>::max());
75 }
76 {
77 Fwt f("C", 1);
78 assert(f.decimal_point() == std::numeric_limits<wchar_t>::max());
79 }
80
81 {
82 Fnf f(LOCALE_en_US_UTF_8, 1);
83 assert(f.decimal_point() == '.');
84 }
85 {
86 Fnt f(LOCALE_en_US_UTF_8, 1);
87 assert(f.decimal_point() == '.');
88 }
89 {
90 Fwf f(LOCALE_en_US_UTF_8, 1);
91 assert(f.decimal_point() == L'.');
92 }
93 {
94 Fwt f(LOCALE_en_US_UTF_8, 1);
95 assert(f.decimal_point() == L'.');
96 }
97
98 {
99 Fnf f(LOCALE_fr_FR_UTF_8, 1);
100 assert(f.decimal_point() == ',');
101 }
102 {
103 Fnt f(LOCALE_fr_FR_UTF_8, 1);
104 assert(f.decimal_point() == ',');
105 }
106 {
107 Fwf f(LOCALE_fr_FR_UTF_8, 1);
108 assert(f.decimal_point() == L',');
109 }
110 {
111 Fwt f(LOCALE_fr_FR_UTF_8, 1);
112 assert(f.decimal_point() == L',');
113 }
114
115 {
116 Fnf f(LOCALE_ru_RU_UTF_8, 1);
117 assert(f.decimal_point() == ',');
118 }
119 {
120 Fnt f(LOCALE_ru_RU_UTF_8, 1);
121 assert(f.decimal_point() == ',');
122 }
123 {
124 Fwf f(LOCALE_ru_RU_UTF_8, 1);
125 assert(f.decimal_point() == L',');
126 }
127 {
128 Fwt f(LOCALE_ru_RU_UTF_8, 1);
129 assert(f.decimal_point() == L',');
130 }
131
132 {
133 Fnf f(LOCALE_zh_CN_UTF_8, 1);
134 assert(f.decimal_point() == '.');
135 }
136 {
137 Fnt f(LOCALE_zh_CN_UTF_8, 1);
138 assert(f.decimal_point() == '.');
139 }
140 {
141 Fwf f(LOCALE_zh_CN_UTF_8, 1);
142 assert(f.decimal_point() == L'.');
143 }
144 {
145 Fwt f(LOCALE_zh_CN_UTF_8, 1);
146 assert(f.decimal_point() == L'.');
147 }
148 }
149