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 // REQUIRES: locale.en_US.UTF-8 18 19 #include <regex> 20 #include <cassert> 21 22 #include "test_macros.h" 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 t.imbue(std::locale(LOCALE_en_US_UTF_8)); 38 assert(t.translate_nocase(' ') == ' '); 39 assert(t.translate_nocase('A') == 'a'); 40 assert(t.translate_nocase('\x07') == '\x07'); 41 assert(t.translate_nocase('.') == '.'); 42 assert(t.translate_nocase('a') == 'a'); 43 assert(t.translate_nocase('1') == '1'); 44 } 45 { 46 std::regex_traits<wchar_t> t; 47 assert(t.translate_nocase(L' ') == L' '); 48 assert(t.translate_nocase(L'A') == L'a'); 49 assert(t.translate_nocase(L'\x07') == L'\x07'); 50 assert(t.translate_nocase(L'.') == L'.'); 51 assert(t.translate_nocase(L'a') == L'a'); 52 assert(t.translate_nocase(L'1') == L'1'); 53 assert(t.translate_nocase(L'\xDA') == L'\xDA'); 54 assert(t.translate_nocase(L'\xFA') == L'\xFA'); 55 t.imbue(std::locale(LOCALE_en_US_UTF_8)); 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'\xFA'); 63 assert(t.translate_nocase(L'\xFA') == L'\xFA'); 64 } 65 } 66