Revert "[libc] Use best-fit binary trie to make malloc logarithmic" (#117065)
[llvm-project.git] / libcxx / test / std / re / re.traits / lookup_collatename.pass.cpp
blob178979d5b9ce8e8a4e3b67f97bd3fd14a0f471a3
1 //===----------------------------------------------------------------------===//
2 //
3 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4 // See https://llvm.org/LICENSE.txt for license information.
5 // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6 //
7 //===----------------------------------------------------------------------===//
8 //
9 // NetBSD does not support LC_COLLATE at the moment
10 // XFAIL: netbsd
12 // XFAIL: LIBCXX-AIX-FIXME
13 // XFAIL: LIBCXX-FREEBSD-FIXME
15 // REQUIRES: locale.cs_CZ.ISO8859-2
17 // <regex>
19 // template <class charT> struct regex_traits;
21 // template <class ForwardIterator>
22 // string_type
23 // lookup_collatename(ForwardIterator first, ForwardIterator last) const;
25 // TODO: investigation needed
26 // XFAIL: target={{.*}}-linux-gnu{{.*}}
28 #include <regex>
29 #include <iterator>
30 #include <cassert>
32 #include "test_macros.h"
33 #include "test_iterators.h"
34 #include "platform_support.h" // locale name macros
36 template <class char_type>
37 void
38 test(const char_type* A, const std::basic_string<char_type>& expected)
40 std::regex_traits<char_type> t;
41 typedef forward_iterator<const char_type*> F;
42 assert(t.lookup_collatename(F(A), F(A + t.length(A))) == expected);
45 int main(int, char**)
47 test("NUL", std::string("\x00", 1));
48 test("alert", std::string("\x07"));
49 test("backspace", std::string("\x08"));
50 test("tab", std::string("\x09"));
51 test("carriage-return", std::string("\x0D"));
52 test("newline", std::string("\x0A"));
53 test("vertical-tab", std::string("\x0B"));
54 test("form-feed", std::string("\x0C"));
55 test("space", std::string(" "));
56 test("exclamation-mark", std::string("!"));
57 test("quotation-mark", std::string("\""));
58 test("number-sign", std::string("#"));
59 test("dollar-sign", std::string("$"));
60 test("percent-sign", std::string("%"));
61 test("ampersand", std::string("&"));
62 test("apostrophe", std::string("\'"));
63 test("left-parenthesis", std::string("("));
64 test("right-parenthesis", std::string(")"));
65 test("asterisk", std::string("*"));
66 test("plus-sign", std::string("+"));
67 test("comma", std::string(","));
68 test("hyphen-minus", std::string("-"));
69 test("hyphen", std::string("-"));
70 test("full-stop", std::string("."));
71 test("period", std::string("."));
72 test("slash", std::string("/"));
73 test("solidus", std::string("/"));
74 test("zero", std::string("0"));
75 test("one", std::string("1"));
76 test("two", std::string("2"));
77 test("three", std::string("3"));
78 test("four", std::string("4"));
79 test("five", std::string("5"));
80 test("six", std::string("6"));
81 test("seven", std::string("7"));
82 test("eight", std::string("8"));
83 test("nine", std::string("9"));
84 test("colon", std::string(":"));
85 test("semicolon", std::string(";"));
86 test("less-than-sign", std::string("<"));
87 test("equals-sign", std::string("="));
88 test("greater-than-sign", std::string(">"));
89 test("question-mark", std::string("?"));
90 test("commercial-at", std::string("@"));
91 for (char c = 'A'; c <= 'Z'; ++c)
93 const char a[2] = {c};
94 test(a, std::string(a));
96 test("left-square-bracket", std::string("["));
97 test("backslash", std::string("\\"));
98 test("reverse-solidus", std::string("\\"));
99 test("right-square-bracket", std::string("]"));
100 test("circumflex-accent", std::string("^"));
101 test("circumflex", std::string("^"));
102 test("low-line", std::string("_"));
103 test("underscore", std::string("_"));
104 test("grave-accent", std::string("`"));
105 for (char c = 'a'; c <= 'z'; ++c)
107 const char a[2] = {c};
108 test(a, std::string(a));
110 test("left-brace", std::string("{"));
111 test("left-curly-bracket", std::string("{"));
112 test("vertical-line", std::string("|"));
113 test("right-brace", std::string("}"));
114 test("right-curly-bracket", std::string("}"));
115 test("tilde", std::string("~"));
117 test("tild", std::string(""));
118 test("ch", std::string(""));
119 std::locale::global(std::locale(LOCALE_cs_CZ_ISO8859_2));
120 test("ch", std::string("ch"));
121 std::locale::global(std::locale("C"));
123 #ifndef TEST_HAS_NO_WIDE_CHARACTERS
124 test(L"NUL", std::wstring(L"\x00", 1));
125 test(L"alert", std::wstring(L"\x07"));
126 test(L"backspace", std::wstring(L"\x08"));
127 test(L"tab", std::wstring(L"\x09"));
128 test(L"carriage-return", std::wstring(L"\x0D"));
129 test(L"newline", std::wstring(L"\x0A"));
130 test(L"vertical-tab", std::wstring(L"\x0B"));
131 test(L"form-feed", std::wstring(L"\x0C"));
132 test(L"space", std::wstring(L" "));
133 test(L"exclamation-mark", std::wstring(L"!"));
134 test(L"quotation-mark", std::wstring(L"\""));
135 test(L"number-sign", std::wstring(L"#"));
136 test(L"dollar-sign", std::wstring(L"$"));
137 test(L"percent-sign", std::wstring(L"%"));
138 test(L"ampersand", std::wstring(L"&"));
139 test(L"apostrophe", std::wstring(L"\'"));
140 test(L"left-parenthesis", std::wstring(L"("));
141 test(L"right-parenthesis", std::wstring(L")"));
142 test(L"asterisk", std::wstring(L"*"));
143 test(L"plus-sign", std::wstring(L"+"));
144 test(L"comma", std::wstring(L","));
145 test(L"hyphen-minus", std::wstring(L"-"));
146 test(L"hyphen", std::wstring(L"-"));
147 test(L"full-stop", std::wstring(L"."));
148 test(L"period", std::wstring(L"."));
149 test(L"slash", std::wstring(L"/"));
150 test(L"solidus", std::wstring(L"/"));
151 test(L"zero", std::wstring(L"0"));
152 test(L"one", std::wstring(L"1"));
153 test(L"two", std::wstring(L"2"));
154 test(L"three", std::wstring(L"3"));
155 test(L"four", std::wstring(L"4"));
156 test(L"five", std::wstring(L"5"));
157 test(L"six", std::wstring(L"6"));
158 test(L"seven", std::wstring(L"7"));
159 test(L"eight", std::wstring(L"8"));
160 test(L"nine", std::wstring(L"9"));
161 test(L"colon", std::wstring(L":"));
162 test(L"semicolon", std::wstring(L";"));
163 test(L"less-than-sign", std::wstring(L"<"));
164 test(L"equals-sign", std::wstring(L"="));
165 test(L"greater-than-sign", std::wstring(L">"));
166 test(L"question-mark", std::wstring(L"?"));
167 test(L"commercial-at", std::wstring(L"@"));
168 for (wchar_t c = L'A'; c <= L'Z'; ++c)
170 const wchar_t a[2] = {c};
171 test(a, std::wstring(a));
173 test(L"left-square-bracket", std::wstring(L"["));
174 test(L"backslash", std::wstring(L"\\"));
175 test(L"reverse-solidus", std::wstring(L"\\"));
176 test(L"right-square-bracket", std::wstring(L"]"));
177 test(L"circumflex-accent", std::wstring(L"^"));
178 test(L"circumflex", std::wstring(L"^"));
179 test(L"low-line", std::wstring(L"_"));
180 test(L"underscore", std::wstring(L"_"));
181 test(L"grave-accent", std::wstring(L"`"));
182 for (wchar_t c = L'a'; c <= L'z'; ++c)
184 const wchar_t a[2] = {c};
185 test(a, std::wstring(a));
187 test(L"left-brace", std::wstring(L"{"));
188 test(L"left-curly-bracket", std::wstring(L"{"));
189 test(L"vertical-line", std::wstring(L"|"));
190 test(L"right-brace", std::wstring(L"}"));
191 test(L"right-curly-bracket", std::wstring(L"}"));
192 test(L"tilde", std::wstring(L"~"));
194 test(L"tild", std::wstring(L""));
195 test(L"ch", std::wstring(L""));
196 std::locale::global(std::locale(LOCALE_cs_CZ_ISO8859_2));
197 test(L"ch", std::wstring(L"ch"));
198 std::locale::global(std::locale("C"));
199 #endif // TEST_HAS_NO_WIDE_CHARACTERS
201 return 0;