1 //===----------------------------------------------------------------------===//
3 // The LLVM Compiler Infrastructure
5 // This file is dual licensed under the MIT and the University of Illinois Open
6 // Source Licenses. See LICENSE.TXT for details.
8 //===----------------------------------------------------------------------===//
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
17 // class moneypunct_byname<charT, International>
19 // charT thousands_sep() const;
25 #include "test_macros.h"
26 #include "platform_support.h" // locale name macros
29 : public std::moneypunct_byname<char, false>
32 explicit Fnf(const std::string& nm, std::size_t refs = 0)
33 : std::moneypunct_byname<char, false>(nm, refs) {}
37 : public std::moneypunct_byname<char, true>
40 explicit Fnt(const std::string& nm, std::size_t refs = 0)
41 : std::moneypunct_byname<char, true>(nm, refs) {}
45 : public std::moneypunct_byname<wchar_t, false>
48 explicit Fwf(const std::string& nm, std::size_t refs = 0)
49 : std::moneypunct_byname<wchar_t, false>(nm, refs) {}
53 : public std::moneypunct_byname<wchar_t, true>
56 explicit Fwt(const std::string& nm, std::size_t refs = 0)
57 : std::moneypunct_byname<wchar_t, true>(nm, refs) {}
64 assert(f.thousands_sep() == std::numeric_limits<char>::max());
68 assert(f.thousands_sep() == std::numeric_limits<char>::max());
72 assert(f.thousands_sep() == std::numeric_limits<wchar_t>::max());
76 assert(f.thousands_sep() == std::numeric_limits<wchar_t>::max());
80 Fnf f(LOCALE_en_US_UTF_8, 1);
81 assert(f.thousands_sep() == ',');
84 Fnt f(LOCALE_en_US_UTF_8, 1);
85 assert(f.thousands_sep() == ',');
88 Fwf f(LOCALE_en_US_UTF_8, 1);
89 assert(f.thousands_sep() == L',');
92 Fwt f(LOCALE_en_US_UTF_8, 1);
93 assert(f.thousands_sep() == L',');
97 Fnf f(LOCALE_fr_FR_UTF_8, 1);
98 assert(f.thousands_sep() == ' ');
101 Fnt f(LOCALE_fr_FR_UTF_8, 1);
102 assert(f.thousands_sep() == ' ');
105 Fwf f(LOCALE_fr_FR_UTF_8, 1);
106 assert(f.thousands_sep() == L' ');
109 Fwt f(LOCALE_fr_FR_UTF_8, 1);
110 assert(f.thousands_sep() == L' ');
112 // The below tests work around GLIBC's use of U00A0 as mon_thousands_sep
113 // and U002E as mon_decimal_point.
114 // TODO: Fix thousands_sep for 'char'.
115 // related to https://gcc.gnu.org/bugzilla/show_bug.cgi?id=16006
116 #ifndef TEST_HAS_GLIBC
117 const char sep = ' ';
118 const wchar_t wsep = L' ';
120 // FIXME libc++ specifically works around \u00A0 by translating it into
122 const char sep = ' ';
123 const wchar_t wsep = L'\u00A0';
126 Fnf f(LOCALE_ru_RU_UTF_8, 1);
127 assert(f.thousands_sep() == sep);
130 Fnt f(LOCALE_ru_RU_UTF_8, 1);
131 assert(f.thousands_sep() == sep);
134 Fwf f(LOCALE_ru_RU_UTF_8, 1);
135 assert(f.thousands_sep() == wsep);
138 Fwt f(LOCALE_ru_RU_UTF_8, 1);
139 assert(f.thousands_sep() == wsep);
143 Fnf f(LOCALE_zh_CN_UTF_8, 1);
144 assert(f.thousands_sep() == ',');
147 Fnt f(LOCALE_zh_CN_UTF_8, 1);
148 assert(f.thousands_sep() == ',');
151 Fwf f(LOCALE_zh_CN_UTF_8, 1);
152 assert(f.thousands_sep() == L',');
155 Fwt f(LOCALE_zh_CN_UTF_8, 1);
156 assert(f.thousands_sep() == L',');