1 //===----------------------------------------------------------------------===// 2 // 3 // The LLVM Compiler Infrastructure 4 // 5 // This file is dual licensed under the MIT and the University of Illinois Open 6 // Source Licenses. See LICENSE.TXT for details. 7 // 8 //===----------------------------------------------------------------------===// 9 10 // REQUIRES: locale.cs_CZ.ISO8859-2 11 12 // <regex> 13 14 // template <class charT> struct regex_traits; 15 16 // template <class ForwardIterator> 17 // string_type 18 // lookup_collatename(ForwardIterator first, ForwardIterator last) const; 19 20 // TODO: investigation needed 21 // XFAIL: linux-gnu 22 23 #include <regex> 24 #include <iterator> 25 #include <cassert> 26 27 #include "test_macros.h" 28 #include "test_iterators.h" 29 #include "platform_support.h" // locale name macros 30 31 template <class char_type> 32 void 33 test(const char_type* A, const std::basic_string<char_type>& expected) 34 { 35 std::regex_traits<char_type> t; 36 typedef forward_iterator<const char_type*> F; 37 assert(t.lookup_collatename(F(A), F(A + t.length(A))) == expected); 38 } 39 40 int main() 41 { 42 test("NUL", std::string("\x00", 1)); 43 test("alert", std::string("\x07")); 44 test("backspace", std::string("\x08")); 45 test("tab", std::string("\x09")); 46 test("carriage-return", std::string("\x0D")); 47 test("newline", std::string("\x0A")); 48 test("vertical-tab", std::string("\x0B")); 49 test("form-feed", std::string("\x0C")); 50 test("space", std::string(" ")); 51 test("exclamation-mark", std::string("!")); 52 test("quotation-mark", std::string("\"")); 53 test("number-sign", std::string("#")); 54 test("dollar-sign", std::string("$")); 55 test("percent-sign", std::string("%")); 56 test("ampersand", std::string("&")); 57 test("apostrophe", std::string("\'")); 58 test("left-parenthesis", std::string("(")); 59 test("right-parenthesis", std::string(")")); 60 test("asterisk", std::string("*")); 61 test("plus-sign", std::string("+")); 62 test("comma", std::string(",")); 63 test("hyphen-minus", std::string("-")); 64 test("hyphen", std::string("-")); 65 test("full-stop", std::string(".")); 66 test("period", std::string(".")); 67 test("slash", std::string("/")); 68 test("solidus", std::string("/")); 69 test("zero", std::string("0")); 70 test("one", std::string("1")); 71 test("two", std::string("2")); 72 test("three", std::string("3")); 73 test("four", std::string("4")); 74 test("five", std::string("5")); 75 test("six", std::string("6")); 76 test("seven", std::string("7")); 77 test("eight", std::string("8")); 78 test("nine", std::string("9")); 79 test("colon", std::string(":")); 80 test("semicolon", std::string(";")); 81 test("less-than-sign", std::string("<")); 82 test("equals-sign", std::string("=")); 83 test("greater-than-sign", std::string(">")); 84 test("question-mark", std::string("?")); 85 test("commercial-at", std::string("@")); 86 for (char c = 'A'; c <= 'Z'; ++c) 87 { 88 const char a[2] = {c}; 89 test(a, std::string(a)); 90 } 91 test("left-square-bracket", std::string("[")); 92 test("backslash", std::string("\\")); 93 test("reverse-solidus", std::string("\\")); 94 test("right-square-bracket", std::string("]")); 95 test("circumflex-accent", std::string("^")); 96 test("circumflex", std::string("^")); 97 test("low-line", std::string("_")); 98 test("underscore", std::string("_")); 99 test("grave-accent", std::string("`")); 100 for (char c = 'a'; c <= 'z'; ++c) 101 { 102 const char a[2] = {c}; 103 test(a, std::string(a)); 104 } 105 test("left-brace", std::string("{")); 106 test("left-curly-bracket", std::string("{")); 107 test("vertical-line", std::string("|")); 108 test("right-brace", std::string("}")); 109 test("right-curly-bracket", std::string("}")); 110 test("tilde", std::string("~")); 111 112 test("tild", std::string("")); 113 test("ch", std::string("")); 114 std::locale::global(std::locale(LOCALE_cs_CZ_ISO8859_2)); 115 test("ch", std::string("ch")); 116 std::locale::global(std::locale("C")); 117 118 test(L"NUL", std::wstring(L"\x00", 1)); 119 test(L"alert", std::wstring(L"\x07")); 120 test(L"backspace", std::wstring(L"\x08")); 121 test(L"tab", std::wstring(L"\x09")); 122 test(L"carriage-return", std::wstring(L"\x0D")); 123 test(L"newline", std::wstring(L"\x0A")); 124 test(L"vertical-tab", std::wstring(L"\x0B")); 125 test(L"form-feed", std::wstring(L"\x0C")); 126 test(L"space", std::wstring(L" ")); 127 test(L"exclamation-mark", std::wstring(L"!")); 128 test(L"quotation-mark", std::wstring(L"\"")); 129 test(L"number-sign", std::wstring(L"#")); 130 test(L"dollar-sign", std::wstring(L"$")); 131 test(L"percent-sign", std::wstring(L"%")); 132 test(L"ampersand", std::wstring(L"&")); 133 test(L"apostrophe", std::wstring(L"\'")); 134 test(L"left-parenthesis", std::wstring(L"(")); 135 test(L"right-parenthesis", std::wstring(L")")); 136 test(L"asterisk", std::wstring(L"*")); 137 test(L"plus-sign", std::wstring(L"+")); 138 test(L"comma", std::wstring(L",")); 139 test(L"hyphen-minus", std::wstring(L"-")); 140 test(L"hyphen", std::wstring(L"-")); 141 test(L"full-stop", std::wstring(L".")); 142 test(L"period", std::wstring(L".")); 143 test(L"slash", std::wstring(L"/")); 144 test(L"solidus", std::wstring(L"/")); 145 test(L"zero", std::wstring(L"0")); 146 test(L"one", std::wstring(L"1")); 147 test(L"two", std::wstring(L"2")); 148 test(L"three", std::wstring(L"3")); 149 test(L"four", std::wstring(L"4")); 150 test(L"five", std::wstring(L"5")); 151 test(L"six", std::wstring(L"6")); 152 test(L"seven", std::wstring(L"7")); 153 test(L"eight", std::wstring(L"8")); 154 test(L"nine", std::wstring(L"9")); 155 test(L"colon", std::wstring(L":")); 156 test(L"semicolon", std::wstring(L";")); 157 test(L"less-than-sign", std::wstring(L"<")); 158 test(L"equals-sign", std::wstring(L"=")); 159 test(L"greater-than-sign", std::wstring(L">")); 160 test(L"question-mark", std::wstring(L"?")); 161 test(L"commercial-at", std::wstring(L"@")); 162 for (wchar_t c = L'A'; c <= L'Z'; ++c) 163 { 164 const wchar_t a[2] = {c}; 165 test(a, std::wstring(a)); 166 } 167 test(L"left-square-bracket", std::wstring(L"[")); 168 test(L"backslash", std::wstring(L"\\")); 169 test(L"reverse-solidus", std::wstring(L"\\")); 170 test(L"right-square-bracket", std::wstring(L"]")); 171 test(L"circumflex-accent", std::wstring(L"^")); 172 test(L"circumflex", std::wstring(L"^")); 173 test(L"low-line", std::wstring(L"_")); 174 test(L"underscore", std::wstring(L"_")); 175 test(L"grave-accent", std::wstring(L"`")); 176 for (wchar_t c = L'a'; c <= L'z'; ++c) 177 { 178 const wchar_t a[2] = {c}; 179 test(a, std::wstring(a)); 180 } 181 test(L"left-brace", std::wstring(L"{")); 182 test(L"left-curly-bracket", std::wstring(L"{")); 183 test(L"vertical-line", std::wstring(L"|")); 184 test(L"right-brace", std::wstring(L"}")); 185 test(L"right-curly-bracket", std::wstring(L"}")); 186 test(L"tilde", std::wstring(L"~")); 187 188 test(L"tild", std::wstring(L"")); 189 test(L"ch", std::wstring(L"")); 190 std::locale::global(std::locale(LOCALE_cs_CZ_ISO8859_2)); 191 test(L"ch", std::wstring(L"ch")); 192 std::locale::global(std::locale("C")); 193 } 194