1bc8d3f97eb5c958007f2713238472e0c1c8fe02Howard Hinnant//===----------------------------------------------------------------------===//
2bc8d3f97eb5c958007f2713238472e0c1c8fe02Howard Hinnant//
3f5256e16dfc425c1d466f6308d4026d529ce9e0bHoward Hinnant//                     The LLVM Compiler Infrastructure
4bc8d3f97eb5c958007f2713238472e0c1c8fe02Howard Hinnant//
5b64f8b07c104c6cc986570ac8ee0ed16a9f23976Howard Hinnant// This file is dual licensed under the MIT and the University of Illinois Open
6b64f8b07c104c6cc986570ac8ee0ed16a9f23976Howard Hinnant// Source Licenses. See LICENSE.TXT for details.
7bc8d3f97eb5c958007f2713238472e0c1c8fe02Howard Hinnant//
8bc8d3f97eb5c958007f2713238472e0c1c8fe02Howard Hinnant//===----------------------------------------------------------------------===//
9bc8d3f97eb5c958007f2713238472e0c1c8fe02Howard Hinnant
10bc8d3f97eb5c958007f2713238472e0c1c8fe02Howard Hinnant// <locale>
11bc8d3f97eb5c958007f2713238472e0c1c8fe02Howard Hinnant
12bc8d3f97eb5c958007f2713238472e0c1c8fe02Howard Hinnant// locale(const locale& other, const locale& one, category cats);
13bc8d3f97eb5c958007f2713238472e0c1c8fe02Howard Hinnant
14bc8d3f97eb5c958007f2713238472e0c1c8fe02Howard Hinnant#include <locale>
15bc8d3f97eb5c958007f2713238472e0c1c8fe02Howard Hinnant#include <new>
16bc8d3f97eb5c958007f2713238472e0c1c8fe02Howard Hinnant#include <cassert>
17bc8d3f97eb5c958007f2713238472e0c1c8fe02Howard Hinnant
1883e2c4d877fe2d7793868b1c6a5d9525a7c4d431Marshall Clow#include "platform_support.h" // locale name macros
19c0d0cbad9ed434267a7af9531bdeeae52eb6d706Howard Hinnant
20bc8d3f97eb5c958007f2713238472e0c1c8fe02Howard Hinnantint new_called = 0;
21bc8d3f97eb5c958007f2713238472e0c1c8fe02Howard Hinnant
22bc8d3f97eb5c958007f2713238472e0c1c8fe02Howard Hinnantvoid* operator new(std::size_t s) throw(std::bad_alloc)
23bc8d3f97eb5c958007f2713238472e0c1c8fe02Howard Hinnant{
24bc8d3f97eb5c958007f2713238472e0c1c8fe02Howard Hinnant    ++new_called;
25bc8d3f97eb5c958007f2713238472e0c1c8fe02Howard Hinnant    return std::malloc(s);
26bc8d3f97eb5c958007f2713238472e0c1c8fe02Howard Hinnant}
27bc8d3f97eb5c958007f2713238472e0c1c8fe02Howard Hinnant
28bc8d3f97eb5c958007f2713238472e0c1c8fe02Howard Hinnantvoid  operator delete(void* p) throw()
29bc8d3f97eb5c958007f2713238472e0c1c8fe02Howard Hinnant{
30bc8d3f97eb5c958007f2713238472e0c1c8fe02Howard Hinnant    --new_called;
31bc8d3f97eb5c958007f2713238472e0c1c8fe02Howard Hinnant    std::free(p);
32bc8d3f97eb5c958007f2713238472e0c1c8fe02Howard Hinnant}
33bc8d3f97eb5c958007f2713238472e0c1c8fe02Howard Hinnant
34bc8d3f97eb5c958007f2713238472e0c1c8fe02Howard Hinnantvoid check(const std::locale& loc)
35bc8d3f97eb5c958007f2713238472e0c1c8fe02Howard Hinnant{
36bc8d3f97eb5c958007f2713238472e0c1c8fe02Howard Hinnant    assert(std::has_facet<std::collate<char> >(loc));
37bc8d3f97eb5c958007f2713238472e0c1c8fe02Howard Hinnant    assert(std::has_facet<std::collate<wchar_t> >(loc));
38bc8d3f97eb5c958007f2713238472e0c1c8fe02Howard Hinnant
39bc8d3f97eb5c958007f2713238472e0c1c8fe02Howard Hinnant    assert(std::has_facet<std::ctype<char> >(loc));
40bc8d3f97eb5c958007f2713238472e0c1c8fe02Howard Hinnant    assert(std::has_facet<std::ctype<wchar_t> >(loc));
41bc8d3f97eb5c958007f2713238472e0c1c8fe02Howard Hinnant    assert((std::has_facet<std::codecvt<char, char, std::mbstate_t> >(loc)));
42bc8d3f97eb5c958007f2713238472e0c1c8fe02Howard Hinnant    assert((std::has_facet<std::codecvt<char16_t, char, std::mbstate_t> >(loc)));
43bc8d3f97eb5c958007f2713238472e0c1c8fe02Howard Hinnant    assert((std::has_facet<std::codecvt<char32_t, char, std::mbstate_t> >(loc)));
44bc8d3f97eb5c958007f2713238472e0c1c8fe02Howard Hinnant    assert((std::has_facet<std::codecvt<wchar_t, char, std::mbstate_t> >(loc)));
45bc8d3f97eb5c958007f2713238472e0c1c8fe02Howard Hinnant
46bc8d3f97eb5c958007f2713238472e0c1c8fe02Howard Hinnant    assert((std::has_facet<std::moneypunct<char> >(loc)));
47bc8d3f97eb5c958007f2713238472e0c1c8fe02Howard Hinnant    assert((std::has_facet<std::moneypunct<wchar_t> >(loc)));
48bc8d3f97eb5c958007f2713238472e0c1c8fe02Howard Hinnant    assert((std::has_facet<std::money_get<char> >(loc)));
49bc8d3f97eb5c958007f2713238472e0c1c8fe02Howard Hinnant    assert((std::has_facet<std::money_get<wchar_t> >(loc)));
50bc8d3f97eb5c958007f2713238472e0c1c8fe02Howard Hinnant    assert((std::has_facet<std::money_put<char> >(loc)));
51bc8d3f97eb5c958007f2713238472e0c1c8fe02Howard Hinnant    assert((std::has_facet<std::money_put<wchar_t> >(loc)));
52bc8d3f97eb5c958007f2713238472e0c1c8fe02Howard Hinnant
53bc8d3f97eb5c958007f2713238472e0c1c8fe02Howard Hinnant    assert((std::has_facet<std::numpunct<char> >(loc)));
54bc8d3f97eb5c958007f2713238472e0c1c8fe02Howard Hinnant    assert((std::has_facet<std::numpunct<wchar_t> >(loc)));
55bc8d3f97eb5c958007f2713238472e0c1c8fe02Howard Hinnant    assert((std::has_facet<std::num_get<char> >(loc)));
56bc8d3f97eb5c958007f2713238472e0c1c8fe02Howard Hinnant    assert((std::has_facet<std::num_get<wchar_t> >(loc)));
57bc8d3f97eb5c958007f2713238472e0c1c8fe02Howard Hinnant    assert((std::has_facet<std::num_put<char> >(loc)));
58bc8d3f97eb5c958007f2713238472e0c1c8fe02Howard Hinnant    assert((std::has_facet<std::num_put<wchar_t> >(loc)));
59bc8d3f97eb5c958007f2713238472e0c1c8fe02Howard Hinnant
60bc8d3f97eb5c958007f2713238472e0c1c8fe02Howard Hinnant    assert((std::has_facet<std::time_get<char> >(loc)));
61bc8d3f97eb5c958007f2713238472e0c1c8fe02Howard Hinnant    assert((std::has_facet<std::time_get<wchar_t> >(loc)));
62bc8d3f97eb5c958007f2713238472e0c1c8fe02Howard Hinnant    assert((std::has_facet<std::time_put<char> >(loc)));
63bc8d3f97eb5c958007f2713238472e0c1c8fe02Howard Hinnant    assert((std::has_facet<std::time_put<wchar_t> >(loc)));
64bc8d3f97eb5c958007f2713238472e0c1c8fe02Howard Hinnant
65bc8d3f97eb5c958007f2713238472e0c1c8fe02Howard Hinnant    assert((std::has_facet<std::messages<char> >(loc)));
66bc8d3f97eb5c958007f2713238472e0c1c8fe02Howard Hinnant    assert((std::has_facet<std::messages<wchar_t> >(loc)));
67bc8d3f97eb5c958007f2713238472e0c1c8fe02Howard Hinnant}
68bc8d3f97eb5c958007f2713238472e0c1c8fe02Howard Hinnant
69bc8d3f97eb5c958007f2713238472e0c1c8fe02Howard Hinnantint main()
70bc8d3f97eb5c958007f2713238472e0c1c8fe02Howard Hinnant{
71bc8d3f97eb5c958007f2713238472e0c1c8fe02Howard Hinnant    {
72c0d0cbad9ed434267a7af9531bdeeae52eb6d706Howard Hinnant        std::locale loc(LOCALE_ru_RU_UTF_8);
73bc8d3f97eb5c958007f2713238472e0c1c8fe02Howard Hinnant        check(loc);
74c0d0cbad9ed434267a7af9531bdeeae52eb6d706Howard Hinnant        std::locale loc2(loc, std::locale(LOCALE_en_US_UTF_8), std::locale::monetary);
75bc8d3f97eb5c958007f2713238472e0c1c8fe02Howard Hinnant        check(loc2);
76bc8d3f97eb5c958007f2713238472e0c1c8fe02Howard Hinnant    }
77bc8d3f97eb5c958007f2713238472e0c1c8fe02Howard Hinnant    assert(new_called == 0);
78bc8d3f97eb5c958007f2713238472e0c1c8fe02Howard Hinnant}
79