1 /* This Source Code Form is subject to the terms of the Mozilla Public
2 * License, v. 2.0. If a copy of the MPL was not distributed with this
3 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
8 struct UTFStringsStringPair
14 static const UTFStringsStringPair ValidStrings
[] =
16 { { 'a', 'b', 'c', 'd' },
17 { 'a', 'b', 'c', 'd' } },
18 { { '1', '2', '3', '4' },
19 { '1', '2', '3', '4' } },
20 { { 0x7F, 'A', 0x80, 'B', 0x101, 0x200 },
21 { 0x7F, 'A', 0xC2, 0x80, 'B', 0xC4, 0x81, 0xC8, 0x80 } },
22 { { 0x7FF, 0x800, 0x1000 },
23 { 0xDF, 0xBF, 0xE0, 0xA0, 0x80, 0xE1, 0x80, 0x80 } },
24 { { 0xD7FF, 0xE000, 0xF00F, 'A', 0xFFF0 },
25 { 0xED, 0x9F, 0xBF, 0xEE, 0x80, 0x80, 0xEF, 0x80, 0x8F, 'A', 0xEF, 0xBF, 0xB0 } },
26 { { 0xFFF7, 0xFFFC, 0xFFFD, 0xFFFD },
27 { 0xEF, 0xBF, 0xB7, 0xEF, 0xBF, 0xBC, 0xEF, 0xBF, 0xBD, 0xEF, 0xBF, 0xBD } },
28 { { 0xD800, 0xDC00, 0xD800, 0xDCFF },
29 { 0xF0, 0x90, 0x80, 0x80, 0xF0, 0x90, 0x83, 0xBF } },
30 { { 0xDBFF, 0xDFFF, 0xDBB7, 0xDCBA },
31 { 0xF4, 0x8F, 0xBF, 0xBF, 0xF3, 0xBD, 0xB2, 0xBA } },
33 { 0xEF, 0xBF, 0xBD, 0xEF, 0xBF, 0xBF } },
34 { { 0xFFFD, 0xFFFE, 0xFFFF },
35 { 0xEF, 0xBF, 0xBD, 0xEF, 0xBF, 0xBE, 0xEF, 0xBF, 0xBF } },
38 static const UTFStringsStringPair Invalid16Strings
[] =
40 { { 'a', 'b', 0xD800 },
41 { 'a', 'b', 0xEF, 0xBF, 0xBD } },
43 { 0xEF, 0xBF, 0xBD, 'b' } },
45 { 0xEF, 0xBF, 0xBD } },
47 { 0xEF, 0xBF, 0xBD } },
48 { { 0xDC00, 0xD800, 'b' },
49 { 0xEF, 0xBF, 0xBD, 0xEF, 0xBF, 0xBD, 'b' } },
50 { { 'b', 0xDC00, 0xD800 },
51 { 'b', 0xEF, 0xBF, 0xBD, 0xEF, 0xBF, 0xBD } },
53 { 0xEF, 0xBF, 0xBD, 0xEF, 0xBF, 0xBD } },
54 { { 0xDC00, 0xD800, 0xDC00, 0xD800 },
55 { 0xEF, 0xBF, 0xBD, 0xF0, 0x90, 0x80, 0x80, 0xEF, 0xBF, 0xBD } },
56 { { 0xDC00, 0xD800, 0xD800, 0xDC00 },
57 { 0xEF, 0xBF, 0xBD, 0xEF, 0xBF, 0xBD, 0xF0, 0x90, 0x80, 0x80 } },
60 static const UTFStringsStringPair Invalid8Strings
[] =
62 { { 'a', 0xFFFD, 'b' },
63 { 'a', 0xC0, 0x80, 'b' } },
65 { 0xC1, 0xBF, 0xC2, 0x80 } },
68 { { 0xFFFD, 'x', 0x0800 },
69 { 0xE0, 0x80, 0x80, 'x', 0xE0, 0xA0, 0x80 } },
70 { { 0xFFFD, 'x', 0xFFFD },
71 { 0xF0, 0x80, 0x80, 0x80, 'x', 0xF0, 0x80, 0x8F, 0x80 } },
73 { 0xF4, 0x90, 0x80, 0x80, 0xF7, 0xBF, 0xBF, 0xBF } },
74 { { 0xFFFD, 'x', 0xD800, 0xDC00, 0xFFFD },
75 { 0xF0, 0x8F, 0xBF, 0xBF, 'x', 0xF0, 0x90, 0x80, 0x80, 0xF0, 0x8F, 0xBF, 0xBF } },
76 { { 0xFFFD, 'x', 0xFFFD },
77 { 0xF8, 0x80, 0x80, 0x80, 0x80, 'x', 0xF8, 0x88, 0x80, 0x80, 0x80 } },
79 { 0xFB, 0xBF, 0xBF, 0xBF, 0xBF, 0xFC, 0xA0, 0x80, 0x80, 0x80, 0x80 } },
81 { 0xFC, 0x80, 0x80, 0x80, 0x80, 0x80, 0xFD, 0xBF, 0xBF, 0xBF, 0xBF, 0xBF } },
84 // Don't use this array in debug builds as that intentionally asserts.
86 static const char Malformed8Strings
[][16] =
92 { 'a', 0xE8, 0x80, 'c' },
95 { 'a', 0xE8, 0xE8, 0x80 },
97 { 'a', 0xF4, 0x80, 0x80, 'c', 'c' },
98 { 'a', 0xF4, 0x80, 'x', 0x80 },
99 { 0xF4, 0x80, 0x80, 0x80, 0x80 },
101 { 'a', 0xFA, 0x80, 0x80, 0x7F, 0x80, 'c' },
102 { 'a', 0xFA, 0x80, 0x80, 0x80, 0x80, 0x80, 'c' },
104 { 'a', 0xFD, 0x80, 0x80, 0x80, 0x80, 'c' },
105 { 'a', 0xFD, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80 },
106 { 'a', 0xFC, 0x80, 0x80, 0x40, 0x80, 0x80, 'c' },