1 // -*- C++ -*- 2 //===----------------------------------------------------------------------===// 3 // 4 // The LLVM Compiler Infrastructure 5 // 6 // This file is dual licensed under the MIT and the University of Illinois Open 7 // Source Licenses. See LICENSE.TXT for details. 8 // 9 //===----------------------------------------------------------------------===// 10 11 // <regex> 12 13 // template <class charT> struct regex_traits; 14 15 // charT translate_nocase(charT c) const; 16 17 // XFAIL: with_system_lib=x86_64-apple-darwin11 18 // XFAIL: with_system_lib=x86_64-apple-darwin12 19 20 #include <regex> 21 #include <cassert> 22 23 #include "platform_support.h" 24 main()25int main() 26 { 27 { 28 std::regex_traits<char> t; 29 assert(t.translate_nocase(' ') == ' '); 30 assert(t.translate_nocase('A') == 'a'); 31 assert(t.translate_nocase('\x07') == '\x07'); 32 assert(t.translate_nocase('.') == '.'); 33 assert(t.translate_nocase('a') == 'a'); 34 assert(t.translate_nocase('1') == '1'); 35 assert(t.translate_nocase('\xDA') == '\xDA'); 36 assert(t.translate_nocase('\xFA') == '\xFA'); 37 /* Disable locale specific tests on Android because Android's NDK does not 38 * support locales other than "C" and "POSIX". 39 * 40 * https://code.google.com/p/android/issues/detail?id=57313 41 */ 42 #if !defined(__ANDROID__) 43 t.imbue(std::locale(LOCALE_en_US_UTF_8)); 44 assert(t.translate_nocase(' ') == ' '); 45 assert(t.translate_nocase('A') == 'a'); 46 assert(t.translate_nocase('\x07') == '\x07'); 47 assert(t.translate_nocase('.') == '.'); 48 assert(t.translate_nocase('a') == 'a'); 49 assert(t.translate_nocase('1') == '1'); 50 assert(t.translate_nocase('\xDA') == '\xFA'); 51 assert(t.translate_nocase('\xFA') == '\xFA'); 52 #endif 53 } 54 { 55 std::regex_traits<wchar_t> t; 56 assert(t.translate_nocase(L' ') == L' '); 57 assert(t.translate_nocase(L'A') == L'a'); 58 assert(t.translate_nocase(L'\x07') == L'\x07'); 59 assert(t.translate_nocase(L'.') == L'.'); 60 assert(t.translate_nocase(L'a') == L'a'); 61 assert(t.translate_nocase(L'1') == L'1'); 62 assert(t.translate_nocase(L'\xDA') == L'\xDA'); 63 assert(t.translate_nocase(L'\xFA') == L'\xFA'); 64 /* Disable locale specific tests on Android because Android's NDK does not 65 * support locales other than "C" and "POSIX". 66 * 67 * https://code.google.com/p/android/issues/detail?id=57313 68 */ 69 #if !defined(__ANDROID__) 70 t.imbue(std::locale(LOCALE_en_US_UTF_8)); 71 assert(t.translate_nocase(L' ') == L' '); 72 assert(t.translate_nocase(L'A') == L'a'); 73 assert(t.translate_nocase(L'\x07') == L'\x07'); 74 assert(t.translate_nocase(L'.') == L'.'); 75 assert(t.translate_nocase(L'a') == L'a'); 76 assert(t.translate_nocase(L'1') == L'1'); 77 assert(t.translate_nocase(L'\xDA') == L'\xFA'); 78 assert(t.translate_nocase(L'\xFA') == L'\xFA'); 79 #endif 80 } 81 } 82