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 // class moneypunct_byname<charT, International>
     13 
     14 // int frac_digits() 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.frac_digits() == 0);
     59     }
     60     {
     61         Fnt f("C", 1);
     62         assert(f.frac_digits() == 0);
     63     }
     64     {
     65         Fwf f("C", 1);
     66         assert(f.frac_digits() == 0);
     67     }
     68     {
     69         Fwt f("C", 1);
     70         assert(f.frac_digits() == 0);
     71     }
     72 
     73     {
     74         Fnf f(LOCALE_en_US_UTF_8, 1);
     75         assert(f.frac_digits() == 2);
     76     }
     77     {
     78         Fnt f(LOCALE_en_US_UTF_8, 1);
     79         assert(f.frac_digits() == 2);
     80     }
     81     {
     82         Fwf f(LOCALE_en_US_UTF_8, 1);
     83         assert(f.frac_digits() == 2);
     84     }
     85     {
     86         Fwt f(LOCALE_en_US_UTF_8, 1);
     87         assert(f.frac_digits() == 2);
     88     }
     89 
     90     {
     91         Fnf f(LOCALE_fr_FR_UTF_8, 1);
     92         assert(f.frac_digits() == 2);
     93     }
     94     {
     95         Fnt f(LOCALE_fr_FR_UTF_8, 1);
     96         assert(f.frac_digits() == 2);
     97     }
     98     {
     99         Fwf f(LOCALE_fr_FR_UTF_8, 1);
    100         assert(f.frac_digits() == 2);
    101     }
    102     {
    103         Fwt f(LOCALE_fr_FR_UTF_8, 1);
    104         assert(f.frac_digits() == 2);
    105     }
    106 
    107     {
    108         Fnf f(LOCALE_ru_RU_UTF_8, 1);
    109         assert(f.frac_digits() == 2);
    110     }
    111     {
    112         Fnt f(LOCALE_ru_RU_UTF_8, 1);
    113         assert(f.frac_digits() == 2);
    114     }
    115     {
    116         Fwf f(LOCALE_ru_RU_UTF_8, 1);
    117         assert(f.frac_digits() == 2);
    118     }
    119     {
    120         Fwt f(LOCALE_ru_RU_UTF_8, 1);
    121         assert(f.frac_digits() == 2);
    122     }
    123 
    124     {
    125         Fnf f(LOCALE_zh_CN_UTF_8, 1);
    126         assert(f.frac_digits() == 2);
    127     }
    128     {
    129         Fnt f(LOCALE_zh_CN_UTF_8, 1);
    130         assert(f.frac_digits() == 2);
    131     }
    132     {
    133         Fwf f(LOCALE_zh_CN_UTF_8, 1);
    134         assert(f.frac_digits() == 2);
    135     }
    136     {
    137         Fwt f(LOCALE_zh_CN_UTF_8, 1);
    138         assert(f.frac_digits() == 2);
    139     }
    140 }
    141