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 // static const locale& classic();
13 
14 #include <locale>
15 #include <cassert>
16 
check(const std::locale & loc)17 void check(const std::locale& loc)
18 {
19     assert(std::has_facet<std::collate<char> >(loc));
20     assert(std::has_facet<std::collate<wchar_t> >(loc));
21 
22     assert(std::has_facet<std::ctype<char> >(loc));
23     assert(std::has_facet<std::ctype<wchar_t> >(loc));
24     assert((std::has_facet<std::codecvt<char, char, std::mbstate_t> >(loc)));
25     assert((std::has_facet<std::codecvt<char16_t, char, std::mbstate_t> >(loc)));
26     assert((std::has_facet<std::codecvt<char32_t, char, std::mbstate_t> >(loc)));
27     assert((std::has_facet<std::codecvt<wchar_t, char, std::mbstate_t> >(loc)));
28 
29     assert((std::has_facet<std::moneypunct<char> >(loc)));
30     assert((std::has_facet<std::moneypunct<wchar_t> >(loc)));
31     assert((std::has_facet<std::money_get<char> >(loc)));
32     assert((std::has_facet<std::money_get<wchar_t> >(loc)));
33     assert((std::has_facet<std::money_put<char> >(loc)));
34     assert((std::has_facet<std::money_put<wchar_t> >(loc)));
35 
36     assert((std::has_facet<std::numpunct<char> >(loc)));
37     assert((std::has_facet<std::numpunct<wchar_t> >(loc)));
38     assert((std::has_facet<std::num_get<char> >(loc)));
39     assert((std::has_facet<std::num_get<wchar_t> >(loc)));
40     assert((std::has_facet<std::num_put<char> >(loc)));
41     assert((std::has_facet<std::num_put<wchar_t> >(loc)));
42 
43     assert((std::has_facet<std::time_get<char> >(loc)));
44     assert((std::has_facet<std::time_get<wchar_t> >(loc)));
45     assert((std::has_facet<std::time_put<char> >(loc)));
46     assert((std::has_facet<std::time_put<wchar_t> >(loc)));
47 
48     assert((std::has_facet<std::messages<char> >(loc)));
49     assert((std::has_facet<std::messages<wchar_t> >(loc)));
50 }
51 
main()52 int main()
53 {
54     std::locale loc = std::locale::classic();
55     assert(loc.name() == "C");
56     assert(loc == std::locale("C"));
57     check(loc);
58     check(std::locale("C"));
59 }
60