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