blob: d495f8aaf070e23613a2601eae7ecb14e412dfed [file] [log] [blame]
Howard Hinnant70505302010-06-17 00:34:59 +00001//===----------------------------------------------------------------------===//
2//
3// The LLVM Compiler Infrastructure
4//
Howard Hinnant412dbeb2010-11-16 22:09:02 +00005// This file is dual licensed under the MIT and the University of Illinois Open
6// Source Licenses. See LICENSE.TXT for details.
Howard Hinnant70505302010-06-17 00:34:59 +00007//
8//===----------------------------------------------------------------------===//
9
Dan Alberta85b27f2014-08-04 18:44:48 +000010// REQUIRES: locale.cs_CZ.ISO8859-2
11
Howard Hinnant70505302010-06-17 00:34:59 +000012// <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 Fiseliere608aed2014-10-23 21:17:36 +000020// TODO: investigation needed
21// XFAIL: linux-gnu
22
Howard Hinnant70505302010-06-17 00:34:59 +000023#include <regex>
24#include <iterator>
25#include <cassert>
Marshall Clow32227082013-01-05 03:21:01 +000026#include "test_iterators.h"
Howard Hinnant70505302010-06-17 00:34:59 +000027
28template <class char_type>
29void
Howard Hinnantb996af12011-09-21 16:42:32 +000030test(const char_type* A, const std::basic_string<char_type>& expected)
Howard Hinnant70505302010-06-17 00:34:59 +000031{
32 std::regex_traits<char_type> t;
33 typedef forward_iterator<const char_type*> F;
34 assert(t.lookup_collatename(F(A), F(A + t.length(A))) == expected);
35}
36
37int main()
38{
Howard Hinnantb996af12011-09-21 16:42:32 +000039 test("NUL", std::string("\x00", 1));
40 test("alert", std::string("\x07"));
41 test("backspace", std::string("\x08"));
42 test("tab", std::string("\x09"));
43 test("carriage-return", std::string("\x0D"));
44 test("newline", std::string("\x0A"));
45 test("vertical-tab", std::string("\x0B"));
46 test("form-feed", std::string("\x0C"));
47 test("space", std::string(" "));
48 test("exclamation-mark", std::string("!"));
49 test("quotation-mark", std::string("\""));
50 test("number-sign", std::string("#"));
51 test("dollar-sign", std::string("$"));
52 test("percent-sign", std::string("%"));
53 test("ampersand", std::string("&"));
54 test("apostrophe", std::string("\'"));
55 test("left-parenthesis", std::string("("));
56 test("right-parenthesis", std::string(")"));
57 test("asterisk", std::string("*"));
58 test("plus-sign", std::string("+"));
59 test("comma", std::string(","));
60 test("hyphen-minus", std::string("-"));
61 test("hyphen", std::string("-"));
62 test("full-stop", std::string("."));
63 test("period", std::string("."));
64 test("slash", std::string("/"));
65 test("solidus", std::string("/"));
66 test("zero", std::string("0"));
67 test("one", std::string("1"));
68 test("two", std::string("2"));
69 test("three", std::string("3"));
70 test("four", std::string("4"));
71 test("five", std::string("5"));
72 test("six", std::string("6"));
73 test("seven", std::string("7"));
74 test("eight", std::string("8"));
75 test("nine", std::string("9"));
76 test("colon", std::string(":"));
77 test("semicolon", std::string(";"));
78 test("less-than-sign", std::string("<"));
79 test("equals-sign", std::string("="));
80 test("greater-than-sign", std::string(">"));
81 test("question-mark", std::string("?"));
82 test("commercial-at", std::string("@"));
Howard Hinnant70505302010-06-17 00:34:59 +000083 for (char c = 'A'; c <= 'Z'; ++c)
84 {
85 const char a[2] = {c};
Howard Hinnantb996af12011-09-21 16:42:32 +000086 test(a, std::string(a));
Howard Hinnant70505302010-06-17 00:34:59 +000087 }
Howard Hinnantb996af12011-09-21 16:42:32 +000088 test("left-square-bracket", std::string("["));
89 test("backslash", std::string("\\"));
90 test("reverse-solidus", std::string("\\"));
91 test("right-square-bracket", std::string("]"));
92 test("circumflex-accent", std::string("^"));
93 test("circumflex", std::string("^"));
94 test("low-line", std::string("_"));
95 test("underscore", std::string("_"));
96 test("grave-accent", std::string("`"));
Howard Hinnant70505302010-06-17 00:34:59 +000097 for (char c = 'a'; c <= 'z'; ++c)
98 {
99 const char a[2] = {c};
Howard Hinnantb996af12011-09-21 16:42:32 +0000100 test(a, std::string(a));
Howard Hinnant70505302010-06-17 00:34:59 +0000101 }
Howard Hinnantb996af12011-09-21 16:42:32 +0000102 test("left-brace", std::string("{"));
103 test("left-curly-bracket", std::string("{"));
104 test("vertical-line", std::string("|"));
105 test("right-brace", std::string("}"));
106 test("right-curly-bracket", std::string("}"));
107 test("tilde", std::string("~"));
Howard Hinnant70505302010-06-17 00:34:59 +0000108
Howard Hinnantb996af12011-09-21 16:42:32 +0000109 test("tild", std::string(""));
110 test("ch", std::string(""));
Howard Hinnant70505302010-06-17 00:34:59 +0000111 std::locale::global(std::locale("cs_CZ.ISO8859-2"));
Howard Hinnantb996af12011-09-21 16:42:32 +0000112 test("ch", std::string("ch"));
Howard Hinnant70505302010-06-17 00:34:59 +0000113 std::locale::global(std::locale("C"));
114
Howard Hinnantb996af12011-09-21 16:42:32 +0000115 test(L"NUL", std::wstring(L"\x00", 1));
116 test(L"alert", std::wstring(L"\x07"));
117 test(L"backspace", std::wstring(L"\x08"));
118 test(L"tab", std::wstring(L"\x09"));
119 test(L"carriage-return", std::wstring(L"\x0D"));
120 test(L"newline", std::wstring(L"\x0A"));
121 test(L"vertical-tab", std::wstring(L"\x0B"));
122 test(L"form-feed", std::wstring(L"\x0C"));
123 test(L"space", std::wstring(L" "));
124 test(L"exclamation-mark", std::wstring(L"!"));
125 test(L"quotation-mark", std::wstring(L"\""));
126 test(L"number-sign", std::wstring(L"#"));
127 test(L"dollar-sign", std::wstring(L"$"));
128 test(L"percent-sign", std::wstring(L"%"));
129 test(L"ampersand", std::wstring(L"&"));
130 test(L"apostrophe", std::wstring(L"\'"));
131 test(L"left-parenthesis", std::wstring(L"("));
132 test(L"right-parenthesis", std::wstring(L")"));
133 test(L"asterisk", std::wstring(L"*"));
134 test(L"plus-sign", std::wstring(L"+"));
135 test(L"comma", std::wstring(L","));
136 test(L"hyphen-minus", std::wstring(L"-"));
137 test(L"hyphen", std::wstring(L"-"));
138 test(L"full-stop", std::wstring(L"."));
139 test(L"period", std::wstring(L"."));
140 test(L"slash", std::wstring(L"/"));
141 test(L"solidus", std::wstring(L"/"));
142 test(L"zero", std::wstring(L"0"));
143 test(L"one", std::wstring(L"1"));
144 test(L"two", std::wstring(L"2"));
145 test(L"three", std::wstring(L"3"));
146 test(L"four", std::wstring(L"4"));
147 test(L"five", std::wstring(L"5"));
148 test(L"six", std::wstring(L"6"));
149 test(L"seven", std::wstring(L"7"));
150 test(L"eight", std::wstring(L"8"));
151 test(L"nine", std::wstring(L"9"));
152 test(L"colon", std::wstring(L":"));
153 test(L"semicolon", std::wstring(L";"));
154 test(L"less-than-sign", std::wstring(L"<"));
155 test(L"equals-sign", std::wstring(L"="));
156 test(L"greater-than-sign", std::wstring(L">"));
157 test(L"question-mark", std::wstring(L"?"));
158 test(L"commercial-at", std::wstring(L"@"));
Howard Hinnant70505302010-06-17 00:34:59 +0000159 for (wchar_t c = L'A'; c <= L'Z'; ++c)
160 {
161 const wchar_t a[2] = {c};
Howard Hinnantb996af12011-09-21 16:42:32 +0000162 test(a, std::wstring(a));
Howard Hinnant70505302010-06-17 00:34:59 +0000163 }
Howard Hinnantb996af12011-09-21 16:42:32 +0000164 test(L"left-square-bracket", std::wstring(L"["));
165 test(L"backslash", std::wstring(L"\\"));
166 test(L"reverse-solidus", std::wstring(L"\\"));
167 test(L"right-square-bracket", std::wstring(L"]"));
168 test(L"circumflex-accent", std::wstring(L"^"));
169 test(L"circumflex", std::wstring(L"^"));
170 test(L"low-line", std::wstring(L"_"));
171 test(L"underscore", std::wstring(L"_"));
172 test(L"grave-accent", std::wstring(L"`"));
Howard Hinnant70505302010-06-17 00:34:59 +0000173 for (wchar_t c = L'a'; c <= L'z'; ++c)
174 {
175 const wchar_t a[2] = {c};
Howard Hinnantb996af12011-09-21 16:42:32 +0000176 test(a, std::wstring(a));
Howard Hinnant70505302010-06-17 00:34:59 +0000177 }
Howard Hinnantb996af12011-09-21 16:42:32 +0000178 test(L"left-brace", std::wstring(L"{"));
179 test(L"left-curly-bracket", std::wstring(L"{"));
180 test(L"vertical-line", std::wstring(L"|"));
181 test(L"right-brace", std::wstring(L"}"));
182 test(L"right-curly-bracket", std::wstring(L"}"));
183 test(L"tilde", std::wstring(L"~"));
Howard Hinnant70505302010-06-17 00:34:59 +0000184
Howard Hinnantb996af12011-09-21 16:42:32 +0000185 test(L"tild", std::wstring(L""));
186 test(L"ch", std::wstring(L""));
Howard Hinnant70505302010-06-17 00:34:59 +0000187 std::locale::global(std::locale("cs_CZ.ISO8859-2"));
Howard Hinnantb996af12011-09-21 16:42:32 +0000188 test(L"ch", std::wstring(L"ch"));
Howard Hinnant70505302010-06-17 00:34:59 +0000189 std::locale::global(std::locale("C"));
190}