Home | History | Annotate | Download | only in locale.numpunct.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 // REQUIRES: locale.en_US.UTF-8
     11 // REQUIRES: locale.fr_FR.UTF-8
     12 
     13 // <locale>
     14 
     15 // template <class charT> class numpunct_byname;
     16 
     17 // char_type thousands_sep() const;
     18 
     19 
     20 #include <locale>
     21 #include <cassert>
     22 
     23 #include "test_macros.h"
     24 #include "platform_support.h" // locale name macros
     25 
     26 int main()
     27 {
     28     {
     29         std::locale l("C");
     30         {
     31             typedef char C;
     32             const std::numpunct<C>& np = std::use_facet<std::numpunct<C> >(l);
     33             assert(np.thousands_sep() == ',');
     34         }
     35         {
     36             typedef wchar_t C;
     37             const std::numpunct<C>& np = std::use_facet<std::numpunct<C> >(l);
     38             assert(np.thousands_sep() == L',');
     39         }
     40     }
     41     {
     42         std::locale l(LOCALE_en_US_UTF_8);
     43         {
     44             typedef char C;
     45             const std::numpunct<C>& np = std::use_facet<std::numpunct<C> >(l);
     46             assert(np.thousands_sep() == ',');
     47         }
     48         {
     49             typedef wchar_t C;
     50             const std::numpunct<C>& np = std::use_facet<std::numpunct<C> >(l);
     51             assert(np.thousands_sep() == L',');
     52         }
     53     }
     54     {
     55         std::locale l(LOCALE_fr_FR_UTF_8);
     56 #if defined(TEST_HAS_GLIBC)
     57         const char sep = ' ';
     58         const wchar_t wsep = L' ';
     59 #else
     60         const char sep = ',';
     61         const wchar_t wsep = L',';
     62 #endif
     63         {
     64             typedef char C;
     65             const std::numpunct<C>& np = std::use_facet<std::numpunct<C> >(l);
     66             assert(np.thousands_sep() == sep);
     67         }
     68         {
     69             typedef wchar_t C;
     70             const std::numpunct<C>& np = std::use_facet<std::numpunct<C> >(l);
     71             assert(np.thousands_sep() == wsep);
     72         }
     73     }
     74 }
     75