Bug 596580: Fix mozJSSubScriptLoader's version finding. (r=brendan)
[mozilla-central.git] / xpcom / tests / UTFStrings.h
blob28b5239412f9d29c7b99a55167b8a735c40e730d
1 /* ***** BEGIN LICENSE BLOCK *****
2 * Version: MPL 1.1/GPL 2.0/LGPL 2.1
4 * The contents of this file are subject to the Mozilla Public License Version
5 * 1.1 (the "License"); you may not use this file except in compliance with
6 * the License. You may obtain a copy of the License at
7 * http://www.mozilla.org/MPL/
9 * Software distributed under the License is distributed on an "AS IS" basis,
10 * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
11 * for the specific language governing rights and limitations under the
12 * License.
14 * The Original Code is string testing code.
16 * The Initial Developer of the Original Code is
17 * mozilla.org.
18 * Portions created by the Initial Developer are Copyright (C) 2010
19 * the Initial Developer. All Rights Reserved.
21 * Contributor(s):
23 * Alternatively, the contents of this file may be used under the terms of
24 * either the GNU General Public License Version 2 or later (the "GPL"), or
25 * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
26 * in which case the provisions of the GPL or the LGPL are applicable instead
27 * of those above. If you wish to allow use of your version of this file only
28 * under the terms of either the GPL or the LGPL, and not to allow others to
29 * use your version of this file under the terms of the MPL, indicate your
30 * decision by deleting the provisions above and replace them with the notice
31 * and other provisions required by the GPL or the LGPL. If you do not delete
32 * the provisions above, a recipient may use your version of this file under
33 * the terms of any one of the MPL, the GPL or the LGPL.
35 * ***** END LICENSE BLOCK ***** */
37 #ifndef utfstrings_h__
38 #define utfstrings_h__
40 struct UTFStringsStringPair
42 PRUnichar m16[16];
43 char m8[16];
46 static const UTFStringsStringPair ValidStrings[] =
48 { { 'a', 'b', 'c', 'd' },
49 { 'a', 'b', 'c', 'd' } },
50 { { '1', '2', '3', '4' },
51 { '1', '2', '3', '4' } },
52 { { 0x7F, 'A', 0x80, 'B', 0x101, 0x200 },
53 { 0x7F, 'A', 0xC2, 0x80, 'B', 0xC4, 0x81, 0xC8, 0x80 } },
54 { { 0x7FF, 0x800, 0x1000 },
55 { 0xDF, 0xBF, 0xE0, 0xA0, 0x80, 0xE1, 0x80, 0x80 } },
56 { { 0xD7FF, 0xE000, 0xF00F, 'A', 0xFFF0 },
57 { 0xED, 0x9F, 0xBF, 0xEE, 0x80, 0x80, 0xEF, 0x80, 0x8F, 'A', 0xEF, 0xBF, 0xB0 } },
58 { { 0xFFF7, 0xFFFC, 0xFFFD, 0xFFFD },
59 { 0xEF, 0xBF, 0xB7, 0xEF, 0xBF, 0xBC, 0xEF, 0xBF, 0xBD, 0xEF, 0xBF, 0xBD } },
60 { { 0xD800, 0xDC00, 0xD800, 0xDCFF },
61 { 0xF0, 0x90, 0x80, 0x80, 0xF0, 0x90, 0x83, 0xBF } },
62 { { 0xDBFF, 0xDFFF, 0xDBB7, 0xDCBA },
63 { 0xF4, 0x8F, 0xBF, 0xBF, 0xF3, 0xBD, 0xB2, 0xBA } },
64 { { 0xFFFD, 0xFFFF },
65 { 0xEF, 0xBF, 0xBD, 0xEF, 0xBF, 0xBF } },
66 { { 0xFFFD, 0xFFFE, 0xFFFF },
67 { 0xEF, 0xBF, 0xBD, 0xEF, 0xBF, 0xBE, 0xEF, 0xBF, 0xBF } },
70 static const UTFStringsStringPair Invalid16Strings[] =
72 { { 'a', 'b', 0xD800 },
73 { 'a', 'b', 0xEF, 0xBF, 0xBD } },
74 { { 0xD8FF, 'b' },
75 { 0xEF, 0xBF, 0xBD, 'b' } },
76 { { 0xD821 },
77 { 0xEF, 0xBF, 0xBD } },
78 { { 0xDC21 },
79 { 0xEF, 0xBF, 0xBD } },
80 { { 0xDC00, 0xD800, 'b' },
81 { 0xEF, 0xBF, 0xBD, 0xEF, 0xBF, 0xBD, 'b' } },
82 { { 'b', 0xDC00, 0xD800 },
83 { 'b', 0xEF, 0xBF, 0xBD, 0xEF, 0xBF, 0xBD } },
84 { { 0xDC00, 0xD800 },
85 { 0xEF, 0xBF, 0xBD, 0xEF, 0xBF, 0xBD } },
86 { { 0xDC00, 0xD800, 0xDC00, 0xD800 },
87 { 0xEF, 0xBF, 0xBD, 0xF0, 0x90, 0x80, 0x80, 0xEF, 0xBF, 0xBD } },
88 { { 0xDC00, 0xD800, 0xD800, 0xDC00 },
89 { 0xEF, 0xBF, 0xBD, 0xEF, 0xBF, 0xBD, 0xF0, 0x90, 0x80, 0x80 } },
92 static const UTFStringsStringPair Invalid8Strings[] =
94 { { 'a', 0xFFFD, 'b' },
95 { 'a', 0xC0, 0x80, 'b' } },
96 { { 0xFFFD, 0x80 },
97 { 0xC1, 0xBF, 0xC2, 0x80 } },
98 { { 0xFFFD },
99 { 0xC1, 0xBF } },
100 { { 0xFFFD, 'x', 0x0800 },
101 { 0xE0, 0x80, 0x80, 'x', 0xE0, 0xA0, 0x80 } },
102 { { 0xFFFD, 'x', 0xFFFD },
103 { 0xF0, 0x80, 0x80, 0x80, 'x', 0xF0, 0x80, 0x8F, 0x80 } },
104 { { 0xFFFD, 0xFFFD },
105 { 0xF4, 0x90, 0x80, 0x80, 0xF7, 0xBF, 0xBF, 0xBF } },
106 { { 0xFFFD, 'x', 0xD800, 0xDC00, 0xFFFD },
107 { 0xF0, 0x8F, 0xBF, 0xBF, 'x', 0xF0, 0x90, 0x80, 0x80, 0xF0, 0x8F, 0xBF, 0xBF } },
108 { { 0xFFFD, 'x', 0xFFFD },
109 { 0xF8, 0x80, 0x80, 0x80, 0x80, 'x', 0xF8, 0x88, 0x80, 0x80, 0x80 } },
110 { { 0xFFFD, 0xFFFD },
111 { 0xFB, 0xBF, 0xBF, 0xBF, 0xBF, 0xFC, 0xA0, 0x80, 0x80, 0x80, 0x80 } },
112 { { 0xFFFD, 0xFFFD },
113 { 0xFC, 0x80, 0x80, 0x80, 0x80, 0x80, 0xFD, 0xBF, 0xBF, 0xBF, 0xBF, 0xBF } },
116 // Don't use this array in debug builds as that intentionally asserts.
117 #ifndef DEBUG
118 static const char Malformed8Strings[][16] =
120 { 0x80 },
121 { 'a', 0xC8, 'c' },
122 { 'a', 0xC0 },
123 { 'a', 0xE8, 'c' },
124 { 'a', 0xE8, 0x80, 'c' },
125 { 'a', 0xE8, 0x80 },
126 { 0xE8, 0x7F, 0x80 },
127 { 'a', 0xE8, 0xE8, 0x80 },
128 { 'a', 0xF4 },
129 { 'a', 0xF4, 0x80, 0x80, 'c', 'c' },
130 { 'a', 0xF4, 0x80, 'x', 0x80 },
131 { 0xF4, 0x80, 0x80, 0x80, 0x80 },
132 { 'a', 0xFA, 'c' },
133 { 'a', 0xFA, 0x80, 0x80, 0x7F, 0x80, 'c' },
134 { 'a', 0xFA, 0x80, 0x80, 0x80, 0x80, 0x80, 'c' },
135 { 'a', 0xFD },
136 { 'a', 0xFD, 0x80, 0x80, 0x80, 0x80, 'c' },
137 { 'a', 0xFD, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80 },
138 { 'a', 0xFC, 0x80, 0x80, 0x40, 0x80, 0x80, 'c' },
140 #endif
142 #endif