Home | History | Annotate | Download | only in locale.cons
      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.ru_RU.UTF-8
     12 // UNSUPPORTED: sanitizer-new-delete
     13 
     14 // XFAIL: availability_markup=macosx10.8
     15 // XFAIL: availability_markup=macosx10.7
     16 
     17 // <locale>
     18 
     19 // locale(const locale& other, const string& std_name, category cat);
     20 
     21 #include <locale>
     22 #include <new>
     23 #include <cassert>
     24 
     25 #include "count_new.hpp"
     26 #include "platform_support.h" // locale name macros
     27 
     28 
     29 void check(const std::locale& loc)
     30 {
     31     assert(std::has_facet<std::collate<char> >(loc));
     32     assert(std::has_facet<std::collate<wchar_t> >(loc));
     33 
     34     assert(std::has_facet<std::ctype<char> >(loc));
     35     assert(std::has_facet<std::ctype<wchar_t> >(loc));
     36     assert((std::has_facet<std::codecvt<char, char, std::mbstate_t> >(loc)));
     37     assert((std::has_facet<std::codecvt<char16_t, char, std::mbstate_t> >(loc)));
     38     assert((std::has_facet<std::codecvt<char32_t, char, std::mbstate_t> >(loc)));
     39     assert((std::has_facet<std::codecvt<wchar_t, char, std::mbstate_t> >(loc)));
     40 
     41     assert((std::has_facet<std::moneypunct<char> >(loc)));
     42     assert((std::has_facet<std::moneypunct<wchar_t> >(loc)));
     43     assert((std::has_facet<std::money_get<char> >(loc)));
     44     assert((std::has_facet<std::money_get<wchar_t> >(loc)));
     45     assert((std::has_facet<std::money_put<char> >(loc)));
     46     assert((std::has_facet<std::money_put<wchar_t> >(loc)));
     47 
     48     assert((std::has_facet<std::numpunct<char> >(loc)));
     49     assert((std::has_facet<std::numpunct<wchar_t> >(loc)));
     50     assert((std::has_facet<std::num_get<char> >(loc)));
     51     assert((std::has_facet<std::num_get<wchar_t> >(loc)));
     52     assert((std::has_facet<std::num_put<char> >(loc)));
     53     assert((std::has_facet<std::num_put<wchar_t> >(loc)));
     54 
     55     assert((std::has_facet<std::time_get<char> >(loc)));
     56     assert((std::has_facet<std::time_get<wchar_t> >(loc)));
     57     assert((std::has_facet<std::time_put<char> >(loc)));
     58     assert((std::has_facet<std::time_put<wchar_t> >(loc)));
     59 
     60     assert((std::has_facet<std::messages<char> >(loc)));
     61     assert((std::has_facet<std::messages<wchar_t> >(loc)));
     62 }
     63 
     64 int main()
     65 {
     66     {
     67         std::locale loc(LOCALE_ru_RU_UTF_8);
     68         check(loc);
     69         std::locale loc2(loc, std::string(LOCALE_en_US_UTF_8), std::locale::monetary);
     70         check(loc2);
     71     }
     72     assert(globalMemCounter.checkOutstandingNewEq(0));
     73 }
     74