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