1 /* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
2 /* vim: set ts=8 sts=2 et sw=2 tw=80: */
3 /* This Source Code Form is subject to the terms of the Mozilla Public
4 * License, v. 2.0. If a copy of the MPL was not distributed with this file,
5 * You can obtain one at http://mozilla.org/MPL/2.0/. */
7 #include "mozilla/Assertions.h"
8 #include "mozilla/TextUtils.h"
10 using mozilla::AsciiAlphanumericToNumber
;
11 using mozilla::IsAscii
;
12 using mozilla::IsAsciiAlpha
;
13 using mozilla::IsAsciiAlphanumeric
;
14 using mozilla::IsAsciiDigit
;
15 using mozilla::IsAsciiLowercaseAlpha
;
16 using mozilla::IsAsciiNullTerminated
;
17 using mozilla::IsAsciiUppercaseAlpha
;
19 static void TestIsAscii() {
22 static_assert(!IsAscii(char(-1)), "char(-1) isn't ASCII");
24 static_assert(IsAscii('\0'), "nul is ASCII");
26 static_assert(IsAscii('A'), "'A' is ASCII");
27 static_assert(IsAscii('B'), "'B' is ASCII");
28 static_assert(IsAscii('M'), "'M' is ASCII");
29 static_assert(IsAscii('Y'), "'Y' is ASCII");
30 static_assert(IsAscii('Z'), "'Z' is ASCII");
32 static_assert(IsAscii('['), "'[' is ASCII");
33 static_assert(IsAscii('`'), "'`' is ASCII");
35 static_assert(IsAscii('a'), "'a' is ASCII");
36 static_assert(IsAscii('b'), "'b' is ASCII");
37 static_assert(IsAscii('m'), "'m' is ASCII");
38 static_assert(IsAscii('y'), "'y' is ASCII");
39 static_assert(IsAscii('z'), "'z' is ASCII");
41 static_assert(IsAscii('{'), "'{' is ASCII");
43 static_assert(IsAscii('5'), "'5' is ASCII");
45 static_assert(IsAscii('\x7F'), "'\\x7F' is ASCII");
46 static_assert(!IsAscii('\x80'), "'\\x80' isn't ASCII");
50 static_assert(!IsAscii(char16_t(-1)), "char16_t(-1) isn't ASCII");
52 static_assert(IsAscii(u
'\0'), "nul is ASCII");
54 static_assert(IsAscii(u
'A'), "u'A' is ASCII");
55 static_assert(IsAscii(u
'B'), "u'B' is ASCII");
56 static_assert(IsAscii(u
'M'), "u'M' is ASCII");
57 static_assert(IsAscii(u
'Y'), "u'Y' is ASCII");
58 static_assert(IsAscii(u
'Z'), "u'Z' is ASCII");
60 static_assert(IsAscii(u
'['), "u'[' is ASCII");
61 static_assert(IsAscii(u
'`'), "u'`' is ASCII");
63 static_assert(IsAscii(u
'a'), "u'a' is ASCII");
64 static_assert(IsAscii(u
'b'), "u'b' is ASCII");
65 static_assert(IsAscii(u
'm'), "u'm' is ASCII");
66 static_assert(IsAscii(u
'y'), "u'y' is ASCII");
67 static_assert(IsAscii(u
'z'), "u'z' is ASCII");
69 static_assert(IsAscii(u
'{'), "u'{' is ASCII");
71 static_assert(IsAscii(u
'5'), "u'5' is ASCII");
73 static_assert(IsAscii(u
'\x7F'), "u'\\x7F' is ASCII");
74 static_assert(!IsAscii(u
'\x80'), "u'\\x80' isn't ASCII");
78 static_assert(!IsAscii(char32_t(-1)), "char32_t(-1) isn't ASCII");
80 static_assert(IsAscii(U
'\0'), "nul is ASCII");
82 static_assert(IsAscii(U
'A'), "U'A' is ASCII");
83 static_assert(IsAscii(U
'B'), "U'B' is ASCII");
84 static_assert(IsAscii(U
'M'), "U'M' is ASCII");
85 static_assert(IsAscii(U
'Y'), "U'Y' is ASCII");
86 static_assert(IsAscii(U
'Z'), "U'Z' is ASCII");
88 static_assert(IsAscii(U
'['), "U'[' is ASCII");
89 static_assert(IsAscii(U
'`'), "U'`' is ASCII");
91 static_assert(IsAscii(U
'a'), "U'a' is ASCII");
92 static_assert(IsAscii(U
'b'), "U'b' is ASCII");
93 static_assert(IsAscii(U
'm'), "U'm' is ASCII");
94 static_assert(IsAscii(U
'y'), "U'y' is ASCII");
95 static_assert(IsAscii(U
'z'), "U'z' is ASCII");
97 static_assert(IsAscii(U
'{'), "U'{' is ASCII");
99 static_assert(IsAscii(U
'5'), "U'5' is ASCII");
101 static_assert(IsAscii(U
'\x7F'), "U'\\x7F' is ASCII");
102 static_assert(!IsAscii(U
'\x80'), "U'\\x80' isn't ASCII");
105 static void TestIsAsciiNullTerminated() {
108 constexpr char allChar
[] =
109 "\x01\x02\x03\x04\x05\x06\x07\x08\x09\x0A\x0B\0x0C\x0D\x0E\x0F"
110 "\x11\x12\x13\x14\x15\x16\x17\x18\x19\x1A\x1B\0x1C\x1D\x1E\x1F"
111 "\x21\x22\x23\x24\x25\x26\x27\x28\x29\x2A\x2B\0x2C\x2D\x2E\x2F"
112 "\x31\x32\x33\x34\x35\x36\x37\x38\x39\x3A\x3B\0x3C\x3D\x3E\x3F"
113 "\x41\x42\x43\x44\x45\x46\x47\x48\x49\x4A\x4B\0x4C\x4D\x4E\x4F"
114 "\x51\x52\x53\x54\x55\x56\x57\x58\x59\x5A\x5B\0x5C\x5D\x5E\x5F"
115 "\x61\x62\x63\x64\x65\x66\x67\x68\x69\x6A\x6B\0x6C\x6D\x6E\x6F"
116 "\x71\x72\x73\x74\x75\x76\x77\x78\x79\x7A\x7B\0x7C\x7D\x7E\x7F";
118 static_assert(IsAsciiNullTerminated(allChar
), "allChar is ASCII");
120 constexpr char loBadChar
[] = "\x80";
122 static_assert(!IsAsciiNullTerminated(loBadChar
), "loBadChar isn't ASCII");
124 constexpr char hiBadChar
[] = "\xFF";
126 static_assert(!IsAsciiNullTerminated(hiBadChar
), "hiBadChar isn't ASCII");
130 constexpr char16_t allChar16
[] =
131 u
"\x01\x02\x03\x04\x05\x06\x07\x08\x09\x0A\x0B\0x0C\x0D\x0E\x0F"
132 "\x11\x12\x13\x14\x15\x16\x17\x18\x19\x1A\x1B\0x1C\x1D\x1E\x1F"
133 "\x21\x22\x23\x24\x25\x26\x27\x28\x29\x2A\x2B\0x2C\x2D\x2E\x2F"
134 "\x31\x32\x33\x34\x35\x36\x37\x38\x39\x3A\x3B\0x3C\x3D\x3E\x3F"
135 "\x41\x42\x43\x44\x45\x46\x47\x48\x49\x4A\x4B\0x4C\x4D\x4E\x4F"
136 "\x51\x52\x53\x54\x55\x56\x57\x58\x59\x5A\x5B\0x5C\x5D\x5E\x5F"
137 "\x61\x62\x63\x64\x65\x66\x67\x68\x69\x6A\x6B\0x6C\x6D\x6E\x6F"
138 "\x71\x72\x73\x74\x75\x76\x77\x78\x79\x7A\x7B\0x7C\x7D\x7E\x7F";
140 static_assert(IsAsciiNullTerminated(allChar16
), "allChar16 is ASCII");
142 constexpr char16_t loBadChar16
[] = u
"\x80";
144 static_assert(!IsAsciiNullTerminated(loBadChar16
), "loBadChar16 isn't ASCII");
146 constexpr char16_t hiBadChar16
[] = u
"\xFF";
148 static_assert(!IsAsciiNullTerminated(hiBadChar16
), "hiBadChar16 isn't ASCII");
150 constexpr char16_t highestChar16
[] = u
"\uFFFF";
152 static_assert(!IsAsciiNullTerminated(highestChar16
),
153 "highestChar16 isn't ASCII");
157 constexpr char32_t allChar32
[] =
158 U
"\x01\x02\x03\x04\x05\x06\x07\x08\x09\x0A\x0B\0x0C\x0D\x0E\x0F"
159 "\x11\x12\x13\x14\x15\x16\x17\x18\x19\x1A\x1B\0x1C\x1D\x1E\x1F"
160 "\x21\x22\x23\x24\x25\x26\x27\x28\x29\x2A\x2B\0x2C\x2D\x2E\x2F"
161 "\x31\x32\x33\x34\x35\x36\x37\x38\x39\x3A\x3B\0x3C\x3D\x3E\x3F"
162 "\x41\x42\x43\x44\x45\x46\x47\x48\x49\x4A\x4B\0x4C\x4D\x4E\x4F"
163 "\x51\x52\x53\x54\x55\x56\x57\x58\x59\x5A\x5B\0x5C\x5D\x5E\x5F"
164 "\x61\x62\x63\x64\x65\x66\x67\x68\x69\x6A\x6B\0x6C\x6D\x6E\x6F"
165 "\x71\x72\x73\x74\x75\x76\x77\x78\x79\x7A\x7B\0x7C\x7D\x7E\x7F";
167 static_assert(IsAsciiNullTerminated(allChar32
), "allChar32 is ASCII");
169 constexpr char32_t loBadChar32
[] = U
"\x80";
171 static_assert(!IsAsciiNullTerminated(loBadChar32
), "loBadChar32 isn't ASCII");
173 constexpr char32_t hiBadChar32
[] = U
"\xFF";
175 static_assert(!IsAsciiNullTerminated(hiBadChar32
), "hiBadChar32 isn't ASCII");
177 constexpr char32_t highestChar32
[] = {static_cast<char32_t
>(-1), 0};
179 static_assert(!IsAsciiNullTerminated(highestChar32
),
180 "highestChar32 isn't ASCII");
183 static void TestIsAsciiAlpha() {
186 static_assert(!IsAsciiAlpha('@'), "'@' isn't ASCII alpha");
187 static_assert('@' == 0x40, "'@' has value 0x40");
189 static_assert('A' == 0x41, "'A' has value 0x41");
190 static_assert(IsAsciiAlpha('A'), "'A' is ASCII alpha");
191 static_assert(IsAsciiAlpha('B'), "'B' is ASCII alpha");
192 static_assert(IsAsciiAlpha('M'), "'M' is ASCII alpha");
193 static_assert(IsAsciiAlpha('Y'), "'Y' is ASCII alpha");
194 static_assert(IsAsciiAlpha('Z'), "'Z' is ASCII alpha");
196 static_assert('Z' == 0x5A, "'Z' has value 0x5A");
197 static_assert('[' == 0x5B, "'[' has value 0x5B");
198 static_assert(!IsAsciiAlpha('['), "'[' isn't ASCII alpha");
200 static_assert(!IsAsciiAlpha('`'), "'`' isn't ASCII alpha");
201 static_assert('`' == 0x60, "'`' has value 0x60");
203 static_assert('a' == 0x61, "'a' has value 0x61");
204 static_assert(IsAsciiAlpha('a'), "'a' is ASCII alpha");
205 static_assert(IsAsciiAlpha('b'), "'b' is ASCII alpha");
206 static_assert(IsAsciiAlpha('m'), "'m' is ASCII alpha");
207 static_assert(IsAsciiAlpha('y'), "'y' is ASCII alpha");
208 static_assert(IsAsciiAlpha('z'), "'z' is ASCII alpha");
210 static_assert('z' == 0x7A, "'z' has value 0x7A");
211 static_assert('{' == 0x7B, "'{' has value 0x7B");
212 static_assert(!IsAsciiAlpha('{'), "'{' isn't ASCII alpha");
214 static_assert(!IsAsciiAlpha('5'), "'5' isn't ASCII alpha");
218 static_assert(!IsAsciiAlpha(u
'@'), "u'@' isn't ASCII alpha");
219 static_assert(u
'@' == 0x40, "u'@' has value 0x40");
221 static_assert(u
'A' == 0x41, "u'A' has value 0x41");
222 static_assert(IsAsciiAlpha(u
'A'), "u'A' is ASCII alpha");
223 static_assert(IsAsciiAlpha(u
'B'), "u'B' is ASCII alpha");
224 static_assert(IsAsciiAlpha(u
'M'), "u'M' is ASCII alpha");
225 static_assert(IsAsciiAlpha(u
'Y'), "u'Y' is ASCII alpha");
226 static_assert(IsAsciiAlpha(u
'Z'), "u'Z' is ASCII alpha");
228 static_assert(u
'Z' == 0x5A, "u'Z' has value 0x5A");
229 static_assert(u
'[' == 0x5B, "u'[' has value 0x5B");
230 static_assert(!IsAsciiAlpha(u
'['), "u'[' isn't ASCII alpha");
232 static_assert(!IsAsciiAlpha(u
'`'), "u'`' isn't ASCII alpha");
233 static_assert(u
'`' == 0x60, "u'`' has value 0x60");
235 static_assert(u
'a' == 0x61, "u'a' has value 0x61");
236 static_assert(IsAsciiAlpha(u
'a'), "u'a' is ASCII alpha");
237 static_assert(IsAsciiAlpha(u
'b'), "u'b' is ASCII alpha");
238 static_assert(IsAsciiAlpha(u
'm'), "u'm' is ASCII alpha");
239 static_assert(IsAsciiAlpha(u
'y'), "u'y' is ASCII alpha");
240 static_assert(IsAsciiAlpha(u
'z'), "u'z' is ASCII alpha");
242 static_assert(u
'z' == 0x7A, "u'z' has value 0x7A");
243 static_assert(u
'{' == 0x7B, "u'{' has value 0x7B");
244 static_assert(!IsAsciiAlpha(u
'{'), "u'{' isn't ASCII alpha");
246 static_assert(!IsAsciiAlpha(u
'5'), "u'5' isn't ASCII alpha");
250 static_assert(!IsAsciiAlpha(U
'@'), "U'@' isn't ASCII alpha");
251 static_assert(U
'@' == 0x40, "U'@' has value 0x40");
253 static_assert(U
'A' == 0x41, "U'A' has value 0x41");
254 static_assert(IsAsciiAlpha(U
'A'), "U'A' is ASCII alpha");
255 static_assert(IsAsciiAlpha(U
'B'), "U'B' is ASCII alpha");
256 static_assert(IsAsciiAlpha(U
'M'), "U'M' is ASCII alpha");
257 static_assert(IsAsciiAlpha(U
'Y'), "U'Y' is ASCII alpha");
258 static_assert(IsAsciiAlpha(U
'Z'), "U'Z' is ASCII alpha");
260 static_assert(U
'Z' == 0x5A, "U'Z' has value 0x5A");
261 static_assert(U
'[' == 0x5B, "U'[' has value 0x5B");
262 static_assert(!IsAsciiAlpha(U
'['), "U'[' isn't ASCII alpha");
264 static_assert(!IsAsciiAlpha(U
'`'), "U'`' isn't ASCII alpha");
265 static_assert(U
'`' == 0x60, "U'`' has value 0x60");
267 static_assert(U
'a' == 0x61, "U'a' has value 0x61");
268 static_assert(IsAsciiAlpha(U
'a'), "U'a' is ASCII alpha");
269 static_assert(IsAsciiAlpha(U
'b'), "U'b' is ASCII alpha");
270 static_assert(IsAsciiAlpha(U
'm'), "U'm' is ASCII alpha");
271 static_assert(IsAsciiAlpha(U
'y'), "U'y' is ASCII alpha");
272 static_assert(IsAsciiAlpha(U
'z'), "U'z' is ASCII alpha");
274 static_assert(U
'z' == 0x7A, "U'z' has value 0x7A");
275 static_assert(U
'{' == 0x7B, "U'{' has value 0x7B");
276 static_assert(!IsAsciiAlpha(U
'{'), "U'{' isn't ASCII alpha");
278 static_assert(!IsAsciiAlpha(U
'5'), "U'5' isn't ASCII alpha");
281 static void TestIsAsciiUppercaseAlpha() {
284 static_assert(!IsAsciiUppercaseAlpha('@'), "'@' isn't ASCII alpha uppercase");
285 static_assert('@' == 0x40, "'@' has value 0x40");
287 static_assert('A' == 0x41, "'A' has value 0x41");
288 static_assert(IsAsciiUppercaseAlpha('A'), "'A' is ASCII alpha uppercase");
289 static_assert(IsAsciiUppercaseAlpha('B'), "'B' is ASCII alpha uppercase");
290 static_assert(IsAsciiUppercaseAlpha('M'), "'M' is ASCII alpha uppercase");
291 static_assert(IsAsciiUppercaseAlpha('Y'), "'Y' is ASCII alpha uppercase");
292 static_assert(IsAsciiUppercaseAlpha('Z'), "'Z' is ASCII alpha uppercase");
294 static_assert('Z' == 0x5A, "'Z' has value 0x5A");
295 static_assert('[' == 0x5B, "'[' has value 0x5B");
296 static_assert(!IsAsciiUppercaseAlpha('['), "'[' isn't ASCII alpha uppercase");
298 static_assert(!IsAsciiUppercaseAlpha('`'), "'`' isn't ASCII alpha uppercase");
299 static_assert(!IsAsciiUppercaseAlpha('a'), "'a' is ASCII alpha uppercase");
300 static_assert(!IsAsciiUppercaseAlpha('b'), "'b' is ASCII alpha uppercase");
301 static_assert(!IsAsciiUppercaseAlpha('m'), "'m' is ASCII alpha uppercase");
302 static_assert(!IsAsciiUppercaseAlpha('y'), "'y' is ASCII alpha uppercase");
303 static_assert(!IsAsciiUppercaseAlpha('z'), "'z' is ASCII alpha uppercase");
304 static_assert(!IsAsciiUppercaseAlpha('{'), "'{' isn't ASCII alpha uppercase");
308 static_assert(!IsAsciiUppercaseAlpha(u
'@'),
309 "u'@' isn't ASCII alpha uppercase");
310 static_assert(u
'@' == 0x40, "u'@' has value 0x40");
312 static_assert(u
'A' == 0x41, "u'A' has value 0x41");
313 static_assert(IsAsciiUppercaseAlpha(u
'A'), "u'A' is ASCII alpha uppercase");
314 static_assert(IsAsciiUppercaseAlpha(u
'B'), "u'B' is ASCII alpha uppercase");
315 static_assert(IsAsciiUppercaseAlpha(u
'M'), "u'M' is ASCII alpha uppercase");
316 static_assert(IsAsciiUppercaseAlpha(u
'Y'), "u'Y' is ASCII alpha uppercase");
317 static_assert(IsAsciiUppercaseAlpha(u
'Z'), "u'Z' is ASCII alpha uppercase");
319 static_assert(u
'Z' == 0x5A, "u'Z' has value 0x5A");
320 static_assert(u
'[' == 0x5B, "u'[' has value 0x5B");
321 static_assert(!IsAsciiUppercaseAlpha(u
'['),
322 "u'[' isn't ASCII alpha uppercase");
324 static_assert(!IsAsciiUppercaseAlpha(u
'`'),
325 "u'`' isn't ASCII alpha uppercase");
326 static_assert(!IsAsciiUppercaseAlpha(u
'a'), "u'a' is ASCII alpha uppercase");
327 static_assert(!IsAsciiUppercaseAlpha(u
'b'), "u'b' is ASCII alpha uppercase");
328 static_assert(!IsAsciiUppercaseAlpha(u
'm'), "u'm' is ASCII alpha uppercase");
329 static_assert(!IsAsciiUppercaseAlpha(u
'y'), "u'y' is ASCII alpha uppercase");
330 static_assert(!IsAsciiUppercaseAlpha(u
'z'), "u'z' is ASCII alpha uppercase");
331 static_assert(!IsAsciiUppercaseAlpha(u
'{'),
332 "u'{' isn't ASCII alpha uppercase");
336 static_assert(!IsAsciiUppercaseAlpha(U
'@'),
337 "U'@' isn't ASCII alpha uppercase");
338 static_assert(U
'@' == 0x40, "U'@' has value 0x40");
340 static_assert(U
'A' == 0x41, "U'A' has value 0x41");
341 static_assert(IsAsciiUppercaseAlpha(U
'A'), "U'A' is ASCII alpha uppercase");
342 static_assert(IsAsciiUppercaseAlpha(U
'B'), "U'B' is ASCII alpha uppercase");
343 static_assert(IsAsciiUppercaseAlpha(U
'M'), "U'M' is ASCII alpha uppercase");
344 static_assert(IsAsciiUppercaseAlpha(U
'Y'), "U'Y' is ASCII alpha uppercase");
345 static_assert(IsAsciiUppercaseAlpha(U
'Z'), "U'Z' is ASCII alpha uppercase");
347 static_assert(U
'Z' == 0x5A, "U'Z' has value 0x5A");
348 static_assert(U
'[' == 0x5B, "U'[' has value 0x5B");
349 static_assert(!IsAsciiUppercaseAlpha(U
'['),
350 "U'[' isn't ASCII alpha uppercase");
352 static_assert(!IsAsciiUppercaseAlpha(U
'`'),
353 "U'`' isn't ASCII alpha uppercase");
354 static_assert(!IsAsciiUppercaseAlpha(U
'a'), "U'a' is ASCII alpha uppercase");
355 static_assert(!IsAsciiUppercaseAlpha(U
'b'), "U'b' is ASCII alpha uppercase");
356 static_assert(!IsAsciiUppercaseAlpha(U
'm'), "U'm' is ASCII alpha uppercase");
357 static_assert(!IsAsciiUppercaseAlpha(U
'y'), "U'y' is ASCII alpha uppercase");
358 static_assert(!IsAsciiUppercaseAlpha(U
'z'), "U'z' is ASCII alpha uppercase");
359 static_assert(!IsAsciiUppercaseAlpha(U
'{'),
360 "U'{' isn't ASCII alpha uppercase");
363 static void TestIsAsciiLowercaseAlpha() {
366 static_assert(!IsAsciiLowercaseAlpha('`'), "'`' isn't ASCII alpha lowercase");
367 static_assert('`' == 0x60, "'`' has value 0x60");
369 static_assert('a' == 0x61, "'a' has value 0x61");
370 static_assert(IsAsciiLowercaseAlpha('a'), "'a' is ASCII alpha lowercase");
371 static_assert(IsAsciiLowercaseAlpha('b'), "'b' is ASCII alpha lowercase");
372 static_assert(IsAsciiLowercaseAlpha('m'), "'m' is ASCII alpha lowercase");
373 static_assert(IsAsciiLowercaseAlpha('y'), "'y' is ASCII alpha lowercase");
374 static_assert(IsAsciiLowercaseAlpha('z'), "'z' is ASCII alpha lowercase");
376 static_assert('z' == 0x7A, "'z' has value 0x7A");
377 static_assert('{' == 0x7B, "'{' has value 0x7B");
378 static_assert(!IsAsciiLowercaseAlpha('{'), "'{' isn't ASCII alpha lowercase");
380 static_assert(!IsAsciiLowercaseAlpha('@'), "'@' isn't ASCII alpha lowercase");
381 static_assert(!IsAsciiLowercaseAlpha('A'), "'A' is ASCII alpha lowercase");
382 static_assert(!IsAsciiLowercaseAlpha('B'), "'B' is ASCII alpha lowercase");
383 static_assert(!IsAsciiLowercaseAlpha('M'), "'M' is ASCII alpha lowercase");
384 static_assert(!IsAsciiLowercaseAlpha('Y'), "'Y' is ASCII alpha lowercase");
385 static_assert(!IsAsciiLowercaseAlpha('Z'), "'Z' is ASCII alpha lowercase");
386 static_assert(!IsAsciiLowercaseAlpha('['), "'[' isn't ASCII alpha lowercase");
390 static_assert(!IsAsciiLowercaseAlpha(u
'`'),
391 "u'`' isn't ASCII alpha lowercase");
392 static_assert(u
'`' == 0x60, "u'`' has value 0x60");
394 static_assert(u
'a' == 0x61, "u'a' has value 0x61");
395 static_assert(IsAsciiLowercaseAlpha(u
'a'), "u'a' is ASCII alpha lowercase");
396 static_assert(IsAsciiLowercaseAlpha(u
'b'), "u'b' is ASCII alpha lowercase");
397 static_assert(IsAsciiLowercaseAlpha(u
'm'), "u'm' is ASCII alpha lowercase");
398 static_assert(IsAsciiLowercaseAlpha(u
'y'), "u'y' is ASCII alpha lowercase");
399 static_assert(IsAsciiLowercaseAlpha(u
'z'), "u'z' is ASCII alpha lowercase");
401 static_assert(u
'z' == 0x7A, "u'z' has value 0x7A");
402 static_assert(u
'{' == 0x7B, "u'{' has value 0x7B");
403 static_assert(!IsAsciiLowercaseAlpha(u
'{'),
404 "u'{' isn't ASCII alpha lowercase");
406 static_assert(!IsAsciiLowercaseAlpha(u
'@'),
407 "u'@' isn't ASCII alpha lowercase");
408 static_assert(!IsAsciiLowercaseAlpha(u
'A'), "u'A' is ASCII alpha lowercase");
409 static_assert(!IsAsciiLowercaseAlpha(u
'B'), "u'B' is ASCII alpha lowercase");
410 static_assert(!IsAsciiLowercaseAlpha(u
'M'), "u'M' is ASCII alpha lowercase");
411 static_assert(!IsAsciiLowercaseAlpha(u
'Y'), "u'Y' is ASCII alpha lowercase");
412 static_assert(!IsAsciiLowercaseAlpha(u
'Z'), "u'Z' is ASCII alpha lowercase");
413 static_assert(!IsAsciiLowercaseAlpha(u
'['),
414 "u'[' isn't ASCII alpha lowercase");
418 static_assert(!IsAsciiLowercaseAlpha(U
'`'),
419 "U'`' isn't ASCII alpha lowercase");
420 static_assert(U
'`' == 0x60, "U'`' has value 0x60");
422 static_assert(U
'a' == 0x61, "U'a' has value 0x61");
423 static_assert(IsAsciiLowercaseAlpha(U
'a'), "U'a' is ASCII alpha lowercase");
424 static_assert(IsAsciiLowercaseAlpha(U
'b'), "U'b' is ASCII alpha lowercase");
425 static_assert(IsAsciiLowercaseAlpha(U
'm'), "U'm' is ASCII alpha lowercase");
426 static_assert(IsAsciiLowercaseAlpha(U
'y'), "U'y' is ASCII alpha lowercase");
427 static_assert(IsAsciiLowercaseAlpha(U
'z'), "U'z' is ASCII alpha lowercase");
429 static_assert(U
'z' == 0x7A, "U'z' has value 0x7A");
430 static_assert(U
'{' == 0x7B, "U'{' has value 0x7B");
431 static_assert(!IsAsciiLowercaseAlpha(U
'{'),
432 "U'{' isn't ASCII alpha lowercase");
434 static_assert(!IsAsciiLowercaseAlpha(U
'@'),
435 "U'@' isn't ASCII alpha lowercase");
436 static_assert(!IsAsciiLowercaseAlpha(U
'A'), "U'A' is ASCII alpha lowercase");
437 static_assert(!IsAsciiLowercaseAlpha(U
'B'), "U'B' is ASCII alpha lowercase");
438 static_assert(!IsAsciiLowercaseAlpha(U
'M'), "U'M' is ASCII alpha lowercase");
439 static_assert(!IsAsciiLowercaseAlpha(U
'Y'), "U'Y' is ASCII alpha lowercase");
440 static_assert(!IsAsciiLowercaseAlpha(U
'Z'), "U'Z' is ASCII alpha lowercase");
441 static_assert(!IsAsciiLowercaseAlpha(U
'['),
442 "U'[' isn't ASCII alpha lowercase");
445 static void TestIsAsciiAlphanumeric() {
448 static_assert(!IsAsciiAlphanumeric('/'), "'/' isn't ASCII alphanumeric");
449 static_assert('/' == 0x2F, "'/' has value 0x2F");
451 static_assert('0' == 0x30, "'0' has value 0x30");
452 static_assert(IsAsciiAlphanumeric('0'), "'0' is ASCII alphanumeric");
453 static_assert(IsAsciiAlphanumeric('1'), "'1' is ASCII alphanumeric");
454 static_assert(IsAsciiAlphanumeric('5'), "'5' is ASCII alphanumeric");
455 static_assert(IsAsciiAlphanumeric('8'), "'8' is ASCII alphanumeric");
456 static_assert(IsAsciiAlphanumeric('9'), "'9' is ASCII alphanumeric");
458 static_assert('9' == 0x39, "'9' has value 0x39");
459 static_assert(':' == 0x3A, "':' has value 0x3A");
460 static_assert(!IsAsciiAlphanumeric(':'), "':' isn't ASCII alphanumeric");
462 static_assert(!IsAsciiAlphanumeric('@'), "'@' isn't ASCII alphanumeric");
463 static_assert('@' == 0x40, "'@' has value 0x40");
465 static_assert('A' == 0x41, "'A' has value 0x41");
466 static_assert(IsAsciiAlphanumeric('A'), "'A' is ASCII alphanumeric");
467 static_assert(IsAsciiAlphanumeric('B'), "'B' is ASCII alphanumeric");
468 static_assert(IsAsciiAlphanumeric('M'), "'M' is ASCII alphanumeric");
469 static_assert(IsAsciiAlphanumeric('Y'), "'Y' is ASCII alphanumeric");
470 static_assert(IsAsciiAlphanumeric('Z'), "'Z' is ASCII alphanumeric");
472 static_assert('Z' == 0x5A, "'Z' has value 0x5A");
473 static_assert('[' == 0x5B, "'[' has value 0x5B");
474 static_assert(!IsAsciiAlphanumeric('['), "'[' isn't ASCII alphanumeric");
476 static_assert(!IsAsciiAlphanumeric('`'), "'`' isn't ASCII alphanumeric");
477 static_assert('`' == 0x60, "'`' has value 0x60");
479 static_assert('a' == 0x61, "'a' has value 0x61");
480 static_assert(IsAsciiAlphanumeric('a'), "'a' is ASCII alphanumeric");
481 static_assert(IsAsciiAlphanumeric('b'), "'b' is ASCII alphanumeric");
482 static_assert(IsAsciiAlphanumeric('m'), "'m' is ASCII alphanumeric");
483 static_assert(IsAsciiAlphanumeric('y'), "'y' is ASCII alphanumeric");
484 static_assert(IsAsciiAlphanumeric('z'), "'z' is ASCII alphanumeric");
486 static_assert('z' == 0x7A, "'z' has value 0x7A");
487 static_assert('{' == 0x7B, "'{' has value 0x7B");
488 static_assert(!IsAsciiAlphanumeric('{'), "'{' isn't ASCII alphanumeric");
492 static_assert(!IsAsciiAlphanumeric(u
'/'), "u'/' isn't ASCII alphanumeric");
493 static_assert(u
'/' == 0x2F, "u'/' has value 0x2F");
495 static_assert(u
'0' == 0x30, "u'0' has value 0x30");
496 static_assert(IsAsciiAlphanumeric(u
'0'), "u'0' is ASCII alphanumeric");
497 static_assert(IsAsciiAlphanumeric(u
'1'), "u'1' is ASCII alphanumeric");
498 static_assert(IsAsciiAlphanumeric(u
'5'), "u'5' is ASCII alphanumeric");
499 static_assert(IsAsciiAlphanumeric(u
'8'), "u'8' is ASCII alphanumeric");
500 static_assert(IsAsciiAlphanumeric(u
'9'), "u'9' is ASCII alphanumeric");
502 static_assert(u
'9' == 0x39, "u'9' has value 0x39");
503 static_assert(u
':' == 0x3A, "u':' has value 0x3A");
504 static_assert(!IsAsciiAlphanumeric(u
':'), "u':' isn't ASCII alphanumeric");
506 static_assert(!IsAsciiAlphanumeric(u
'@'), "u'@' isn't ASCII alphanumeric");
507 static_assert(u
'@' == 0x40, "u'@' has value 0x40");
509 static_assert(u
'A' == 0x41, "u'A' has value 0x41");
510 static_assert(IsAsciiAlphanumeric(u
'A'), "u'A' is ASCII alphanumeric");
511 static_assert(IsAsciiAlphanumeric(u
'B'), "u'B' is ASCII alphanumeric");
512 static_assert(IsAsciiAlphanumeric(u
'M'), "u'M' is ASCII alphanumeric");
513 static_assert(IsAsciiAlphanumeric(u
'Y'), "u'Y' is ASCII alphanumeric");
514 static_assert(IsAsciiAlphanumeric(u
'Z'), "u'Z' is ASCII alphanumeric");
516 static_assert(u
'Z' == 0x5A, "u'Z' has value 0x5A");
517 static_assert(u
'[' == 0x5B, "u'[' has value 0x5B");
518 static_assert(!IsAsciiAlphanumeric(u
'['), "u'[' isn't ASCII alphanumeric");
520 static_assert(!IsAsciiAlphanumeric(u
'`'), "u'`' isn't ASCII alphanumeric");
521 static_assert(u
'`' == 0x60, "u'`' has value 0x60");
523 static_assert(u
'a' == 0x61, "u'a' has value 0x61");
524 static_assert(IsAsciiAlphanumeric(u
'a'), "u'a' is ASCII alphanumeric");
525 static_assert(IsAsciiAlphanumeric(u
'b'), "u'b' is ASCII alphanumeric");
526 static_assert(IsAsciiAlphanumeric(u
'm'), "u'm' is ASCII alphanumeric");
527 static_assert(IsAsciiAlphanumeric(u
'y'), "u'y' is ASCII alphanumeric");
528 static_assert(IsAsciiAlphanumeric(u
'z'), "u'z' is ASCII alphanumeric");
530 static_assert(u
'z' == 0x7A, "u'z' has value 0x7A");
531 static_assert(u
'{' == 0x7B, "u'{' has value 0x7B");
532 static_assert(!IsAsciiAlphanumeric(u
'{'), "u'{' isn't ASCII alphanumeric");
536 static_assert(!IsAsciiAlphanumeric(U
'/'), "U'/' isn't ASCII alphanumeric");
537 static_assert(U
'/' == 0x2F, "U'/' has value 0x2F");
539 static_assert(U
'0' == 0x30, "U'0' has value 0x30");
540 static_assert(IsAsciiAlphanumeric(U
'0'), "U'0' is ASCII alphanumeric");
541 static_assert(IsAsciiAlphanumeric(U
'1'), "U'1' is ASCII alphanumeric");
542 static_assert(IsAsciiAlphanumeric(U
'5'), "U'5' is ASCII alphanumeric");
543 static_assert(IsAsciiAlphanumeric(U
'8'), "U'8' is ASCII alphanumeric");
544 static_assert(IsAsciiAlphanumeric(U
'9'), "U'9' is ASCII alphanumeric");
546 static_assert(U
'9' == 0x39, "U'9' has value 0x39");
547 static_assert(U
':' == 0x3A, "U':' has value 0x3A");
548 static_assert(!IsAsciiAlphanumeric(U
':'), "U':' isn't ASCII alphanumeric");
550 static_assert(!IsAsciiAlphanumeric(U
'@'), "U'@' isn't ASCII alphanumeric");
551 static_assert(U
'@' == 0x40, "U'@' has value 0x40");
553 static_assert(U
'A' == 0x41, "U'A' has value 0x41");
554 static_assert(IsAsciiAlphanumeric(U
'A'), "U'A' is ASCII alphanumeric");
555 static_assert(IsAsciiAlphanumeric(U
'B'), "U'B' is ASCII alphanumeric");
556 static_assert(IsAsciiAlphanumeric(U
'M'), "U'M' is ASCII alphanumeric");
557 static_assert(IsAsciiAlphanumeric(U
'Y'), "U'Y' is ASCII alphanumeric");
558 static_assert(IsAsciiAlphanumeric(U
'Z'), "U'Z' is ASCII alphanumeric");
560 static_assert(U
'Z' == 0x5A, "U'Z' has value 0x5A");
561 static_assert(U
'[' == 0x5B, "U'[' has value 0x5B");
562 static_assert(!IsAsciiAlphanumeric(U
'['), "U'[' isn't ASCII alphanumeric");
564 static_assert(!IsAsciiAlphanumeric(U
'`'), "U'`' isn't ASCII alphanumeric");
565 static_assert(U
'`' == 0x60, "U'`' has value 0x60");
567 static_assert(U
'a' == 0x61, "U'a' has value 0x61");
568 static_assert(IsAsciiAlphanumeric(U
'a'), "U'a' is ASCII alphanumeric");
569 static_assert(IsAsciiAlphanumeric(U
'b'), "U'b' is ASCII alphanumeric");
570 static_assert(IsAsciiAlphanumeric(U
'm'), "U'm' is ASCII alphanumeric");
571 static_assert(IsAsciiAlphanumeric(U
'y'), "U'y' is ASCII alphanumeric");
572 static_assert(IsAsciiAlphanumeric(U
'z'), "U'z' is ASCII alphanumeric");
574 static_assert(U
'z' == 0x7A, "U'z' has value 0x7A");
575 static_assert(U
'{' == 0x7B, "U'{' has value 0x7B");
576 static_assert(!IsAsciiAlphanumeric(U
'{'), "U'{' isn't ASCII alphanumeric");
579 static void TestAsciiAlphanumericToNumber() {
580 // When AsciiAlphanumericToNumber becomes constexpr, make sure to convert all
581 // these to just static_assert.
585 MOZ_RELEASE_ASSERT(AsciiAlphanumericToNumber('0') == 0, "'0' converts to 0");
586 MOZ_RELEASE_ASSERT(AsciiAlphanumericToNumber('1') == 1, "'1' converts to 1");
587 MOZ_RELEASE_ASSERT(AsciiAlphanumericToNumber('2') == 2, "'2' converts to 2");
588 MOZ_RELEASE_ASSERT(AsciiAlphanumericToNumber('3') == 3, "'3' converts to 3");
589 MOZ_RELEASE_ASSERT(AsciiAlphanumericToNumber('4') == 4, "'4' converts to 4");
590 MOZ_RELEASE_ASSERT(AsciiAlphanumericToNumber('5') == 5, "'5' converts to 5");
591 MOZ_RELEASE_ASSERT(AsciiAlphanumericToNumber('6') == 6, "'6' converts to 6");
592 MOZ_RELEASE_ASSERT(AsciiAlphanumericToNumber('7') == 7, "'7' converts to 7");
593 MOZ_RELEASE_ASSERT(AsciiAlphanumericToNumber('8') == 8, "'8' converts to 8");
594 MOZ_RELEASE_ASSERT(AsciiAlphanumericToNumber('9') == 9, "'9' converts to 9");
596 MOZ_RELEASE_ASSERT(AsciiAlphanumericToNumber('A') == 10,
597 "'A' converts to 10");
598 MOZ_RELEASE_ASSERT(AsciiAlphanumericToNumber('B') == 11,
599 "'B' converts to 11");
600 MOZ_RELEASE_ASSERT(AsciiAlphanumericToNumber('C') == 12,
601 "'C' converts to 12");
602 MOZ_RELEASE_ASSERT(AsciiAlphanumericToNumber('D') == 13,
603 "'D' converts to 13");
604 MOZ_RELEASE_ASSERT(AsciiAlphanumericToNumber('E') == 14,
605 "'E' converts to 14");
606 MOZ_RELEASE_ASSERT(AsciiAlphanumericToNumber('F') == 15,
607 "'F' converts to 15");
608 MOZ_RELEASE_ASSERT(AsciiAlphanumericToNumber('G') == 16,
609 "'G' converts to 16");
610 MOZ_RELEASE_ASSERT(AsciiAlphanumericToNumber('H') == 17,
611 "'H' converts to 17");
612 MOZ_RELEASE_ASSERT(AsciiAlphanumericToNumber('I') == 18,
613 "'I' converts to 18");
614 MOZ_RELEASE_ASSERT(AsciiAlphanumericToNumber('J') == 19,
615 "'J' converts to 19");
616 MOZ_RELEASE_ASSERT(AsciiAlphanumericToNumber('K') == 20,
617 "'K' converts to 20");
618 MOZ_RELEASE_ASSERT(AsciiAlphanumericToNumber('L') == 21,
619 "'L' converts to 21");
620 MOZ_RELEASE_ASSERT(AsciiAlphanumericToNumber('M') == 22,
621 "'M' converts to 22");
622 MOZ_RELEASE_ASSERT(AsciiAlphanumericToNumber('N') == 23,
623 "'N' converts to 23");
624 MOZ_RELEASE_ASSERT(AsciiAlphanumericToNumber('O') == 24,
625 "'O' converts to 24");
626 MOZ_RELEASE_ASSERT(AsciiAlphanumericToNumber('P') == 25,
627 "'P' converts to 25");
628 MOZ_RELEASE_ASSERT(AsciiAlphanumericToNumber('Q') == 26,
629 "'Q' converts to 26");
630 MOZ_RELEASE_ASSERT(AsciiAlphanumericToNumber('R') == 27,
631 "'R' converts to 27");
632 MOZ_RELEASE_ASSERT(AsciiAlphanumericToNumber('S') == 28,
633 "'S' converts to 28");
634 MOZ_RELEASE_ASSERT(AsciiAlphanumericToNumber('T') == 29,
635 "'T' converts to 29");
636 MOZ_RELEASE_ASSERT(AsciiAlphanumericToNumber('U') == 30,
637 "'U' converts to 30");
638 MOZ_RELEASE_ASSERT(AsciiAlphanumericToNumber('V') == 31,
639 "'V' converts to 31");
640 MOZ_RELEASE_ASSERT(AsciiAlphanumericToNumber('W') == 32,
641 "'W' converts to 32");
642 MOZ_RELEASE_ASSERT(AsciiAlphanumericToNumber('X') == 33,
643 "'X' converts to 33");
644 MOZ_RELEASE_ASSERT(AsciiAlphanumericToNumber('Y') == 34,
645 "'Y' converts to 34");
646 MOZ_RELEASE_ASSERT(AsciiAlphanumericToNumber('Z') == 35,
647 "'Z' converts to 35");
649 MOZ_RELEASE_ASSERT(AsciiAlphanumericToNumber('a') == 10,
650 "'a' converts to 10");
651 MOZ_RELEASE_ASSERT(AsciiAlphanumericToNumber('b') == 11,
652 "'b' converts to 11");
653 MOZ_RELEASE_ASSERT(AsciiAlphanumericToNumber('c') == 12,
654 "'c' converts to 12");
655 MOZ_RELEASE_ASSERT(AsciiAlphanumericToNumber('d') == 13,
656 "'d' converts to 13");
657 MOZ_RELEASE_ASSERT(AsciiAlphanumericToNumber('e') == 14,
658 "'e' converts to 14");
659 MOZ_RELEASE_ASSERT(AsciiAlphanumericToNumber('f') == 15,
660 "'f' converts to 15");
661 MOZ_RELEASE_ASSERT(AsciiAlphanumericToNumber('g') == 16,
662 "'g' converts to 16");
663 MOZ_RELEASE_ASSERT(AsciiAlphanumericToNumber('h') == 17,
664 "'h' converts to 17");
665 MOZ_RELEASE_ASSERT(AsciiAlphanumericToNumber('i') == 18,
666 "'i' converts to 18");
667 MOZ_RELEASE_ASSERT(AsciiAlphanumericToNumber('j') == 19,
668 "'j' converts to 19");
669 MOZ_RELEASE_ASSERT(AsciiAlphanumericToNumber('k') == 20,
670 "'k' converts to 20");
671 MOZ_RELEASE_ASSERT(AsciiAlphanumericToNumber('l') == 21,
672 "'l' converts to 21");
673 MOZ_RELEASE_ASSERT(AsciiAlphanumericToNumber('m') == 22,
674 "'m' converts to 22");
675 MOZ_RELEASE_ASSERT(AsciiAlphanumericToNumber('n') == 23,
676 "'n' converts to 23");
677 MOZ_RELEASE_ASSERT(AsciiAlphanumericToNumber('o') == 24,
678 "'o' converts to 24");
679 MOZ_RELEASE_ASSERT(AsciiAlphanumericToNumber('p') == 25,
680 "'p' converts to 25");
681 MOZ_RELEASE_ASSERT(AsciiAlphanumericToNumber('q') == 26,
682 "'q' converts to 26");
683 MOZ_RELEASE_ASSERT(AsciiAlphanumericToNumber('r') == 27,
684 "'r' converts to 27");
685 MOZ_RELEASE_ASSERT(AsciiAlphanumericToNumber('s') == 28,
686 "'s' converts to 28");
687 MOZ_RELEASE_ASSERT(AsciiAlphanumericToNumber('t') == 29,
688 "'t' converts to 29");
689 MOZ_RELEASE_ASSERT(AsciiAlphanumericToNumber('u') == 30,
690 "'u' converts to 30");
691 MOZ_RELEASE_ASSERT(AsciiAlphanumericToNumber('v') == 31,
692 "'v' converts to 31");
693 MOZ_RELEASE_ASSERT(AsciiAlphanumericToNumber('w') == 32,
694 "'w' converts to 32");
695 MOZ_RELEASE_ASSERT(AsciiAlphanumericToNumber('x') == 33,
696 "'x' converts to 33");
697 MOZ_RELEASE_ASSERT(AsciiAlphanumericToNumber('y') == 34,
698 "'y' converts to 34");
699 MOZ_RELEASE_ASSERT(AsciiAlphanumericToNumber('z') == 35,
700 "'z' converts to 35");
704 MOZ_RELEASE_ASSERT(AsciiAlphanumericToNumber(u
'0') == 0,
705 "u'0' converts to 0");
706 MOZ_RELEASE_ASSERT(AsciiAlphanumericToNumber(u
'1') == 1,
707 "u'1' converts to 1");
708 MOZ_RELEASE_ASSERT(AsciiAlphanumericToNumber(u
'2') == 2,
709 "u'2' converts to 2");
710 MOZ_RELEASE_ASSERT(AsciiAlphanumericToNumber(u
'3') == 3,
711 "u'3' converts to 3");
712 MOZ_RELEASE_ASSERT(AsciiAlphanumericToNumber(u
'4') == 4,
713 "u'4' converts to 4");
714 MOZ_RELEASE_ASSERT(AsciiAlphanumericToNumber(u
'5') == 5,
715 "u'5' converts to 5");
716 MOZ_RELEASE_ASSERT(AsciiAlphanumericToNumber(u
'6') == 6,
717 "u'6' converts to 6");
718 MOZ_RELEASE_ASSERT(AsciiAlphanumericToNumber(u
'7') == 7,
719 "u'7' converts to 7");
720 MOZ_RELEASE_ASSERT(AsciiAlphanumericToNumber(u
'8') == 8,
721 "u'8' converts to 8");
722 MOZ_RELEASE_ASSERT(AsciiAlphanumericToNumber(u
'9') == 9,
723 "u'9' converts to 9");
725 MOZ_RELEASE_ASSERT(AsciiAlphanumericToNumber(u
'A') == 10,
726 "u'A' converts to 10");
727 MOZ_RELEASE_ASSERT(AsciiAlphanumericToNumber(u
'B') == 11,
728 "u'B' converts to 11");
729 MOZ_RELEASE_ASSERT(AsciiAlphanumericToNumber(u
'C') == 12,
730 "u'C' converts to 12");
731 MOZ_RELEASE_ASSERT(AsciiAlphanumericToNumber(u
'D') == 13,
732 "u'D' converts to 13");
733 MOZ_RELEASE_ASSERT(AsciiAlphanumericToNumber(u
'E') == 14,
734 "u'E' converts to 14");
735 MOZ_RELEASE_ASSERT(AsciiAlphanumericToNumber(u
'F') == 15,
736 "u'F' converts to 15");
737 MOZ_RELEASE_ASSERT(AsciiAlphanumericToNumber(u
'G') == 16,
738 "u'G' converts to 16");
739 MOZ_RELEASE_ASSERT(AsciiAlphanumericToNumber(u
'H') == 17,
740 "u'H' converts to 17");
741 MOZ_RELEASE_ASSERT(AsciiAlphanumericToNumber(u
'I') == 18,
742 "u'I' converts to 18");
743 MOZ_RELEASE_ASSERT(AsciiAlphanumericToNumber(u
'J') == 19,
744 "u'J' converts to 19");
745 MOZ_RELEASE_ASSERT(AsciiAlphanumericToNumber(u
'K') == 20,
746 "u'K' converts to 20");
747 MOZ_RELEASE_ASSERT(AsciiAlphanumericToNumber(u
'L') == 21,
748 "u'L' converts to 21");
749 MOZ_RELEASE_ASSERT(AsciiAlphanumericToNumber(u
'M') == 22,
750 "u'M' converts to 22");
751 MOZ_RELEASE_ASSERT(AsciiAlphanumericToNumber(u
'N') == 23,
752 "u'N' converts to 23");
753 MOZ_RELEASE_ASSERT(AsciiAlphanumericToNumber(u
'O') == 24,
754 "u'O' converts to 24");
755 MOZ_RELEASE_ASSERT(AsciiAlphanumericToNumber(u
'P') == 25,
756 "u'P' converts to 25");
757 MOZ_RELEASE_ASSERT(AsciiAlphanumericToNumber(u
'Q') == 26,
758 "u'Q' converts to 26");
759 MOZ_RELEASE_ASSERT(AsciiAlphanumericToNumber(u
'R') == 27,
760 "u'R' converts to 27");
761 MOZ_RELEASE_ASSERT(AsciiAlphanumericToNumber(u
'S') == 28,
762 "u'S' converts to 28");
763 MOZ_RELEASE_ASSERT(AsciiAlphanumericToNumber(u
'T') == 29,
764 "u'T' converts to 29");
765 MOZ_RELEASE_ASSERT(AsciiAlphanumericToNumber(u
'U') == 30,
766 "u'U' converts to 30");
767 MOZ_RELEASE_ASSERT(AsciiAlphanumericToNumber(u
'V') == 31,
768 "u'V' converts to 31");
769 MOZ_RELEASE_ASSERT(AsciiAlphanumericToNumber(u
'W') == 32,
770 "u'W' converts to 32");
771 MOZ_RELEASE_ASSERT(AsciiAlphanumericToNumber(u
'X') == 33,
772 "u'X' converts to 33");
773 MOZ_RELEASE_ASSERT(AsciiAlphanumericToNumber(u
'Y') == 34,
774 "u'Y' converts to 34");
775 MOZ_RELEASE_ASSERT(AsciiAlphanumericToNumber(u
'Z') == 35,
776 "u'Z' converts to 35");
778 MOZ_RELEASE_ASSERT(AsciiAlphanumericToNumber(u
'a') == 10,
779 "u'a' converts to 10");
780 MOZ_RELEASE_ASSERT(AsciiAlphanumericToNumber(u
'b') == 11,
781 "u'b' converts to 11");
782 MOZ_RELEASE_ASSERT(AsciiAlphanumericToNumber(u
'c') == 12,
783 "u'c' converts to 12");
784 MOZ_RELEASE_ASSERT(AsciiAlphanumericToNumber(u
'd') == 13,
785 "u'd' converts to 13");
786 MOZ_RELEASE_ASSERT(AsciiAlphanumericToNumber(u
'e') == 14,
787 "u'e' converts to 14");
788 MOZ_RELEASE_ASSERT(AsciiAlphanumericToNumber(u
'f') == 15,
789 "u'f' converts to 15");
790 MOZ_RELEASE_ASSERT(AsciiAlphanumericToNumber(u
'g') == 16,
791 "u'g' converts to 16");
792 MOZ_RELEASE_ASSERT(AsciiAlphanumericToNumber(u
'h') == 17,
793 "u'h' converts to 17");
794 MOZ_RELEASE_ASSERT(AsciiAlphanumericToNumber(u
'i') == 18,
795 "u'i' converts to 18");
796 MOZ_RELEASE_ASSERT(AsciiAlphanumericToNumber(u
'j') == 19,
797 "u'j' converts to 19");
798 MOZ_RELEASE_ASSERT(AsciiAlphanumericToNumber(u
'k') == 20,
799 "u'k' converts to 20");
800 MOZ_RELEASE_ASSERT(AsciiAlphanumericToNumber(u
'l') == 21,
801 "u'l' converts to 21");
802 MOZ_RELEASE_ASSERT(AsciiAlphanumericToNumber(u
'm') == 22,
803 "u'm' converts to 22");
804 MOZ_RELEASE_ASSERT(AsciiAlphanumericToNumber(u
'n') == 23,
805 "u'n' converts to 23");
806 MOZ_RELEASE_ASSERT(AsciiAlphanumericToNumber(u
'o') == 24,
807 "u'o' converts to 24");
808 MOZ_RELEASE_ASSERT(AsciiAlphanumericToNumber(u
'p') == 25,
809 "u'p' converts to 25");
810 MOZ_RELEASE_ASSERT(AsciiAlphanumericToNumber(u
'q') == 26,
811 "u'q' converts to 26");
812 MOZ_RELEASE_ASSERT(AsciiAlphanumericToNumber(u
'r') == 27,
813 "u'r' converts to 27");
814 MOZ_RELEASE_ASSERT(AsciiAlphanumericToNumber(u
's') == 28,
815 "u's' converts to 28");
816 MOZ_RELEASE_ASSERT(AsciiAlphanumericToNumber(u
't') == 29,
817 "u't' converts to 29");
818 MOZ_RELEASE_ASSERT(AsciiAlphanumericToNumber(u
'u') == 30,
819 "u'u' converts to 30");
820 MOZ_RELEASE_ASSERT(AsciiAlphanumericToNumber(u
'v') == 31,
821 "u'v' converts to 31");
822 MOZ_RELEASE_ASSERT(AsciiAlphanumericToNumber(u
'w') == 32,
823 "u'w' converts to 32");
824 MOZ_RELEASE_ASSERT(AsciiAlphanumericToNumber(u
'x') == 33,
825 "u'x' converts to 33");
826 MOZ_RELEASE_ASSERT(AsciiAlphanumericToNumber(u
'y') == 34,
827 "u'y' converts to 34");
828 MOZ_RELEASE_ASSERT(AsciiAlphanumericToNumber(u
'z') == 35,
829 "u'z' converts to 35");
833 MOZ_RELEASE_ASSERT(AsciiAlphanumericToNumber(U
'0') == 0,
834 "U'0' converts to 0");
835 MOZ_RELEASE_ASSERT(AsciiAlphanumericToNumber(U
'1') == 1,
836 "U'1' converts to 1");
837 MOZ_RELEASE_ASSERT(AsciiAlphanumericToNumber(U
'2') == 2,
838 "U'2' converts to 2");
839 MOZ_RELEASE_ASSERT(AsciiAlphanumericToNumber(U
'3') == 3,
840 "U'3' converts to 3");
841 MOZ_RELEASE_ASSERT(AsciiAlphanumericToNumber(U
'4') == 4,
842 "U'4' converts to 4");
843 MOZ_RELEASE_ASSERT(AsciiAlphanumericToNumber(U
'5') == 5,
844 "U'5' converts to 5");
845 MOZ_RELEASE_ASSERT(AsciiAlphanumericToNumber(U
'6') == 6,
846 "U'6' converts to 6");
847 MOZ_RELEASE_ASSERT(AsciiAlphanumericToNumber(U
'7') == 7,
848 "U'7' converts to 7");
849 MOZ_RELEASE_ASSERT(AsciiAlphanumericToNumber(U
'8') == 8,
850 "U'8' converts to 8");
851 MOZ_RELEASE_ASSERT(AsciiAlphanumericToNumber(U
'9') == 9,
852 "U'9' converts to 9");
854 MOZ_RELEASE_ASSERT(AsciiAlphanumericToNumber(U
'A') == 10,
855 "U'A' converts to 10");
856 MOZ_RELEASE_ASSERT(AsciiAlphanumericToNumber(U
'B') == 11,
857 "U'B' converts to 11");
858 MOZ_RELEASE_ASSERT(AsciiAlphanumericToNumber(U
'C') == 12,
859 "U'C' converts to 12");
860 MOZ_RELEASE_ASSERT(AsciiAlphanumericToNumber(U
'D') == 13,
861 "U'D' converts to 13");
862 MOZ_RELEASE_ASSERT(AsciiAlphanumericToNumber(U
'E') == 14,
863 "U'E' converts to 14");
864 MOZ_RELEASE_ASSERT(AsciiAlphanumericToNumber(U
'F') == 15,
865 "U'F' converts to 15");
866 MOZ_RELEASE_ASSERT(AsciiAlphanumericToNumber(U
'G') == 16,
867 "U'G' converts to 16");
868 MOZ_RELEASE_ASSERT(AsciiAlphanumericToNumber(U
'H') == 17,
869 "U'H' converts to 17");
870 MOZ_RELEASE_ASSERT(AsciiAlphanumericToNumber(U
'I') == 18,
871 "U'I' converts to 18");
872 MOZ_RELEASE_ASSERT(AsciiAlphanumericToNumber(U
'J') == 19,
873 "U'J' converts to 19");
874 MOZ_RELEASE_ASSERT(AsciiAlphanumericToNumber(U
'K') == 20,
875 "U'K' converts to 20");
876 MOZ_RELEASE_ASSERT(AsciiAlphanumericToNumber(U
'L') == 21,
877 "U'L' converts to 21");
878 MOZ_RELEASE_ASSERT(AsciiAlphanumericToNumber(U
'M') == 22,
879 "U'M' converts to 22");
880 MOZ_RELEASE_ASSERT(AsciiAlphanumericToNumber(U
'N') == 23,
881 "U'N' converts to 23");
882 MOZ_RELEASE_ASSERT(AsciiAlphanumericToNumber(U
'O') == 24,
883 "U'O' converts to 24");
884 MOZ_RELEASE_ASSERT(AsciiAlphanumericToNumber(U
'P') == 25,
885 "U'P' converts to 25");
886 MOZ_RELEASE_ASSERT(AsciiAlphanumericToNumber(U
'Q') == 26,
887 "U'Q' converts to 26");
888 MOZ_RELEASE_ASSERT(AsciiAlphanumericToNumber(U
'R') == 27,
889 "U'R' converts to 27");
890 MOZ_RELEASE_ASSERT(AsciiAlphanumericToNumber(U
'S') == 28,
891 "U'S' converts to 28");
892 MOZ_RELEASE_ASSERT(AsciiAlphanumericToNumber(U
'T') == 29,
893 "U'T' converts to 29");
894 MOZ_RELEASE_ASSERT(AsciiAlphanumericToNumber(U
'U') == 30,
895 "U'U' converts to 30");
896 MOZ_RELEASE_ASSERT(AsciiAlphanumericToNumber(U
'V') == 31,
897 "U'V' converts to 31");
898 MOZ_RELEASE_ASSERT(AsciiAlphanumericToNumber(U
'W') == 32,
899 "U'W' converts to 32");
900 MOZ_RELEASE_ASSERT(AsciiAlphanumericToNumber(U
'X') == 33,
901 "U'X' converts to 33");
902 MOZ_RELEASE_ASSERT(AsciiAlphanumericToNumber(U
'Y') == 34,
903 "U'Y' converts to 34");
904 MOZ_RELEASE_ASSERT(AsciiAlphanumericToNumber(U
'Z') == 35,
905 "U'Z' converts to 35");
907 MOZ_RELEASE_ASSERT(AsciiAlphanumericToNumber(U
'a') == 10,
908 "U'a' converts to 10");
909 MOZ_RELEASE_ASSERT(AsciiAlphanumericToNumber(U
'b') == 11,
910 "U'b' converts to 11");
911 MOZ_RELEASE_ASSERT(AsciiAlphanumericToNumber(U
'c') == 12,
912 "U'c' converts to 12");
913 MOZ_RELEASE_ASSERT(AsciiAlphanumericToNumber(U
'd') == 13,
914 "U'd' converts to 13");
915 MOZ_RELEASE_ASSERT(AsciiAlphanumericToNumber(U
'e') == 14,
916 "U'e' converts to 14");
917 MOZ_RELEASE_ASSERT(AsciiAlphanumericToNumber(U
'f') == 15,
918 "U'f' converts to 15");
919 MOZ_RELEASE_ASSERT(AsciiAlphanumericToNumber(U
'g') == 16,
920 "U'g' converts to 16");
921 MOZ_RELEASE_ASSERT(AsciiAlphanumericToNumber(U
'h') == 17,
922 "U'h' converts to 17");
923 MOZ_RELEASE_ASSERT(AsciiAlphanumericToNumber(U
'i') == 18,
924 "U'i' converts to 18");
925 MOZ_RELEASE_ASSERT(AsciiAlphanumericToNumber(U
'j') == 19,
926 "U'j' converts to 19");
927 MOZ_RELEASE_ASSERT(AsciiAlphanumericToNumber(U
'k') == 20,
928 "U'k' converts to 20");
929 MOZ_RELEASE_ASSERT(AsciiAlphanumericToNumber(U
'l') == 21,
930 "U'l' converts to 21");
931 MOZ_RELEASE_ASSERT(AsciiAlphanumericToNumber(U
'm') == 22,
932 "U'm' converts to 22");
933 MOZ_RELEASE_ASSERT(AsciiAlphanumericToNumber(U
'n') == 23,
934 "U'n' converts to 23");
935 MOZ_RELEASE_ASSERT(AsciiAlphanumericToNumber(U
'o') == 24,
936 "U'o' converts to 24");
937 MOZ_RELEASE_ASSERT(AsciiAlphanumericToNumber(U
'p') == 25,
938 "U'p' converts to 25");
939 MOZ_RELEASE_ASSERT(AsciiAlphanumericToNumber(U
'q') == 26,
940 "U'q' converts to 26");
941 MOZ_RELEASE_ASSERT(AsciiAlphanumericToNumber(U
'r') == 27,
942 "U'r' converts to 27");
943 MOZ_RELEASE_ASSERT(AsciiAlphanumericToNumber(U
's') == 28,
944 "U's' converts to 28");
945 MOZ_RELEASE_ASSERT(AsciiAlphanumericToNumber(U
't') == 29,
946 "U't' converts to 29");
947 MOZ_RELEASE_ASSERT(AsciiAlphanumericToNumber(U
'u') == 30,
948 "U'u' converts to 30");
949 MOZ_RELEASE_ASSERT(AsciiAlphanumericToNumber(U
'v') == 31,
950 "U'v' converts to 31");
951 MOZ_RELEASE_ASSERT(AsciiAlphanumericToNumber(U
'w') == 32,
952 "U'w' converts to 32");
953 MOZ_RELEASE_ASSERT(AsciiAlphanumericToNumber(U
'x') == 33,
954 "U'x' converts to 33");
955 MOZ_RELEASE_ASSERT(AsciiAlphanumericToNumber(U
'y') == 34,
956 "U'y' converts to 34");
957 MOZ_RELEASE_ASSERT(AsciiAlphanumericToNumber(U
'z') == 35,
958 "U'z' converts to 35");
961 static void TestIsAsciiDigit() {
964 static_assert(!IsAsciiDigit('/'), "'/' isn't an ASCII digit");
965 static_assert('/' == 0x2F, "'/' has value 0x2F");
967 static_assert('0' == 0x30, "'0' has value 0x30");
968 static_assert(IsAsciiDigit('0'), "'0' is an ASCII digit");
969 static_assert(IsAsciiDigit('1'), "'1' is an ASCII digit");
970 static_assert(IsAsciiDigit('5'), "'5' is an ASCII digit");
971 static_assert(IsAsciiDigit('8'), "'8' is an ASCII digit");
972 static_assert(IsAsciiDigit('9'), "'9' is an ASCII digit");
974 static_assert('9' == 0x39, "'9' has value 0x39");
975 static_assert(':' == 0x3A, "':' has value 0x3A");
976 static_assert(!IsAsciiDigit(':'), "':' isn't an ASCII digit");
978 static_assert(!IsAsciiDigit('@'), "'@' isn't an ASCII digit");
979 static_assert(!IsAsciiDigit('A'), "'A' isn't an ASCII digit");
980 static_assert(!IsAsciiDigit('B'), "'B' isn't an ASCII digit");
981 static_assert(!IsAsciiDigit('M'), "'M' isn't an ASCII digit");
982 static_assert(!IsAsciiDigit('Y'), "'Y' isn't an ASCII digit");
983 static_assert(!IsAsciiDigit('Z'), "'Z' isn't an ASCII digit");
984 static_assert(!IsAsciiDigit('['), "'[' isn't an ASCII digit");
985 static_assert(!IsAsciiDigit('`'), "'`' isn't an ASCII digit");
986 static_assert(!IsAsciiDigit('a'), "'a' isn't an ASCII digit");
987 static_assert(!IsAsciiDigit('b'), "'b' isn't an ASCII digit");
988 static_assert(!IsAsciiDigit('m'), "'m' isn't an ASCII digit");
989 static_assert(!IsAsciiDigit('y'), "'y' isn't an ASCII digit");
990 static_assert(!IsAsciiDigit('z'), "'z' isn't an ASCII digit");
991 static_assert(!IsAsciiDigit('{'), "'{' isn't an ASCII digit");
995 static_assert(!IsAsciiDigit(u
'/'), "u'/' isn't an ASCII digit");
996 static_assert(u
'/' == 0x2F, "u'/' has value 0x2F");
997 static_assert(u
'0' == 0x30, "u'0' has value 0x30");
998 static_assert(IsAsciiDigit(u
'0'), "u'0' is an ASCII digit");
999 static_assert(IsAsciiDigit(u
'1'), "u'1' is an ASCII digit");
1000 static_assert(IsAsciiDigit(u
'5'), "u'5' is an ASCII digit");
1001 static_assert(IsAsciiDigit(u
'8'), "u'8' is an ASCII digit");
1002 static_assert(IsAsciiDigit(u
'9'), "u'9' is an ASCII digit");
1004 static_assert(u
'9' == 0x39, "u'9' has value 0x39");
1005 static_assert(u
':' == 0x3A, "u':' has value 0x3A");
1006 static_assert(!IsAsciiDigit(u
':'), "u':' isn't an ASCII digit");
1008 static_assert(!IsAsciiDigit(u
'@'), "u'@' isn't an ASCII digit");
1009 static_assert(!IsAsciiDigit(u
'A'), "u'A' isn't an ASCII digit");
1010 static_assert(!IsAsciiDigit(u
'B'), "u'B' isn't an ASCII digit");
1011 static_assert(!IsAsciiDigit(u
'M'), "u'M' isn't an ASCII digit");
1012 static_assert(!IsAsciiDigit(u
'Y'), "u'Y' isn't an ASCII digit");
1013 static_assert(!IsAsciiDigit(u
'Z'), "u'Z' isn't an ASCII digit");
1014 static_assert(!IsAsciiDigit(u
'['), "u'[' isn't an ASCII digit");
1015 static_assert(!IsAsciiDigit(u
'`'), "u'`' isn't an ASCII digit");
1016 static_assert(!IsAsciiDigit(u
'a'), "u'a' isn't an ASCII digit");
1017 static_assert(!IsAsciiDigit(u
'b'), "u'b' isn't an ASCII digit");
1018 static_assert(!IsAsciiDigit(u
'm'), "u'm' isn't an ASCII digit");
1019 static_assert(!IsAsciiDigit(u
'y'), "u'y' isn't an ASCII digit");
1020 static_assert(!IsAsciiDigit(u
'z'), "u'z' isn't an ASCII digit");
1021 static_assert(!IsAsciiDigit(u
'{'), "u'{' isn't an ASCII digit");
1025 static_assert(!IsAsciiDigit(U
'/'), "U'/' isn't an ASCII digit");
1026 static_assert(U
'/' == 0x2F, "U'/' has value 0x2F");
1028 static_assert(U
'0' == 0x30, "U'0' has value 0x30");
1029 static_assert(IsAsciiDigit(U
'0'), "U'0' is an ASCII digit");
1030 static_assert(IsAsciiDigit(U
'1'), "U'1' is an ASCII digit");
1031 static_assert(IsAsciiDigit(U
'5'), "U'5' is an ASCII digit");
1032 static_assert(IsAsciiDigit(U
'8'), "U'8' is an ASCII digit");
1033 static_assert(IsAsciiDigit(U
'9'), "U'9' is an ASCII digit");
1035 static_assert(U
'9' == 0x39, "U'9' has value 0x39");
1036 static_assert(U
':' == 0x3A, "U':' has value 0x3A");
1037 static_assert(!IsAsciiDigit(U
':'), "U':' isn't an ASCII digit");
1039 static_assert(!IsAsciiDigit(U
'@'), "U'@' isn't an ASCII digit");
1040 static_assert(!IsAsciiDigit(U
'A'), "U'A' isn't an ASCII digit");
1041 static_assert(!IsAsciiDigit(U
'B'), "U'B' isn't an ASCII digit");
1042 static_assert(!IsAsciiDigit(U
'M'), "U'M' isn't an ASCII digit");
1043 static_assert(!IsAsciiDigit(U
'Y'), "U'Y' isn't an ASCII digit");
1044 static_assert(!IsAsciiDigit(U
'Z'), "U'Z' isn't an ASCII digit");
1045 static_assert(!IsAsciiDigit(U
'['), "U'[' isn't an ASCII digit");
1046 static_assert(!IsAsciiDigit(U
'`'), "U'`' isn't an ASCII digit");
1047 static_assert(!IsAsciiDigit(U
'a'), "U'a' isn't an ASCII digit");
1048 static_assert(!IsAsciiDigit(U
'b'), "U'b' isn't an ASCII digit");
1049 static_assert(!IsAsciiDigit(U
'm'), "U'm' isn't an ASCII digit");
1050 static_assert(!IsAsciiDigit(U
'y'), "U'y' isn't an ASCII digit");
1051 static_assert(!IsAsciiDigit(U
'z'), "U'z' isn't an ASCII digit");
1052 static_assert(!IsAsciiDigit(U
'{'), "U'{' isn't an ASCII digit");
1057 TestIsAsciiNullTerminated();
1059 TestIsAsciiUppercaseAlpha();
1060 TestIsAsciiLowercaseAlpha();
1061 TestIsAsciiAlphanumeric();
1062 TestAsciiAlphanumericToNumber();