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 | //===----------------------------------------------------------------------===// |
| 9 | |
| 10 | // <locale> |
| 11 | |
| 12 | // template <class charT> class ctype_byname; |
| 13 | |
| 14 | // const charT* toupper(charT* low, const charT* high) const; |
| 15 | |
Jonathan Roelofs | 3345961 | 2015-01-14 23:38:12 +0000 | [diff] [blame] | 16 | // XFAIL: with_system_cxx_lib=x86_64-apple-darwin11 |
| 17 | // XFAIL: with_system_cxx_lib=x86_64-apple-darwin12 |
Eric Fiselier | f523693 | 2014-08-21 02:03:01 +0000 | [diff] [blame] | 18 | // XFAIL: linux |
Howard Hinnant | dd854b2 | 2013-05-07 17:37:19 +0000 | [diff] [blame] | 19 | |
Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 20 | #include <locale> |
| 21 | #include <string> |
| 22 | #include <cassert> |
| 23 | |
Marshall Clow | 83e2c4d | 2013-01-05 03:21:01 +0000 | [diff] [blame] | 24 | #include "platform_support.h" // locale name macros |
Howard Hinnant | c0d0cba | 2011-10-03 15:23:59 +0000 | [diff] [blame] | 25 | |
Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 26 | int main() |
| 27 | { |
| 28 | { |
Howard Hinnant | c0d0cba | 2011-10-03 15:23:59 +0000 | [diff] [blame] | 29 | std::locale l(LOCALE_en_US_UTF_8); |
Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 30 | { |
| 31 | typedef std::ctype<char> F; |
| 32 | const F& f = std::use_facet<F>(l); |
| 33 | std::string in("\xFA A\x07.a1"); |
Howard Hinnant | 22a74dc | 2010-08-22 00:39:25 +0000 | [diff] [blame] | 34 | |
Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 35 | assert(f.toupper(&in[0], in.data() + in.size()) == in.data() + in.size()); |
Joerg Sonnenberger | 63d8f7e | 2013-05-02 19:17:48 +0000 | [diff] [blame] | 36 | assert(in[0] == '\xDA'); |
Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 37 | assert(in[1] == ' '); |
| 38 | assert(in[2] == 'A'); |
| 39 | assert(in[3] == '\x07'); |
| 40 | assert(in[4] == '.'); |
| 41 | assert(in[5] == 'A'); |
| 42 | assert(in[6] == '1'); |
| 43 | } |
| 44 | } |
| 45 | { |
| 46 | std::locale l("C"); |
| 47 | { |
| 48 | typedef std::ctype<char> F; |
| 49 | const F& f = std::use_facet<F>(l); |
| 50 | std::string in("\xFA A\x07.a1"); |
Howard Hinnant | 22a74dc | 2010-08-22 00:39:25 +0000 | [diff] [blame] | 51 | |
Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 52 | assert(f.toupper(&in[0], in.data() + in.size()) == in.data() + in.size()); |
| 53 | assert(in[0] == '\xFA'); |
| 54 | assert(in[1] == ' '); |
| 55 | assert(in[2] == 'A'); |
| 56 | assert(in[3] == '\x07'); |
| 57 | assert(in[4] == '.'); |
| 58 | assert(in[5] == 'A'); |
| 59 | assert(in[6] == '1'); |
| 60 | } |
| 61 | } |
| 62 | { |
Howard Hinnant | c0d0cba | 2011-10-03 15:23:59 +0000 | [diff] [blame] | 63 | std::locale l(LOCALE_en_US_UTF_8); |
Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 64 | { |
| 65 | typedef std::ctype<wchar_t> F; |
| 66 | const F& f = std::use_facet<F>(l); |
| 67 | std::wstring in(L"\xFA A\x07.a1"); |
Howard Hinnant | 22a74dc | 2010-08-22 00:39:25 +0000 | [diff] [blame] | 68 | |
Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 69 | assert(f.toupper(&in[0], in.data() + in.size()) == in.data() + in.size()); |
| 70 | assert(in[0] == L'\xDA'); |
| 71 | assert(in[1] == L' '); |
| 72 | assert(in[2] == L'A'); |
| 73 | assert(in[3] == L'\x07'); |
| 74 | assert(in[4] == L'.'); |
| 75 | assert(in[5] == L'A'); |
| 76 | assert(in[6] == L'1'); |
| 77 | } |
| 78 | } |
| 79 | { |
| 80 | std::locale l("C"); |
| 81 | { |
| 82 | typedef std::ctype<wchar_t> F; |
| 83 | const F& f = std::use_facet<F>(l); |
| 84 | std::wstring in(L"\xFA A\x07.a1"); |
Howard Hinnant | 22a74dc | 2010-08-22 00:39:25 +0000 | [diff] [blame] | 85 | |
Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 86 | assert(f.toupper(&in[0], in.data() + in.size()) == in.data() + in.size()); |
| 87 | assert(in[0] == L'\xFA'); |
| 88 | assert(in[1] == L' '); |
| 89 | assert(in[2] == L'A'); |
| 90 | assert(in[3] == L'\x07'); |
| 91 | assert(in[4] == L'.'); |
| 92 | assert(in[5] == L'A'); |
| 93 | assert(in[6] == L'1'); |
| 94 | } |
| 95 | } |
| 96 | } |