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