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