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 // <locale> 11 12 // class moneypunct_byname<charT, International> 13 14 // charT thousands_sep() const; 15 16 #include <locale> 17 #include <limits> 18 #include <cassert> 19 20 #include "platform_support.h" // locale name macros 21 22 class Fnf 23 : public std::moneypunct_byname<char, false> 24 { 25 public: 26 explicit Fnf(const std::string& nm, std::size_t refs = 0) 27 : std::moneypunct_byname<char, false>(nm, refs) {} 28 }; 29 30 class Fnt 31 : public std::moneypunct_byname<char, true> 32 { 33 public: 34 explicit Fnt(const std::string& nm, std::size_t refs = 0) 35 : std::moneypunct_byname<char, true>(nm, refs) {} 36 }; 37 38 class Fwf 39 : public std::moneypunct_byname<wchar_t, false> 40 { 41 public: 42 explicit Fwf(const std::string& nm, std::size_t refs = 0) 43 : std::moneypunct_byname<wchar_t, false>(nm, refs) {} 44 }; 45 46 class Fwt 47 : public std::moneypunct_byname<wchar_t, true> 48 { 49 public: 50 explicit Fwt(const std::string& nm, std::size_t refs = 0) 51 : std::moneypunct_byname<wchar_t, true>(nm, refs) {} 52 }; 53 54 int main() 55 { 56 { 57 Fnf f("C", 1); 58 assert(f.thousands_sep() == std::numeric_limits<char>::max()); 59 } 60 { 61 Fnt f("C", 1); 62 assert(f.thousands_sep() == std::numeric_limits<char>::max()); 63 } 64 { 65 Fwf f("C", 1); 66 assert(f.thousands_sep() == std::numeric_limits<wchar_t>::max()); 67 } 68 { 69 Fwt f("C", 1); 70 assert(f.thousands_sep() == std::numeric_limits<wchar_t>::max()); 71 } 72 73 { 74 Fnf f(LOCALE_en_US_UTF_8, 1); 75 assert(f.thousands_sep() == ','); 76 } 77 { 78 Fnt f(LOCALE_en_US_UTF_8, 1); 79 assert(f.thousands_sep() == ','); 80 } 81 { 82 Fwf f(LOCALE_en_US_UTF_8, 1); 83 assert(f.thousands_sep() == L','); 84 } 85 { 86 Fwt f(LOCALE_en_US_UTF_8, 1); 87 assert(f.thousands_sep() == L','); 88 } 89 90 { 91 Fnf f(LOCALE_fr_FR_UTF_8, 1); 92 assert(f.thousands_sep() == ' '); 93 } 94 { 95 Fnt f(LOCALE_fr_FR_UTF_8, 1); 96 assert(f.thousands_sep() == ' '); 97 } 98 { 99 Fwf f(LOCALE_fr_FR_UTF_8, 1); 100 assert(f.thousands_sep() == L' '); 101 } 102 { 103 Fwt f(LOCALE_fr_FR_UTF_8, 1); 104 assert(f.thousands_sep() == L' '); 105 } 106 107 { 108 Fnf f(LOCALE_ru_RU_UTF_8, 1); 109 assert(f.thousands_sep() == ' '); 110 } 111 { 112 Fnt f(LOCALE_ru_RU_UTF_8, 1); 113 assert(f.thousands_sep() == ' '); 114 } 115 { 116 Fwf f(LOCALE_ru_RU_UTF_8, 1); 117 assert(f.thousands_sep() == L' '); 118 } 119 { 120 Fwt f(LOCALE_ru_RU_UTF_8, 1); 121 assert(f.thousands_sep() == L' '); 122 } 123 124 { 125 Fnf f(LOCALE_zh_CN_UTF_8, 1); 126 assert(f.thousands_sep() == ','); 127 } 128 { 129 Fnt f(LOCALE_zh_CN_UTF_8, 1); 130 assert(f.thousands_sep() == ','); 131 } 132 { 133 Fwf f(LOCALE_zh_CN_UTF_8, 1); 134 assert(f.thousands_sep() == L','); 135 } 136 { 137 Fwt f(LOCALE_zh_CN_UTF_8, 1); 138 assert(f.thousands_sep() == L','); 139 } 140 } 141