Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 1 | //===----------------------------------------------------------------------===// |
| 2 | // |
Howard Hinnant | f5256e1 | 2010-05-11 21:36:01 +0000 | [diff] [blame] | 3 | // The LLVM Compiler Infrastructure |
Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 4 | // |
Howard Hinnant | b64f8b0 | 2010-11-16 22:09:02 +0000 | [diff] [blame] | 5 | // This file is dual licensed under the MIT and the University of Illinois Open |
| 6 | // Source Licenses. See LICENSE.TXT for details. |
Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 7 | // |
| 8 | //===----------------------------------------------------------------------===// |
Dan Albert | 1d4a1ed | 2016-05-25 22:36:09 -0700 | [diff] [blame^] | 9 | |
Dan Albert | b4ed5ca | 2014-08-04 18:44:48 +0000 | [diff] [blame] | 10 | // REQUIRES: locale.ru_RU.UTF-8 |
Eric Fiselier | 07a4bec | 2015-03-10 20:46:04 +0000 | [diff] [blame] | 11 | // UNSUPPORTED: sanitizer-new-delete |
Dan Albert | b4ed5ca | 2014-08-04 18:44:48 +0000 | [diff] [blame] | 12 | |
Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 13 | // <locale> |
| 14 | |
| 15 | // locale(const locale& other, const string& std_name, category cat); |
| 16 | |
| 17 | #include <locale> |
| 18 | #include <new> |
| 19 | #include <cassert> |
| 20 | |
Marshall Clow | 83e2c4d | 2013-01-05 03:21:01 +0000 | [diff] [blame] | 21 | #include "platform_support.h" // locale name macros |
Howard Hinnant | c0d0cba | 2011-10-03 15:23:59 +0000 | [diff] [blame] | 22 | |
Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 23 | int new_called = 0; |
| 24 | |
| 25 | void* operator new(std::size_t s) throw(std::bad_alloc) |
| 26 | { |
| 27 | ++new_called; |
| 28 | return std::malloc(s); |
| 29 | } |
| 30 | |
| 31 | void operator delete(void* p) throw() |
| 32 | { |
| 33 | --new_called; |
| 34 | std::free(p); |
| 35 | } |
| 36 | |
| 37 | void check(const std::locale& loc) |
| 38 | { |
| 39 | assert(std::has_facet<std::collate<char> >(loc)); |
| 40 | assert(std::has_facet<std::collate<wchar_t> >(loc)); |
| 41 | |
| 42 | assert(std::has_facet<std::ctype<char> >(loc)); |
| 43 | assert(std::has_facet<std::ctype<wchar_t> >(loc)); |
| 44 | assert((std::has_facet<std::codecvt<char, char, std::mbstate_t> >(loc))); |
| 45 | assert((std::has_facet<std::codecvt<char16_t, char, std::mbstate_t> >(loc))); |
| 46 | assert((std::has_facet<std::codecvt<char32_t, char, std::mbstate_t> >(loc))); |
| 47 | assert((std::has_facet<std::codecvt<wchar_t, char, std::mbstate_t> >(loc))); |
| 48 | |
| 49 | assert((std::has_facet<std::moneypunct<char> >(loc))); |
| 50 | assert((std::has_facet<std::moneypunct<wchar_t> >(loc))); |
| 51 | assert((std::has_facet<std::money_get<char> >(loc))); |
| 52 | assert((std::has_facet<std::money_get<wchar_t> >(loc))); |
| 53 | assert((std::has_facet<std::money_put<char> >(loc))); |
| 54 | assert((std::has_facet<std::money_put<wchar_t> >(loc))); |
| 55 | |
| 56 | assert((std::has_facet<std::numpunct<char> >(loc))); |
| 57 | assert((std::has_facet<std::numpunct<wchar_t> >(loc))); |
| 58 | assert((std::has_facet<std::num_get<char> >(loc))); |
| 59 | assert((std::has_facet<std::num_get<wchar_t> >(loc))); |
| 60 | assert((std::has_facet<std::num_put<char> >(loc))); |
| 61 | assert((std::has_facet<std::num_put<wchar_t> >(loc))); |
| 62 | |
| 63 | assert((std::has_facet<std::time_get<char> >(loc))); |
| 64 | assert((std::has_facet<std::time_get<wchar_t> >(loc))); |
| 65 | assert((std::has_facet<std::time_put<char> >(loc))); |
| 66 | assert((std::has_facet<std::time_put<wchar_t> >(loc))); |
| 67 | |
| 68 | assert((std::has_facet<std::messages<char> >(loc))); |
| 69 | assert((std::has_facet<std::messages<wchar_t> >(loc))); |
| 70 | } |
| 71 | |
| 72 | int main() |
| 73 | { |
| 74 | { |
Howard Hinnant | c0d0cba | 2011-10-03 15:23:59 +0000 | [diff] [blame] | 75 | std::locale loc(LOCALE_ru_RU_UTF_8); |
Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 76 | check(loc); |
Howard Hinnant | c0d0cba | 2011-10-03 15:23:59 +0000 | [diff] [blame] | 77 | std::locale loc2(loc, std::string(LOCALE_en_US_UTF_8), std::locale::monetary); |
Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 78 | check(loc2); |
| 79 | } |
| 80 | assert(new_called == 0); |
| 81 | } |