Merge pull request #2547 from ermshiperete/Xamarin-33183
[mono.git] / mcs / class / corlib / Test / System.Globalization / CompareInfoTest.cs
1 // CompareInfoTest.cs - NUnit Test Cases for the
2 // System.Globalization.CompareInfo class
3 //
4 // Dick Porter <dick@ximian.com>
5 // Atsushi Enomoto <atsushi@ximian.com>
6 //
7 // (C) 2003-2005 Novell, Inc.  http://www.novell.com
8 //
9
10 using NUnit.Framework;
11 using System;
12 using System.Globalization;
13
14 namespace MonoTests.System.Globalization
15 {
16
17 [TestFixture]
18 public class CompareInfoTest
19 {
20         static bool doTest = Environment.GetEnvironmentVariable ("MONO_DISABLE_MANAGED_COLLATION") != "yes";
21
22         public CompareInfoTest() {}
23
24         [Test]
25         public void Compare()
26         {
27                 string s1 = "foo";
28                 
29                 Assert.AreEqual (0, CultureInfo.InvariantCulture.CompareInfo.Compare ("", ""), "Compare two empty strings");
30                 Assert.AreEqual (1, CultureInfo.InvariantCulture.CompareInfo.Compare (s1, ""), "Compare string with empty string");
31                 Assert.AreEqual (-1, CultureInfo.InvariantCulture.CompareInfo.Compare ("", s1), "Compare empty string with string");
32
33                 Assert.AreEqual (0, CultureInfo.InvariantCulture.CompareInfo.Compare ("", 0, "", 0), "Compare two empty strings, with 0 offsets");
34                 Assert.AreEqual (1, CultureInfo.InvariantCulture.CompareInfo.Compare (s1, 0, "", 0), "Compare string with empty string, with 0 offsets");
35                 Assert.AreEqual (-1, CultureInfo.InvariantCulture.CompareInfo.Compare ("", 0, s1, 0), "Compare empty string with string, with 0 offsets");
36
37                 Assert.AreEqual (0, CultureInfo.InvariantCulture.CompareInfo.Compare ("", 0, "".Length, "", 0, "".Length), "Compare two empty strings, with 0 offsets and specified lengths");
38                 Assert.AreEqual (1, CultureInfo.InvariantCulture.CompareInfo.Compare (s1, 0, s1.Length, "", 0, "".Length), "Compare string with empty string, with 0 offsets and specified lengths");
39                 Assert.AreEqual (-1, CultureInfo.InvariantCulture.CompareInfo.Compare ("", 0, "".Length, s1, 0, s1.Length), "Compare empty string with string, with 0 offsets and specified lengths");
40
41                 Assert.AreEqual (0, CultureInfo.InvariantCulture.CompareInfo.Compare (s1, s1.Length, s1, s1.Length), "Compare two strings, with offsets == string lengths");
42                 Assert.AreEqual (-1, CultureInfo.InvariantCulture.CompareInfo.Compare (s1, s1.Length, s1, 0), "Compare two strings, with first offset == string length");
43                 Assert.AreEqual (1, CultureInfo.InvariantCulture.CompareInfo.Compare (s1, 0, s1, s1.Length), "Compare two strings, with second offset == string length");
44
45                 Assert.AreEqual (0, CultureInfo.InvariantCulture.CompareInfo.Compare (s1, 0, 0, s1, 0, 0), "Compare two strings, with zero lengths");
46                 Assert.AreEqual (-1, CultureInfo.InvariantCulture.CompareInfo.Compare (s1, 0, 0, s1, 0, s1.Length), "Compare two strings, with first length zero");
47                 Assert.AreEqual (1, CultureInfo.InvariantCulture.CompareInfo.Compare (s1, 0, s1.Length, s1, 0, 0), "Compare strings, with second length zero");
48                 
49                 Assert.AreEqual (0, CultureInfo.InvariantCulture.CompareInfo.Compare (null, null), "Compare two null references");
50                 Assert.AreEqual (1, CultureInfo.InvariantCulture.CompareInfo.Compare ("", null), "Compare a string to a null reference");
51                 Assert.AreEqual (-1, CultureInfo.InvariantCulture.CompareInfo.Compare (null, ""), "Compare a null reference to a string");
52         }
53
54         // Culture-sensitive collation tests
55
56         CompareInfo invariant = CultureInfo.InvariantCulture.CompareInfo;
57         CompareInfo french = new CultureInfo ("fr").CompareInfo;
58         CompareInfo japanese = new CultureInfo ("ja").CompareInfo;
59         CompareInfo czech = new CultureInfo ("cs").CompareInfo;
60         CompareInfo hungarian = new CultureInfo ("hu").CompareInfo;
61
62         CompareOptions ignoreCW =
63                 CompareOptions.IgnoreWidth | CompareOptions.IgnoreCase;
64         CompareOptions ignoreCN =
65                 CompareOptions.IgnoreNonSpace | CompareOptions.IgnoreCase;
66
67         void AssertSortKey (string message, byte [] expected, string test)
68         {
69                 AssertSortKey (message, expected, test, CompareOptions.None);
70         }
71
72         void AssertSortKey (string message, byte [] expected, string test, CompareOptions opt)
73         {
74                 AssertSortKey (message, expected, test, opt, invariant);
75         }
76
77         void AssertSortKey (string message, byte [] expected, string test, CompareOptions opt, CompareInfo ci)
78         {
79                 byte [] actual = ci.GetSortKey (test, opt).KeyData;
80                 Assert.AreEqual (expected, actual, message);
81         }
82
83         void AssertSortKeyLevel5 (string message, byte [] expected, string test)
84         {
85                 byte [] tmp = invariant.GetSortKey (test).KeyData;
86                 int idx = 0;
87                 for (int i = 0; i < 4; i++, idx++)
88                         for (; tmp [idx] != 1; idx++)
89                                 ;
90                 byte [] actual = new byte [tmp.Length - idx];
91                 Array.Copy (tmp, idx, actual, 0, actual.Length);
92                 Assert.AreEqual (expected, actual, message);
93         }
94
95         void AssertCompare (string message, int result, string s1, string s2)
96         {
97                 AssertCompare (message, result, s1, s2, CompareOptions.None);
98         }
99
100         void AssertCompare (string message, int result, string s1, string s2,
101                 CompareOptions opt)
102         {
103                 AssertCompare (message, result, s1, s2, opt, invariant);
104         }
105
106         void AssertCompare (string message, int result, string s1, string s2,
107                 CompareOptions opt, CompareInfo ci)
108         {
109                 int ret = ci.Compare (s1, s2, opt);
110                 if (result == 0)
111                         Assert.AreEqual (0, ret, message);
112                 else if (result < 0)
113                         Assert.IsTrue (ret < 0, message + String.Format ("(neg: {0})", ret));
114                 else
115                         Assert.IsTrue (ret > 0, message + String.Format ("(pos: {0})", ret));
116         }
117
118         void AssertCompare (string message, int result,
119                 string s1, int idx1, int len1, string s2, int idx2, int len2)
120         {
121                 int ret = invariant.Compare (s1, idx1, len1, s2, idx2, len2);
122                 if (result == 0)
123                         Assert.AreEqual (0, ret, message);
124                 else if (result < 0)
125                         Assert.IsTrue (ret < 0, message);
126                 else
127                         Assert.IsTrue (ret > 0, message);
128         }
129
130         void AssertCompare (string message, int result,
131                 string s1, int idx1, int len1, string s2, int idx2, int len2,
132                 CompareOptions opt, CompareInfo ci)
133         {
134                 int ret = ci.Compare (s1, idx1, len1, s2, idx2, len2, opt);
135                 if (result == 0)
136                         Assert.AreEqual (0, ret, message);
137                 else if (result < 0)
138                         Assert.IsTrue (ret < 0, message);
139                 else
140                         Assert.IsTrue (ret > 0, message);
141         }
142
143         void AssertIndexOf (string message, int expected,
144                 string source, char target)
145         {
146                 Assert.AreEqual (expected, invariant.IndexOf (source, target), message);
147         }
148
149         void AssertIndexOf (string message, int expected, string source,
150                 char target, CompareOptions opt)
151         {
152                 Assert.AreEqual (expected, invariant.IndexOf (source, target, opt), message);
153         }
154
155         void AssertIndexOf (string message, int expected, string source,
156                 char target, int idx, int len, CompareOptions opt, CompareInfo ci)
157         {
158                 Assert.AreEqual (expected, ci.IndexOf (source, target, idx, len, opt), message);
159         }
160
161         void AssertIndexOf (string message, int expected,
162                 string source, string target)
163         {
164                 Assert.AreEqual (expected, invariant.IndexOf (source, target), message);
165         }
166
167         void AssertIndexOf (string message, int expected, string source,
168                 string target, CompareOptions opt)
169         {
170                 Assert.AreEqual (expected, invariant.IndexOf (source, target, opt), message);
171         }
172
173         void AssertIndexOf (string message, int expected, string source,
174                 string target, int idx, int len, CompareOptions opt, CompareInfo ci)
175         {
176                 Assert.AreEqual (expected, ci.IndexOf (source, target, idx, len, opt), message);
177         }
178
179         void AssertLastIndexOf (string message, int expected,
180                 string source, char target)
181         {
182                 Assert.AreEqual (expected, invariant.LastIndexOf (source, target), message);
183         }
184
185         void AssertLastIndexOf (string message, int expected, string source,
186                 char target, CompareOptions opt)
187         {
188                 Assert.AreEqual (expected, invariant.LastIndexOf (source, target, opt), message);
189         }
190
191         void AssertLastIndexOf (string message, int expected, string source,
192                 char target, int idx, int len)
193         {
194                 Assert.AreEqual (expected, invariant.LastIndexOf (source, target, idx, len), message);
195         }
196
197         void AssertLastIndexOf (string message, int expected, string source,
198                 char target, int idx, int len, CompareOptions opt, CompareInfo ci)
199         {
200                 Assert.AreEqual (expected, ci.LastIndexOf (source, target, idx, len, opt), message);
201         }
202
203         void AssertLastIndexOf (string message, int expected,
204                 string source, string target)
205         {
206                 Assert.AreEqual (expected, invariant.LastIndexOf (source, target), message);
207         }
208
209         void AssertLastIndexOf (string message, int expected, string source,
210                 string target, CompareOptions opt)
211         {
212                 Assert.AreEqual (expected, invariant.LastIndexOf (source, target, opt), message);
213         }
214
215         void AssertLastIndexOf (string message, int expected, string source,
216                 string target, int idx, int len)
217         {
218                 Assert.AreEqual (expected, invariant.LastIndexOf (source, target, idx, len), message);
219         }
220
221         void AssertLastIndexOf (string message, int expected, string source,
222                 string target, int idx, int len, CompareOptions opt, CompareInfo ci)
223         {
224                 Assert.AreEqual (expected, ci.LastIndexOf (source, target, idx, len, opt), message);
225         }
226
227         void AssertIsPrefix (string message, bool expected, string source,
228                 string target)
229         {
230                 Assert.IsTrue (expected == invariant.IsPrefix (source, target), message);
231         }
232
233         void AssertIsPrefix (string message, bool expected, string source,
234                 string target, CompareOptions opt)
235         {
236                 Assert.IsTrue (expected == invariant.IsPrefix (source, target, opt), message);
237         }
238
239         void AssertIsSuffix (string message, bool expected, string source,
240                 string target)
241         {
242                 Assert.IsTrue (expected == invariant.IsSuffix (source, target), message);
243         }
244
245         void AssertIsSuffix (string message, bool expected, string source,
246                 string target, CompareOptions opt)
247         {
248                 Assert.IsTrue (expected == invariant.IsSuffix (source, target, opt), message);
249         }
250
251         [Test]
252         public void GetSortKey ()
253         {
254                 if (!doTest)
255                         Assert.Ignore ("Test is disabled.");
256
257                 // AE == \u00C6
258                 AssertSortKey ("#1", new byte [] {0xE, 2, 0xE, 0x21, 1, 1,
259                         0x12, 0x12, 1, 1, 0}, "AE");
260                 AssertSortKey ("#2", new byte [] {0xE, 2, 0xE, 0x21, 1, 1,
261                         0x12, 0x12, 1, 1, 0}, "\u00C6");
262                 AssertSortKey ("#3", new byte [] {1, 1, 1, 1,
263                         0x80, 7, 6, 0x82, 0}, "-");
264                 AssertSortKey ("#4", new byte [] {1, 1, 1, 1,
265                         0x80, 7, 6, 0x82, 0x80, 7, 6, 0x82, 0}, "--");
266                 AssertSortKey ("#4", new byte [] {0xE, 2, 0xE, 9,
267                         0xE, 0xA, 1, 1, 0x12, 0x12, 0x12, 1, 1, 0x80, 0xB,
268                         6, 0x82, 0x80, 0xF, 6, 0x82, 0}, "A-B-C");
269                 AssertSortKey ("#6", new byte [] {0xE, 2, 1,
270                         0x17, 1, 0x12, 1, 1, 0}, "A\u0304");
271                 AssertSortKey ("#7", new byte [] {0xE, 2, 1,
272                         0x17, 1, 0x12, 1, 1, 0}, "\u0100");
273
274                 // StringSort
275                 AssertSortKey ("#8", new byte [] {
276                         0xE, 2, 6, 0x82, 1, 1, 1, 1, 0},
277                         "a-", CompareOptions.StringSort);
278                 // FIXME: not working (table fix is required)
279 //              AssertSortKey ("#9", new byte [] {
280 //                      0xE, 2, 6, 0x82, 1, 1, 2, 0x3, 1, 1, 0},
281 //                      "a\uFF0D", CompareOptions.StringSort);
282
283                 AssertSortKey ("#10", new byte [] {1, 1, 1, 1, 0}, "\u3007");
284         }
285
286
287         [Test]
288         public void GetSortKeyIgnoreWidth ()
289         {
290                 if (!doTest)
291                         Assert.Ignore ("Test is disabled.");
292
293                 AssertSortKey ("#i1", new byte [] {
294                         0xE, 2, 1, 1, 0x13, 1, 1, 0}, "\uFF21");
295                 AssertSortKey ("#i2", new byte [] {
296                         0xE, 2, 1, 1, 0x12, 1, 1, 0}, "\uFF21", CompareOptions.IgnoreWidth);
297                 AssertSortKey ("#i3", new byte [] {
298                         0xE, 2, 1, 1, 0x3, 1, 1, 0}, "\uFF41");
299                 AssertSortKey ("#i4", new byte [] {
300                         0xE, 2, 1, 1, 1, 1, 0}, "\uFF41", CompareOptions.IgnoreWidth);
301         }
302
303         [Test]
304         public void GetSortKeyDiacritical ()
305         {
306                 if (!doTest)
307                         Assert.Ignore ("Test is disabled.");
308
309                 AssertSortKey ("#i1", new byte [] {
310                         0xE, 0x21, 1, 0xE, 1, 1, 1, 0}, "e\u0301");
311                 AssertSortKey ("#i2", new byte [] {
312                         0xE, 0x21, 1, 0x12, 1, 1, 1, 0}, "e\u0302");
313                 AssertSortKey ("#i3", new byte [] {
314                         0xE, 0x21, 1, 0x13, 1, 1, 1, 0}, "e\u0308");
315                 AssertSortKey ("#i4", new byte [] {
316                         0xE, 0x21, 1, 0x1F, 1, 1, 1, 0}, "e\u0308\u0301");
317                 // FIXME: not working (table fix is required)
318 //              AssertSortKey ("#i5", new byte [] {
319 //                      0xE, 0x21, 1, 0x16, 1, 1, 1, 0}, "e\u0344");
320                 AssertSortKey ("#i6", new byte [] {
321                         0x22, 2, 1, 0xE, 1, 1, 0xC4, 0xFF, 2, 0xFF, 0xFF, 1, 0}, "\u3041\u0301");
322                 AssertSortKey ("#i7", new byte [] {
323                         0xC, 0x21, 1, 0xE, 1, 1, 1, 0}, "1\u0301");
324                 AssertSortKey ("#i8", new byte [] {
325                         0x22, 0xA, 1, 3, 1, 1, 0xFF, 2, 0xFF, 0xFF, 1, 0}, "\u304B\u309B");
326                 AssertSortKey ("#i9", new byte [] {
327                         0x22, 0xA, 1, 3, 1, 1, 0xFF, 2, 0xFF, 0xFF, 1, 0}, "\u304C");
328
329                 AssertSortKey ("#i10", new byte [] {
330                         0xE, 0x2, 1, 0x12, 1, 0x12, 1, 1, 0},
331                         "A\u0302");
332                 AssertSortKey ("#i11", new byte [] {
333                         0xE, 0x2, 1, 0x65, 1, 0x12, 1, 1, 0},
334                         "A\u0302\u0320");
335                 AssertSortKey ("#i12", new byte [] {
336                         0xE, 0x2, 1, 0xB8, 1, 0x12, 1, 1, 0},
337                         "A\u0302\u0320\u0320");
338                 // LAMESPEC: Windows just appends diacritical weight without
339 //              AssertSortKey ("#i13", new byte [] {
340 //                      0xE, 0x2, 1, 0xB, 1, 12, 1, 1, 0},
341 //                      "A\u0302\u0320\u0320\u0320");
342                 // FIXME: not working (table fix is required)
343 //              AssertSortKey ("#i14", new byte [] {
344 //                      0xE, 0x2, 1, 0xF2, 1, 0x12, 1, 1, 0},
345 //                      "A\u20E1");
346                 // LAMESPEC: It should not be equivalent to \u1EA6
347                 AssertSortKey ("#i15", new byte [] {
348                         0xE, 0x2, 1, 0x1F, 1, 0x12, 1, 1, 0},
349                         "A\u0308\u0301");
350                 AssertSortKey ("#i16", new byte [] {
351                         0xE, 0x2, 1, 0x1F, 1, 0x12, 1, 1, 0},
352                         "\u1EA6");
353
354         }
355
356         [Test]
357         public void GetSortKeyIgnoreNonSpaceKana ()
358         {
359                 if (!doTest)
360                         Assert.Ignore ("Test is disabled.");
361
362                 AssertSortKey ("#i1", new byte [] {
363                         0x22, 0x1A, 1, 1, 1, 0xFF, 2, 0xFF, 0xFF, 1, 0},
364                         "\u305F");
365                 AssertSortKey ("#i2", new byte [] {
366                         0x22, 0x1A, 1, 3, 1, 1, 0xFF, 2, 0xFF, 0xFF, 1, 0},
367                         "\u3060");
368                 AssertSortKey ("#i3", new byte [] {
369                         0x22, 0x1A, 1, 1, 1, 0xFF, 2, 0xFF, 0xFF, 1, 0},
370                         "\u305F", CompareOptions.IgnoreNonSpace);
371                 AssertSortKey ("#i4", new byte [] {
372                         0x22, 0x1A, 1, 1, 1, 0xFF, 2, 0xFF, 0xFF, 1, 0},
373                         "\u3060", CompareOptions.IgnoreNonSpace);
374         }
375
376         [Test]
377         public void GetSortKeySpecialWeight ()
378         {
379                 if (!doTest)
380                         Assert.Ignore ("Test is disabled.");
381
382                 AssertSortKey ("#i1", new byte [] {
383                         0x22, 0xA, 0x22, 2, 1, 1, 1, 0xFF, 2, 0xFF, 0xFF, 1, 0},
384                         "\u304B\u3042");
385                 AssertSortKey ("#i2", new byte [] {
386                         0x22, 0xA, 0x22, 2, 1, 1, 1, 0xFF, 3, 5, 2, 0xFF, 0xFF, 1, 0},
387                         "\u304B\u30FC");
388                 AssertSortKey ("#i3", new byte [] {
389                         0x22, 0xA, 0x22, 2, 1, 1, 1, 0xFF, 2, 0xFF, 0xFF, 1, 0},
390                         "\u304B\u30FC", CompareOptions.IgnoreNonSpace);
391
392                 AssertSortKey ("#i4", new byte [] {
393                         0x22, 0xA, 0x22, 0xA, 1, 2, 3, 1, 1, 0xFF, 2, 0xC4, 0xC4, 0xFF, 0xFF, 1, 0},
394                         "\u30AB\u30AC");
395                 AssertSortKey ("#i5", new byte [] {
396                         0x22, 0xA, 0x22, 0xA, 0x22, 2, 1, 1, 1, 0xFF, 3, 3, 5, 2, 0xC4, 0xC4, 0xC4, 0xFF, 0xFF, 1, 0},
397                         "\u30AB\u30AB\u30FC");
398                 AssertSortKey ("#i6", new byte [] {
399                         0x22, 0xA, 0x22, 2, 0x22, 2, 1, 1, 1, 0xFF, 3, 3, 5, 2, 0xC4, 0xC4, 0xC4, 0xFF, 0xFF, 1, 0},
400                         "\u30AB\u30A2\u30FC");
401                 AssertSortKey ("#i7", new byte [] {
402                         0x22, 0xA, 0x22, 2, 0x22, 2, 0x22, 0xA, 1, 1, 1, 0xFF, 3, 3, 5, 2, 0xC4, 0xC4, 0xC4, 0xC4, 0xFF, 0xFF, 1, 0},
403                         "\u30AB\u30A2\u30FC\u30AB");
404                 AssertSortKey ("#i8", new byte [] {
405                         0x22, 0xA, 0x22, 0xA, 1, 1, 1, 0xFF, 3, 4, 2, 0xFF, 0xFF, 1, 0},
406                         "\u304B\u309D");
407                 AssertSortKey ("#i9", new byte [] {
408                         0x22, 0xA, 0x22, 0xA, 1, 2, 3, 1, 1, 0xFF, 3, 4, 2, 0xFF, 0xFF, 1, 0},
409                         "\u304B\u309E");
410                 AssertSortKey ("#i10", new byte [] {
411                         0x22, 0x2, 0x22, 0x2, 1, 2, 3, 1, 1, 0xFF, 3, 4, 2, 0xFF, 0xFF, 1, 0},
412                         "\u3042\u309E");//not possible
413                 AssertSortKey ("#i11", new byte [] {
414                         0x22, 0xA, 0x22, 0xA, 1, 1, 1, 0xFF, 3, 4, 2, 0xFF, 0xFF, 1, 0},
415                         "\u304B\u30FD");//not possible
416                 AssertSortKey ("#i12", new byte [] {
417                         0x22, 0xA, 0x22, 0xA, 1, 2, 3, 1, 1, 0xFF, 3, 4, 2, 0xFF, 0xFF, 1, 0},
418                         "\u304B\u30FE");//not possible
419                 AssertSortKey ("#i13", new byte [] {
420                         0x22, 0xA, 0x22, 0xA, 1, 1, 1, 0xFF, 3, 4, 2, 0xC4, 0xC4, 0xFF, 0xFF, 1, 0},
421                         "\u30AB\u30FD");
422                 AssertSortKey ("#i14", new byte [] {
423                         0x22, 0xA, 0x22, 2, 1, 1, 1, 0xFF, 3, 5, 2, 0xC4, 0xC4, 0xFF, 0xC4, 0xC4, 0xFF, 1, 0},
424                         "\uFF76\uFF70");
425                 AssertSortKey ("#i15", new byte [] {
426                         0x22, 0xA, 0x22, 0xA, 1, 2, 5, 1, 1, 0xFF, 3, 4, 2, 0xFF, 0xFF, 1, 0},
427                         "\u304B\u3005");
428                 AssertSortKey ("#i16", new byte [] {
429                         0xAF, 9, 0xAF, 9, 1, 2, 5, 1, 1, 1, 0},
430                         "\u5EA6\u3005");
431                 AssertSortKey ("#i17", new byte [] {
432                         0xE, 2, 0xE, 2, 1, 2, 5, 1, 1, 1, 0},
433                         "a\u3005"); // huh
434                 // Not working, but I wonder if it is really FIXME.
435 //              AssertSortKey ("#i18", new byte [] {
436 //                      0xFF, 0xFF, 1, 1, 1, 1, 0},
437 //                      "\u3005");
438                 // LAMESPEC. No one can handle \u3031 correctly.
439 //              AssertSortKey ("#i19", new byte [] {
440 //                      0x22, 0x22, 0x22, 0xC, 0x22, 0xC, 1, 1, 1, 0xFF, 3, 4, 2, 0xFF, 0xFF, 1, 0},
441 //                      "\u306A\u304F\u3031");
442
443                 // IgnoreWidth -> all Kana becomes half-width
444                 AssertSortKey ("#i20", new byte [] {
445                         34, 26, 34, 3, 34, 44, 1, 3, 2, 3, 1, 1, 255, 2, 196, 196, 196, 255, 196, 196, 196, 255, 1, 0},
446                         "\uFF80\uFF9E\uFF72\uFF8C\uFF9E", CompareOptions.IgnoreWidth);
447                 AssertSortKey ("#i21", new byte [] {
448                         34, 26, 34, 3, 34, 44, 1, 3, 2, 3, 1, 1, 255, 2, 196, 196, 196, 255, 196, 196, 196, 255, 1, 0},
449                         "\u30C0\u30A4\u30D6", CompareOptions.IgnoreWidth);
450
451                 AssertSortKey ("#i22", new byte [] {
452                         0x22, 0x2A, 0x22, 2, 0x22, 0x44, 1, 3, 1, 1, 0xFF,
453                         3, 5, 2, 0xC4, 0xC4, 0xC4, 0xFF, 0xC4, 0xC4, 0xC4,
454                         0xFF, 1, 0},
455                         "\u30D0\u30FC\u30EB", CompareOptions.IgnoreWidth);
456                 AssertSortKey ("#i23", new byte [] {
457                         0x22, 0x2A, 0x22, 2, 0x22, 0x44, 1, 3, 1, 1, 0xFF,
458                         3, 5, 2, 0xC4, 0xC4, 0xC4, 0xFF, 0xC4, 0xC4, 0xC4,
459                         0xFF, 1, 0},
460                         "\uFF8A\uFF9E\uFF70\uFF99", CompareOptions.IgnoreWidth);
461                 // extender + IgnoreNonSpace
462                 AssertSortKey ("#i24", new byte [] {
463                         0x22, 2, 0x22, 2, 1, 1, 1, 0xFF, 2, 0xFF, 0xFF, 1, 0},
464                         "\u3042\u309D", CompareOptions.IgnoreNonSpace);
465         }
466
467         [Test]
468         public void GetSortKeyLevel5 ()
469         {
470                 if (!doTest)
471                         Assert.Ignore ("Test is disabled.");
472
473                 // shift weight
474                 AssertSortKeyLevel5 ("#8", new byte [] {
475                         0x80, 7, 6, 0x82, 0x80, 0x2F, 6, 0x82, 0},
476                         '-' + new string ('A', 10) + '-');
477                 AssertSortKeyLevel5 ("#9", new byte [] {
478                         0x80, 7, 6, 0x82, 0x80, 0xFF, 6, 0x82, 0},
479                         '-' + new string ('A', 62) + '-');
480                 AssertSortKeyLevel5 ("#10", new byte [] {
481                         0x80, 7, 6, 0x82, 0x81, 3, 6, 0x82, 0},
482                         '-' + new string ('A', 63) + '-');
483                 AssertSortKeyLevel5 ("#11", new byte [] {
484                         0x80, 7, 6, 0x82, 0x81, 0x97, 6, 0x82, 0},
485                         '-' + new string ('A', 100) + '-');
486                 AssertSortKeyLevel5 ("#12", new byte [] {
487                         0x80, 7, 6, 0x82, 0x8F, 0xA7, 6, 0x82, 0},
488                         '-' + new string ('A', 1000) + '-');
489                 AssertSortKeyLevel5 ("#13", new byte [] {
490                         0x80, 7, 6, 0x82, 0x9A, 0x87, 6, 0x82, 0},
491                         '-' + new string ('A', 100000) + '-');
492                 // This shows how Windows is broken.
493 //              AssertSortKeyLevel5 ("#14",
494 //                      0x80, 7, 6, 0x82, 0x89, 0x07, 6, 0x82, 0},
495 //                      '-' + new string ('A', 1000000) + '-');
496
497         }
498
499         [Test]
500         public void GetSortKey_Options ()
501         {
502                 Array values = Enum.GetValues (typeof (CompareOptions));
503                 foreach (int i in values) {
504                         CompareOptions option = (CompareOptions) i;
505                         if (option == CompareOptions.OrdinalIgnoreCase || option == CompareOptions.Ordinal) {
506                                 try {
507                                         french.GetSortKey ("foo", option);
508                                         Assert.Fail ("#1: " + option.ToString ());
509                                 } catch (ArgumentException ex) {
510                                         Assert.AreEqual (typeof (ArgumentException), ex.GetType (), "#2: " + option.ToString ());
511                                         Assert.IsNotNull (ex.Message, "#2: " + option.ToString ());
512                                         Assert.IsNotNull (ex.ParamName, "#3: " + option.ToString ());
513                                         Assert.AreEqual ("options", ex.ParamName, "#4: " + option.ToString ());
514                                         Assert.IsNull (ex.InnerException, "#5: " + option.ToString ());
515                                 }
516                         } else {
517                                 french.GetSortKey ("foo", option);
518                         }
519                 }
520         }
521
522         [Test]
523         [Category ("NotDotNet")]
524         public void FrenchSort ()
525         {
526                 if (!doTest)
527                         Assert.Ignore ("Test is disabled.");
528
529                 // invariant
530                 AssertSortKey ("#inv-1", new byte [] {0xE, 0xA, 0xE, 0x7C, 0xE, 0x99, 0xE, 0x21, 1, 2, 0x12, 1, 1, 1, 0}, "c\u00F4te");
531                 AssertSortKey ("#inv-1-2", new byte [] {0xE, 0xA, 0xE, 0x7C, 0xE, 0x99, 0xE, 0x21, 1, 2, 0x12, 1, 1, 1, 0}, "co\u0302te");
532                 AssertSortKey ("#inv-1-3", new byte [] {0xE, 0xA, 0xE, 0x7C, 0xE, 0x99, 0xE, 0x21, 1, 2, 2, 2, 0x15, 1, 1, 1, 0}, "cote\u0306");
533                 AssertSortKey ("#inv-2", new byte [] {0xE, 0xA, 0xE, 0x7C, 0xE, 0x99, 0xE, 0x21, 1, 2, 2, 2, 0xE, 1, 1, 1, 0}, "cot\u00E9");
534                 AssertSortKey ("#inv-2-2", new byte [] {0xE, 0xA, 0xE, 0x7C, 0xE, 0x99, 0xE, 0x21, 1, 2, 0x14, 1, 1, 1, 0}, "co\u030Cte");
535 // They are all bugs in 2.0:
536 // #inv-3: should not be 0 since those sortkey values differ.
537 // #inv-4: should not be -1 since co\u0302te sortkey is bigger than cote\u0306.
538                 AssertCompare ("#inv-3", 1, "c\u00F4te", "cot\u00E9");
539                 AssertCompare ("#inv-4", 1, "co\u0302te", "cote\u0306");
540                 AssertCompare ("#inv-5", 1, "co\u030Cte", "cote\u0306");
541
542                 // french
543                 AssertSortKey ("#fr-1", new byte [] {0xE, 0xA, 0xE, 0x7C, 0xE, 0x99, 0xE, 0x21, 1, 2, 2, 0x12, 1, 1, 1, 0}, "c\u00F4te", CompareOptions.None, french);
544                 AssertSortKey ("#fr-2", new byte [] {0xE, 0xA, 0xE, 0x7C, 0xE, 0x99, 0xE, 0x21, 1, 0xE, 1, 1, 1, 0}, "cot\u00E9", CompareOptions.None, french);
545                 AssertCompare ("#fr-3", -1, "c\u00F4te", "cot\u00E9", CompareOptions.None, french);
546                 // FIXME: why does .NET return 1 ?
547 //              AssertCompare ("#fr-4", -1, "co\u0302te", "cote\u0306", CompareOptions.None, french);
548 //              AssertCompare ("#fr-4", -1, "co\u030Cte", "cote\u0306", CompareOptions.None, french);
549         }
550
551         [Test]
552         public void GetSortKeyThai ()
553         {
554                 if (!doTest)
555                         Assert.Ignore ("Test is disabled.");
556
557                 AssertSortKey ("#i1", new byte [] {
558                         0x1E, 7, 0x1F, 0x28, 1, 3, 3, 1, 1, 1, 0},
559                         "\u0E01\u0E3A");
560                 AssertSortKey ("#i2", new byte [] {
561                         0x1E, 7, 1, 3, 1, 1, 1, 0},
562                         "\u0E01\u0E3B");
563 // FIXME: not working (table fix required)
564 //              AssertSortKey ("#i6", new byte [] {
565 //                      0x1E, 7, 0xA, 0xF9, 1, 3, 1, 1, 1, 0},
566 //                      "\u0E01\u0E3F");
567                 AssertSortKey ("#i7", new byte [] {
568                         0x1E, 7, 0x1E, 2, 1, 3, 3, 1, 1, 1, 0},
569                         "\u0E01\u0E40");
570                 AssertSortKey ("#i8", new byte [] {
571                         0x1E, 7, 0x1E, 3, 1, 3, 3, 1, 1, 1, 0},
572                         "\u0E01\u0E41");
573                 AssertSortKey ("#i9", new byte [] {
574                         0x1E, 7, 0x1E, 4, 1, 3, 3, 1, 1, 1, 0},
575                         "\u0E01\u0E42");
576                 AssertSortKey ("#i10", new byte [] {
577                         0x1E, 7, 0x1E, 5, 1, 3, 3, 1, 1, 1, 0},
578                         "\u0E01\u0E43");
579                 AssertSortKey ("#i11", new byte [] {
580                         0x1E, 7, 0x1E, 6, 1, 3, 3, 1, 1, 1, 0},
581                         "\u0E01\u0E44");
582                 AssertSortKey ("#i12", new byte [] {
583                         0x1E, 7, 0x1F, 0x29, 1, 3, 3, 1, 1, 1, 0},
584                         "\u0E01\u0E45");
585                 AssertSortKey ("#i13", new byte [] {
586                         0x1E, 7, 0x1F, 0x2A, 1, 3, 3, 1, 1, 1, 0},
587                         "\u0E01\u0E46");
588 // FIXME: not working (U+E47 table fix required)
589 //              AssertSortKey ("#i14", new byte [] {
590 //                      0x1E, 7, 1, 5, 1, 1, 1, 0},
591 //                      "\u0E01\u0E47");
592                 AssertSortKey ("#i15", new byte [] {
593                         0x1E, 7, 1, 6, 1, 1, 1, 0},
594                         "\u0E01\u0E48");
595                 AssertSortKey ("#i16", new byte [] {
596                         0x1E, 7, 1, 7, 1, 1, 1, 0},
597                         "\u0E01\u0E49");
598                 AssertSortKey ("#i17", new byte [] {
599                         0x1E, 7, 1, 8, 1, 1, 1, 0},
600                         "\u0E01\u0E4A");
601                 AssertSortKey ("#i18", new byte [] {
602                         0x1E, 7, 1, 9, 1, 1, 1, 0},
603                         "\u0E01\u0E4B");
604 // FIXME: not working (U+E47 table fix required)
605 //              AssertSortKey ("#i19", new byte [] {
606 //                      0x1E, 7, 1, 8, 1, 1, 1, 0},
607 //                      "\u0E01\u0E48\u0E47");
608                 AssertSortKey ("#i20", new byte [] {
609                         0x1E, 7, 0x1E, 4, 0x1E, 0xD, 1, 3, 3, 3, 1, 1, 1, 0},
610                         "\u0E01\u0E42\u0E02");
611                 AssertSortKey ("#i21", new byte [] {
612                         0x1E, 7, 0x1E, 0xD, 1, 3, 3, 1, 1, 1, 0},
613                         "\u0E01\u0E02");
614         }
615
616         [Test]
617         public void GetSortKeyCzechTailoring ()
618         {
619                 if (!doTest)
620                         Assert.Ignore ("Test is disabled.");
621
622                 AssertSortKey ("#i1", new byte [] {
623                         0xE, 0xA, 0xE, 0x2C, 1, 1, 1, 1, 0},
624                         "ch");
625                 AssertSortKey ("#cs1", new byte [] {
626                         0xE, 0x2E, 1, 1, 1, 1, 0},
627                         "ch", CompareOptions.None, czech);
628                 AssertSortKey ("#i2", new byte [] {
629                         0xE, 0x8A, 1, 0x14, 1, 1, 1, 0},
630                         "r\u030C");
631                 AssertSortKey ("#cs2", new byte [] {
632                         0xE, 0x8A, 1, 0x14, 1, 1, 1, 0},
633                         "r\u030C", CompareOptions.None, czech);
634         }
635
636         [Test]
637         public void GetSortKeyHungarianTailoring ()
638         {
639                 if (!doTest)
640                         Assert.Ignore ("Test is disabled.");
641
642                 AssertSortKey ("#1", new byte [] {
643                         0xE, 0xE, 1, 1, 0x1A, 1, 1, 0},
644                         "CS", CompareOptions.None, hungarian);
645                 AssertSortKey ("#2", new byte [] {
646                         0xE, 0xE, 1, 1, 0x12, 1, 1, 0},
647                         "Cs", CompareOptions.None, hungarian);
648                 AssertSortKey ("#3", new byte [] {
649                         0xE, 0xE, 1, 1, 1, 1, 0},
650                         "cs", CompareOptions.None, hungarian);
651                 AssertSortKey ("#4", new byte [] {
652                         0xE, 0x1C, 1, 1, 0x1A, 1, 1, 0},
653                         "DZ", CompareOptions.None, hungarian);
654                 AssertSortKey ("#5", new byte [] {
655                         0xE, 0x1C, 1, 1, 0x12, 1, 1, 0},
656                         "Dz", CompareOptions.None, hungarian);
657                 AssertSortKey ("#6", new byte [] {
658                         0xE, 0x1C, 1, 1, 1, 1, 0},
659                         "dz", CompareOptions.None, hungarian);
660                 AssertSortKey ("#7", new byte [] {
661                         0xE, 0x75, 1, 1, 0x1A, 1, 1, 0},
662                         "NY", CompareOptions.None, hungarian);
663                 AssertSortKey ("#8", new byte [] {
664                         0xE, 0x75, 1, 1, 0x12, 1, 1, 0},
665                         "Ny", CompareOptions.None, hungarian);
666                 AssertSortKey ("#9", new byte [] {
667                         0xE, 0x75, 1, 1, 1, 1, 0},
668                         "ny", CompareOptions.None, hungarian);
669                 AssertSortKey ("#10", new byte [] {
670                         0xE, 0xB1, 1, 1, 0x1A, 1, 1, 0},
671                         "ZS", CompareOptions.None, hungarian);
672                 AssertSortKey ("#11", new byte [] {
673                         0xE, 0xB1, 1, 1, 0x12, 1, 1, 0},
674                         "Zs", CompareOptions.None, hungarian);
675                 AssertSortKey ("#12", new byte [] {
676                         0xE, 0xB1, 1, 1, 1, 1, 0},
677                         "zs", CompareOptions.None, hungarian);
678
679                 // Windows seems to have bugs around repetitive characters
680                 // that is tailored.
681 //              AssertSortKey ("#x", new byte [] {
682 //                      0xE, 0x2E, 1, 1, 1, 1, 0},
683 //                      "CCS", CompareOptions.None, hungarian);
684
685                 // FIXME: we need to handle case insensitivity
686         }
687
688         [Test]
689         public void CustomCJKTable ()
690         {
691                 if (!doTest)
692                         Assert.Ignore ("Test is disabled.");
693
694                 AssertSortKey ("#1", new byte [] {
695                         0x9E, 9, 0x9E, 0x11, 1, 1, 1, 1, 0},
696                         "\u4E03\u4E09");
697                 AssertSortKey ("#2", new byte [] {
698                         0x84, 0xD3, 0x84, 0x61, 1, 1, 1, 1, 0},
699                         "\u4E03\u4E09", CompareOptions.None, japanese);
700         }
701
702         [Test]
703         [Category ("NotDotNet")]
704         public void CultureSensitiveCompare ()
705         {
706                 if (!doTest)
707                         Assert.Ignore ("Test is disabled.");
708
709                 AssertCompare ("#1", -1, "1", "2");
710                 AssertCompare ("#2", 1, "A", "a");
711                 AssertCompare ("#3", 0, "A", "a", CompareOptions.IgnoreCase);
712                 AssertCompare ("#4", 0, "\uFF10", "0", CompareOptions.IgnoreWidth);
713                 AssertCompare ("#5", 0, "\uFF21", "a", ignoreCW);
714                 AssertCompare ("#6", 1, "12", "1");
715 // BUG in .NET 2.0: See GetSortKey() test that assures sortkeys for "AE" and
716 // "\u00C6" are equivalent.
717                 AssertCompare ("#7", 0, "AE", "\u00C6");
718                 AssertCompare ("#8", 0, "AB\u01c0C", "A\u01c0B\u01c0C", CompareOptions.IgnoreSymbols);
719 // BUG in .NET 2.0: ditto.
720                 AssertCompare ("#9", 0, "A\u0304", "\u0100");
721                 AssertCompare ("#10", 1, "ABCABC", 5, 1, "1", 0, 1, CompareOptions.IgnoreCase, invariant);
722                 AssertCompare ("#11", 0, "-d:NET_2_0", 0, 1, "-", 0, 1);
723
724 // BUG in .NET 2.0: ditto.
725                 AssertCompare ("#12", 0, "ae", "\u00E6");
726                 AssertCompare ("#13", 0, "\u00E6", "ae");
727                 AssertCompare ("#14", 0, "\u00E6s", 0, 1, "ae", 0, 2);
728
729                 // target is "empty" (in culture-sensitive context).
730 // BUG in .NET 2.0: \u3007 is totally-ignored character as a GetSortKey()
731 // result, while it is not in Compare().
732                 AssertCompare ("#17", 0, String.Empty, "\u3007");
733                 AssertCompare ("#18", 1, "A", "\u3007");
734                 AssertCompare ("#19", 1, "ABC", "\u3007");
735
736                 // shift weight comparison 
737                 AssertCompare ("#20", 1, "--start", "--");
738                 // expansion
739 // BUG in .NET 2.0: the same 00C6/00E6 issue.
740                 AssertCompare ("#21", -1, "\u00E6", "aes");
741
742 // bug #78748
743                 AssertCompare ("#22", -1, "++)", "+-+)");
744                 AssertCompare ("#23", -1, "+-+)", "+-+-)");
745                 AssertCompare ("#24", 1, "+-+-)", "++)");
746                 // BUG in .NET: it returns 1
747                 AssertCompare ("#25", -1, "+-+-)", "-+-+)");
748                 AssertCompare ("#26", -1, "+-+)", "-+-+)");
749                 AssertCompare ("#27", -1, "++)", "-+-+)");
750                 // bug #79714
751                 AssertCompare ("#28", 1, "aa ", "A");
752         }
753
754         [Test]
755         [Category ("NotDotNet")]
756         public void CompareSpecialWeight ()
757         {
758                 if (!doTest)
759                         Assert.Ignore ("Test is disabled.");
760
761                 // Japanese (in invariant)
762 // BUG in .NET 2.0 : half-width kana should be bigger.
763                 AssertCompare ("#1", 1, "\u30D1\u30FC\u30B9", "\uFF8A\uFF9F\uFF70\uFF7D");
764                 AssertCompare ("#2", 0, "\u30D1\u30FC\u30B9", "\uFF8A\uFF9F\uFF70\uFF7D", CompareOptions.IgnoreWidth);
765                 AssertCompare ("#3", 0, "\uFF80\uFF9E\uFF72\uFF8C\uFF9E", 
766                         "\u30C0\u30A4\u30D6", CompareOptions.IgnoreWidth);
767                 AssertCompare ("#4", 1, "\u3042\u309D", "\u3042\u3042");
768                 AssertCompare ("#5", 0, "\u3042\u309D", "\u3042\u3042", CompareOptions.IgnoreNonSpace);
769                 AssertCompare ("#6", 0, "\uFF8A\uFF9E\uFF70\uFF99",
770                         "\u30D0\u30FC\u30EB", CompareOptions.IgnoreWidth);
771
772                 // extender in target
773 // BUG in .NET 2.0 : an extender should result in bigger sortkey
774                 AssertCompare ("#7", -1, "\u30D1\u30A2", "\u30D1\u30FC");
775                 AssertCompare ("#8", 0, "\u30D1\u30A2", "\u30D1\u30FC", CompareOptions.IgnoreNonSpace);
776                 // extender in source
777 // BUG in .NET 2.0 : vice versa
778                 AssertCompare ("#9", 1, "\u30D1\u30FC", "\u30D1\u30A2");
779                 AssertCompare ("#10", 0, "\u30D1\u30FC", "\u30D1\u30A2", CompareOptions.IgnoreNonSpace);
780         }
781
782         [Test]
783         public void IndexOfChar ()
784         {
785                 if (!doTest)
786                         Assert.Ignore ("Test is disabled.");
787
788                 AssertIndexOf ("#1", -1, "ABC", '1');
789                 AssertIndexOf ("#2", 2, "ABCABC", 'c', CompareOptions.IgnoreCase);
790                 AssertIndexOf ("#3", 1, "ABCABC", '\uFF22', ignoreCW);
791                 AssertIndexOf ("#4", 4, "ABCDE", '\u0117', ignoreCN);
792                 AssertIndexOf ("#5", 1, "ABCABC", 'B', 1, 5, CompareOptions.IgnoreCase, invariant);
793                 AssertIndexOf ("#6", 4, "ABCABC", 'B', 2, 4, CompareOptions.IgnoreCase, invariant);
794                 AssertIndexOf ("#7", 1, "\u30D1\u30FC", '\u30A2', CompareOptions.IgnoreNonSpace);
795                 AssertIndexOf ("#8", 1, "UAE", '\u00C6');
796                 AssertIndexOf ("#8-2", 1, "AAE", '\u00C6');
797                 AssertIndexOf ("#9", -1, "UA", '\u00C6');
798                 AssertIndexOf ("#10", -1, "UE", '\u00C6');
799         }
800
801         [Test]
802         [Category ("NotDotNet")]
803         public void IndexOfCharMSBug ()
804         {
805                 if (!doTest)
806                         Assert.Ignore ("Test is disabled.");
807
808                 AssertIndexOf ("#1", 0, "\u00E6", 'a');
809         }
810
811         [Test]
812         public void LastIndexOfChar ()
813         {
814                 if (!doTest)
815                         Assert.Ignore ("Test is disabled.");
816
817                 AssertLastIndexOf ("#1", -1, "ABC", '1');
818                 AssertLastIndexOf ("#2", 5, "ABCABC", 'c', CompareOptions.IgnoreCase);
819                 AssertLastIndexOf ("#3", 4, "ABCABC", '\uFF22', ignoreCW);
820                 AssertLastIndexOf ("#4", 4, "ABCDE", '\u0117', ignoreCN);
821                 AssertLastIndexOf ("#5", 1, "ABCABC", 'B', 3, 3);
822                 AssertLastIndexOf ("#6", 4, "ABCABC", 'B', 4, 4);
823                 AssertLastIndexOf ("#7", -1, "ABCABC", 'B', 5, 1);
824                 AssertLastIndexOf ("#8", 1, "UAE", '\u00C6');
825                 AssertLastIndexOf ("#8-2", 1, "UAEE", '\u00C6');
826                 AssertLastIndexOf ("#9", -1, "UA", '\u00C6');
827                 AssertLastIndexOf ("#10", -1, "UE", '\u00C6');
828                 AssertLastIndexOf ("#11", 0, "\\", '\\');
829                 Assert.AreEqual (0, new CultureInfo ("en").CompareInfo.LastIndexOf ("\\", '\\'), "#11en");
830                 Assert.AreEqual (0, new CultureInfo ("ja").CompareInfo.LastIndexOf ("\\", '\\'), "#11ja");
831                 AssertLastIndexOf ("#12", 8, "/system/web", 'w');
832                 Assert.AreEqual (8, new CultureInfo ("sv").CompareInfo.LastIndexOf ("/system/web", 'w'), "#12sv");
833         }
834
835         [Test]
836         [Category ("NotDotNet")]
837         public void LastIndexOfCharMSBug ()
838         {
839                 if (!doTest)
840                         Assert.Ignore ("Test is disabled.");
841
842                 AssertIndexOf ("#1", 0, "\u00E6", 'a');
843         }
844
845         [Test]
846         [Category ("NotDotNet")]
847         public void IsPrefix ()
848         {
849                 if (!doTest)
850                         Assert.Ignore ("Test is disabled.");
851
852                 AssertIsPrefix ("#1", false, "ABC", "c", CompareOptions.IgnoreCase);
853                 AssertIsPrefix ("#2", false, "BC", "c", CompareOptions.IgnoreCase);
854                 AssertIsPrefix ("#3", true, "C", "c", CompareOptions.IgnoreCase);
855                 AssertIsPrefix ("#4", true, "EDCBA", "\u0117", ignoreCN);
856                 AssertIsPrefix ("#5", true, "ABC", "AB", CompareOptions.IgnoreCase);
857 // BUG in .NET 2.0 : see GetSortKey() test (mentioned above).
858                 AssertIsPrefix ("#6", true, "ae", "\u00E6", CompareOptions.None);
859                 AssertIsPrefix ("#7", true, "\u00E6", "ae", CompareOptions.None);
860
861 // BUG in .NET 2.0 : see GetSortKey() test (mentioned above).
862                 AssertIsPrefix ("#8", true, "\u00E6", "a", CompareOptions.None);
863                 AssertIsPrefix ("#9", true, "\u00E6s", "ae", CompareOptions.None);
864                 AssertIsPrefix ("#10", false, "\u00E6", "aes", CompareOptions.None);
865                 AssertIsPrefix ("#11", true, "--start", "--", CompareOptions.None);
866                 AssertIsPrefix ("#12", true, "-d:NET_1_1", "-", CompareOptions.None);
867                 AssertIsPrefix ("#13", false, "-d:NET_1_1", "@", CompareOptions.None);
868                 // U+3007 is completely ignored character.
869                 AssertIsPrefix ("#14", true, "\uff21\uff21", "\uff21", CompareOptions.None);
870 // BUG in .NET 2.0 : see \u3007 issue (mentioned above).
871                 AssertIsPrefix ("#15", true, "\uff21\uff21", "\u3007\uff21", CompareOptions.None);
872                 AssertIsPrefix ("#16", true, "\uff21\uff21", "\uff21\u3007", CompareOptions.None);
873                 AssertIsPrefix ("#17", true, "\\b\\a a", "\\b\\a a");
874                 Assert.IsTrue (new CultureInfo ("en").CompareInfo.IsPrefix ("\\b\\a a", "\\b\\a a"), "#17en");
875                 Assert.IsTrue (new CultureInfo ("ja").CompareInfo.IsPrefix ("\\b\\a a", "\\b\\a a"), "#17ja");
876         }
877
878         [Test]
879         public void IsPrefixSpecialWeight ()
880         {
881                 if (!doTest)
882                         Assert.Ignore ("Test is disabled.");
883
884                 // Japanese (in invariant)
885                 AssertIsPrefix ("#1", false, "\u30D1\u30FC\u30B9", "\uFF8A\uFF9F\uFF70\uFF7D");
886                 AssertIsPrefix ("#2", true, "\u30D1\u30FC\u30B9", "\uFF8A\uFF9F\uFF70\uFF7D", CompareOptions.IgnoreWidth);
887                 AssertIsPrefix ("#2-2", false, "\u30D1\u30FC\u30B9", "\uFF8A\uFF9F\uFF70\uFF7D");
888                 AssertIsPrefix ("#3", true, "\uFF80\uFF9E\uFF72\uFF8C\uFF9E", 
889                         "\u30C0\u30A4\u30D6", CompareOptions.IgnoreWidth);
890                 AssertIsPrefix ("#3-2", false, "\uFF80\uFF9E\uFF72\uFF8C\uFF9E", 
891                         "\u30C0\u30A4\u30D6");
892                 AssertIsPrefix ("#4", false, "\u3042\u309D", "\u3042\u3042");
893                 AssertIsPrefix ("#5", true, "\u3042\u309D", "\u3042\u3042", CompareOptions.IgnoreNonSpace);
894                 AssertIsPrefix ("#6", true, "\uFF8A\uFF9E\uFF70\uFF99",
895                         "\u30D0\u30FC\u30EB", CompareOptions.IgnoreWidth);
896
897                 // extender in target
898                 AssertIsPrefix ("#7", false, "\u30D1\u30A2", "\u30D1\u30FC");
899                 AssertIsPrefix ("#8", true, "\u30D1\u30A2", "\u30D1\u30FC", CompareOptions.IgnoreNonSpace);
900                 // extender in source
901                 AssertIsPrefix ("#9", false, "\u30D1\u30FC", "\u30D1\u30A2");
902                 AssertIsPrefix ("#10", true, "\u30D1\u30FC", "\u30D1\u30A2", CompareOptions.IgnoreNonSpace);
903
904                 // empty suffix always matches the source.
905                 AssertIsPrefix ("#11", true, "", "");
906                 AssertIsPrefix ("#12", true, "/test.css", "");
907
908                 // bug #76243
909                 AssertIsPrefix ("#13", false, "\u00e4_", "a");
910         }
911
912         [Test]
913         [Category ("NotDotNet")]
914         public void IsSuffix ()
915         {
916                 if (!doTest)
917                         Assert.Ignore ("Test is disabled.");
918
919                 AssertIsSuffix ("#1", true, "ABC", "c", CompareOptions.IgnoreCase);
920                 AssertIsSuffix ("#2", true, "BC", "c", CompareOptions.IgnoreCase);
921                 AssertIsSuffix ("#3", false, "CBA", "c", CompareOptions.IgnoreCase);
922                 AssertIsSuffix ("#4", true, "ABCDE", "\u0117", CompareOptions.IgnoreNonSpace | CompareOptions.IgnoreCase);
923                 AssertIsSuffix ("#5", false, "\u00E6", "a", CompareOptions.None);
924 // BUG in .NET 2.0 : see GetSortKey() test (mentioned above).
925                 AssertIsSuffix ("#6", true, "\u00E6", "ae", CompareOptions.None);
926                 AssertIsSuffix ("#7", true, "ae", "\u00E6", CompareOptions.None);
927                 AssertIsSuffix ("#8", false, "e", "\u00E6", CompareOptions.None);
928                 // U+3007 is completely ignored character.
929                 AssertIsSuffix ("#9", true, "\uff21\uff21", "\uff21", CompareOptions.None);
930 // BUG in .NET 2.0 : see \u3007 issue (mentioned above).
931                 AssertIsSuffix ("#10", true, "\uff21\uff21", "\u3007\uff21", CompareOptions.None);
932                 AssertIsSuffix ("#11", true, "\uff21\uff21", "\uff21\u3007", CompareOptions.None);
933                 // extender in target
934                 AssertIsSuffix ("#12", false, "\u30D1\u30A2", "\u30D1\u30FC");
935                 AssertIsSuffix ("#13", true, "\u30D1\u30A2", "\u30D1\u30FC", CompareOptions.IgnoreNonSpace);
936                 // extender in source
937                 AssertIsSuffix ("#14", false, "\u30D1\u30FC", "\u30D1\u30A2");
938                 AssertIsSuffix ("#15", true, "\u30D1\u30FC", "\u30D1\u30A2", CompareOptions.IgnoreNonSpace);
939                 // optimization sanity check
940                 AssertIsSuffix ("#16", true,
941                         "/configuration/system.runtime.remoting",
942                         "system.runtime.remoting");
943
944                 // empty suffix always matches the source.
945                 AssertIsSuffix ("#17", true, "", "");
946                 AssertIsSuffix ("#18", true, "/test.css", "");
947                 AssertIsSuffix ("#19", true, "/test.css", "/test.css");
948                 AssertIsSuffix ("#20", true, "\\b\\a a", "\\b\\a a");
949                 Assert.IsTrue (new CultureInfo ("en").CompareInfo.IsSuffix ("\\b\\a a", "\\b\\a a"), "#20en");
950                 Assert.IsTrue (new CultureInfo ("ja").CompareInfo.IsSuffix ("\\b\\a a", "\\b\\a a"), "#20ja");
951         }
952
953         [Test]
954         [Category ("NotDotNet")]
955         [Category ("NotWorking")]
956         public void IsSuffixMSBug ()
957         {
958                 if (!doTest)
959                         Assert.Ignore ("Test is disabled.");
960
961                 AssertIsSuffix ("#1", true, "\u00E6", "e", CompareOptions.None);
962         }
963
964         [Test]
965         public void IndexOfString ()
966         {
967                 if (!doTest)
968                         Assert.Ignore ("Test is disabled.");
969
970                 AssertIndexOf ("#0", 0, "", "", CompareOptions.None);
971                 AssertIndexOf ("#1", -1, "ABC", "1", CompareOptions.None);
972                 AssertIndexOf ("#2", 2, "ABCABC", "c", CompareOptions.IgnoreCase);
973                 AssertIndexOf ("#3", 1, "ABCABC", "\uFF22", CompareOptions.IgnoreCase | CompareOptions.IgnoreWidth);
974                 AssertIndexOf ("#4", 4, "ABCDE", "\u0117", CompareOptions.IgnoreNonSpace | CompareOptions.IgnoreCase);
975                 AssertIndexOf ("#5", 1, "ABCABC", "BC", CompareOptions.IgnoreCase);
976                 AssertIndexOf ("#6", 1, "BBCBBC", "BC", CompareOptions.IgnoreCase);
977                 AssertIndexOf ("#7", -1, "ABCDEF", "BCD", 0, 3, CompareOptions.IgnoreCase, invariant);
978                 AssertIndexOf ("#8", 0, "-ABC", "-", CompareOptions.None);
979                 AssertIndexOf ("#9", 0, "--ABC", "--", CompareOptions.None);
980                 AssertIndexOf ("#10", -1, "--ABC", "--", 1, 2, CompareOptions.None, invariant);
981
982                 // U+3007 is completely ignored character.
983                 AssertIndexOf ("#12", 0, "\uff21\uff21", "\uff21", CompareOptions.None);
984
985                 AssertIndexOf ("#14", 0, "\uff21\uff21", "\uff21\u3007", CompareOptions.None);
986                 AssertIndexOf ("#15", 0, "\uff21\uff21", "\u3007", CompareOptions.None);
987                 AssertIndexOf ("#15-2", 1, "\u3007\uff21", "\uff21", CompareOptions.None);
988                 // target is "empty" (in culture-sensitive context).
989                 AssertIndexOf ("#16", -1, String.Empty, "\u3007");
990
991                 AssertIndexOf ("#18", 0, "ABC", "\u3007");
992
993                 AssertIndexOf ("#19", 0, "\\b\\a a", "\\b\\a a");
994                 Assert.AreEqual (0, new CultureInfo ("en").CompareInfo.IndexOf ("\\b\\a a", "\\b\\a a"), "#19en");
995                 Assert.AreEqual (0, new CultureInfo ("ja").CompareInfo.IndexOf ("\\b\\a a", "\\b\\a a"), "#19ja");
996         }
997
998         [Test]
999         [Category ("NotDotNet")]
1000         public void IndexOfStringWeird ()
1001         {
1002 // BUG in .NET 2.0 : see GetSortKey() test (mentioned above).
1003                 AssertIndexOf ("#11", 0, "AE", "\u00C6", CompareOptions.None);
1004
1005 // BUG in .NET 2.0 : see \u3007 issue (mentioned above).
1006                 AssertIndexOf ("#13", 0, "\uff21\uff21", "\u3007\uff21", CompareOptions.None);
1007
1008 // BUG in .NET 2.0 : see \u3007 issue (mentioned above).
1009                 AssertIndexOf ("#17", 0, "A", "\u3007");
1010         }
1011         
1012         [Test]
1013         public void IndexOfSpecialWeight ()
1014         {
1015                 if (!doTest)
1016                         Assert.Ignore ("Test is disabled.");
1017
1018                 // Japanese (in invariant)
1019                 AssertIndexOf ("#1", -1, "\u30D1\u30FC\u30B9", "\uFF8A\uFF9F\uFF70\uFF7D");
1020                 // extender in target
1021                 AssertIndexOf ("#1-2", -1, "\u30D1\u30A2", "\u30D1\u30FC");
1022                 AssertIndexOf ("#1-3", 0, "\u30D1\u30A2", "\u30D1\u30FC", CompareOptions.IgnoreNonSpace);
1023                 // extender in source
1024                 AssertIndexOf ("#1-4", 0, "\u30D1\u30FC", "\u30D1\u30A2", CompareOptions.IgnoreNonSpace);
1025                 AssertIndexOf ("#1-5", 1, "\u30D1\u30FC", "\u30A2", CompareOptions.IgnoreNonSpace);
1026                 AssertIndexOf ("#2", 0, "\u30D1\u30FC\u30B9", "\uFF8A\uFF9F\uFF70\uFF7D", CompareOptions.IgnoreWidth);
1027                 AssertIndexOf ("#2-2", -1, "\u30D1\u30FC\u30B9", "\uFF8A\uFF9F\uFF70\uFF7D");
1028                 AssertIndexOf ("#3", 0, "\uFF80\uFF9E\uFF72\uFF8C\uFF9E", 
1029                         "\u30C0\u30A4\u30D6", CompareOptions.IgnoreWidth);
1030                 AssertIndexOf ("#4", -1, "\u3042\u309D", "\u3042\u3042");
1031                 AssertIndexOf ("#5", 0, "\u3042\u309D", "\u3042\u3042", CompareOptions.IgnoreNonSpace);
1032                 AssertIndexOf ("#6", 0, "\uFF8A\uFF9E\uFF70\uFF99",
1033                         "\u30D0\u30FC\u30EB", CompareOptions.IgnoreWidth);
1034
1035         }
1036
1037         [Test]
1038         public void LastIndexOfString ()
1039         {
1040                 if (!doTest)
1041                         Assert.Ignore ("Test is disabled.");
1042
1043                 AssertLastIndexOf ("#1", -1, "ABC", "1", CompareOptions.None);
1044                 AssertLastIndexOf ("#2", 5, "ABCABC", "c", CompareOptions.IgnoreCase);
1045                 AssertLastIndexOf ("#3", 4, "ABCABC", "\uFF22", CompareOptions.IgnoreCase | CompareOptions.IgnoreWidth);
1046                 AssertLastIndexOf ("#4", 4, "ABCDE", "\u0117", CompareOptions.IgnoreNonSpace | CompareOptions.IgnoreCase);
1047                 AssertLastIndexOf ("#5", 4, "ABCABC", "BC", CompareOptions.IgnoreCase);
1048                 AssertLastIndexOf ("#6", 4, "BBCBBC", "BC", CompareOptions.IgnoreCase);
1049                 AssertLastIndexOf ("#7", 1, "original", "rig", CompareOptions.None);
1050
1051                 AssertLastIndexOf ("#9", 0, "-ABC", "-", CompareOptions.None);
1052                 AssertLastIndexOf ("#10", 0, "--ABC", "--", CompareOptions.None);
1053                 AssertLastIndexOf ("#11", -1, "--ABC", "--", 2, 2, CompareOptions.None, invariant);
1054                 AssertLastIndexOf ("#12", -1, "--ABC", "--", 4, 2, CompareOptions.None, invariant);
1055
1056                 // U+3007 is completely ignored character.
1057                 AssertLastIndexOf ("#14", 1, "\uff21\uff21", "\uff21", CompareOptions.None);
1058
1059                 AssertLastIndexOf ("#16", 1, "\uff21\uff21", "\uff21\u3007", CompareOptions.None);
1060                 AssertLastIndexOf ("#17", 1, "\uff21\uff21", "\u3007", CompareOptions.None);
1061                 AssertLastIndexOf ("#18", 1, "\u3007\uff21", "\uff21", CompareOptions.None);
1062                 AssertLastIndexOf ("#19", 0, "\\b\\a a", "\\b\\a a");
1063                 Assert.AreEqual (0, new CultureInfo ("en").CompareInfo.LastIndexOf ("\\b\\a a", "\\b\\a a"), "#19en");
1064                 Assert.AreEqual (0, new CultureInfo ("ja").CompareInfo.LastIndexOf ("\\b\\a a", "\\b\\a a"), "#19ja");
1065                 // bug #80612
1066                 AssertLastIndexOf ("#20", 8, "/system/web", "w");
1067                 Assert.AreEqual (8, new CultureInfo ("sv").CompareInfo.LastIndexOf ("/system/web", "w"), "#20sv");
1068
1069                 AssertLastIndexOf ("#21", 2, "foo", String.Empty);
1070         }
1071
1072         [Test]
1073         [Category ("NotDotNet")]
1074         public void LastIndexOfStringDotnetWeird ()
1075         {
1076                 if (!doTest)
1077                         Assert.Ignore ("Test is disabled.");
1078
1079 // BUG in .NET 2.0 : see GetSortKey() test (mentioned above).
1080                 AssertLastIndexOf ("#8", 0, "\u00E6", "ae", CompareOptions.None);
1081
1082 // BUG in .NET 2.0 : see GetSortKey() test (mentioned above).
1083                 AssertLastIndexOf ("#13", 0, "AE", "\u00C6", CompareOptions.None);
1084
1085 // BUG in .NET 2.0 : see \u3007 issue (mentioned above).
1086                 AssertLastIndexOf ("#15", 1, "\uff21\uff21", "\u3007\uff21", CompareOptions.None);
1087         }
1088
1089         [Test]
1090         public void LastIndexOfSpecialWeight ()
1091         {
1092                 if (!doTest)
1093                         Assert.Ignore ("Test is disabled.");
1094
1095                 // Japanese (in invariant)
1096                 AssertLastIndexOf ("#1", -1, "\u30D1\u30FC\u30B9", "\uFF8A\uFF9F\uFF70\uFF7D");
1097                 // extender in target
1098                 AssertLastIndexOf ("#1-2", -1, "\u30D1\u30A2", "\u30D1\u30FC");
1099                 AssertLastIndexOf ("#1-3", 0, "\u30D1\u30A2", "\u30D1\u30FC", CompareOptions.IgnoreNonSpace);
1100                 // extender in source
1101                 AssertLastIndexOf ("#1-4", 0, "\u30D1\u30FC", "\u30D1\u30A2", CompareOptions.IgnoreNonSpace);
1102                 // FIXME: not working (extender support is not complete. 
1103                 // Currently private IsPrefix() cannot handle heading
1104                 // extenders to consume previous primary char.)
1105 //              AssertLastIndexOf ("#1-5", 1, "\u30D1\u30FC", "\u30A2", CompareOptions.IgnoreNonSpace);
1106                 // this shows that Windows accesses beyond the length and
1107                 // acquires the corresponding character to expand.
1108 //              AssertLastIndexOf ("#1-6", 1, "\u30D1\u30FC", "\u30A2", 1, 1, CompareOptions.IgnoreNonSpace, invariant);
1109                 AssertLastIndexOf ("#2", 0, "\u30D1\u30FC\u30B9", "\uFF8A\uFF9F\uFF70\uFF7D", CompareOptions.IgnoreWidth);
1110                 AssertLastIndexOf ("#3", 0, "\uFF80\uFF9E\uFF72\uFF8C\uFF9E", 
1111                         "\u30C0\u30A4\u30D6", CompareOptions.IgnoreWidth);
1112                 AssertLastIndexOf ("#4", -1, "\u3042\u309D", "\u3042\u3042");
1113                 AssertLastIndexOf ("#5", 0, "\u3042\u309D", "\u3042\u3042", CompareOptions.IgnoreNonSpace);
1114                 AssertLastIndexOf ("#6", 0, "\uFF8A\uFF9E\uFF70\uFF99",
1115                         "\u30D0\u30FC\u30EB", CompareOptions.IgnoreWidth);
1116         }
1117
1118         [Test]
1119         public void LastIndexOfOrdinalString ()
1120         {
1121                 if (!doTest)
1122                         Assert.Ignore ("Test is disabled.");
1123
1124                 AssertLastIndexOf ("#1", -1, "ABC", "1", CompareOptions.Ordinal);
1125                 AssertLastIndexOf ("#2", 5, "ABCABC", "C", CompareOptions.Ordinal);
1126                 AssertLastIndexOf ("#3", -1, "ABCABC", "\uFF22", CompareOptions.Ordinal);
1127                 AssertLastIndexOf ("#4", 4, "ABCABC", "BC", CompareOptions.Ordinal);
1128                 AssertLastIndexOf ("#5", 4, "BBCBBC", "BC", CompareOptions.Ordinal);
1129                 AssertLastIndexOf ("#6", 1, "original", "rig", CompareOptions.Ordinal);
1130                 AssertLastIndexOf ("#7", 0, "\\b\\a a", "\\b\\a a", CompareOptions.Ordinal);
1131         }
1132
1133         [Test]
1134         public void NullCharacter ()
1135         {
1136                 // for bug #76702
1137                 Assert.AreEqual (-1, "MONO".IndexOf ("\0\0\0"), "#1");
1138                 Assert.AreEqual (-1, "MONO".LastIndexOf ("\0\0\0"), "#2");
1139                 Assert.AreEqual (1, "MONO".CompareTo ("\0\0\0"), "#3");
1140
1141                 // I don't really understand why they are so...
1142                 AssertIndexOf ("#4", 0, "\0\0", "\0");
1143                 AssertIndexOf ("#5", -1, "\0", "\0\0");
1144                 AssertIndexOf ("#6", -1, "foo", "\0");
1145                 AssertLastIndexOf ("#7", 1, "\0\0", "\0");
1146                 AssertLastIndexOf ("#8", -1, "\0", "\0\0");
1147                 AssertLastIndexOf ("#9", -1, "foo", "\0");
1148         }
1149
1150         [Test]
1151         // LAMESPEC: MS.NET treats it as equivalent, while in IndexOf() it does not match.
1152         public void NullCharacterWeird ()
1153         {
1154                 Assert.AreEqual (0, "MONO".CompareTo ("MONO\0\0\0"), "#4");
1155         }
1156
1157         [Test]
1158         [Category ("NotDotNet")]
1159         public void OrdinalIgnoreCaseCompare ()
1160         {
1161                 if (!doTest)
1162                         Assert.Ignore ("Test is disabled.");
1163
1164                 // matches
1165 // BUG in .NET 2.0 : see GetSortKey() test (mentioned above).
1166                 AssertCompare ("#1", 0, "AE", "\u00C6", CompareOptions.None);
1167 // BUG in .NET 2.0 : It raises inappropriate ArgumentException.
1168                 // should not match since it is Ordinal
1169                 AssertCompare ("#2", -133, "AE", "\u00C6", CompareOptions.OrdinalIgnoreCase);
1170
1171                 AssertCompare ("#3", 1, "AE", "\u00E6", CompareOptions.None);
1172                 // matches
1173                 AssertCompare ("#4", 0, "AE", "\u00E6", CompareOptions.IgnoreCase);
1174                 // should not match since it is Ordinal
1175                 AssertCompare ("#5", -133, "AE", "\u00E6", CompareOptions.OrdinalIgnoreCase);
1176
1177                 AssertCompare ("#6", 0, "AE", "ae", CompareOptions.OrdinalIgnoreCase);
1178                 AssertCompare ("#7", 0, "aE", "ae", CompareOptions.OrdinalIgnoreCase);
1179                 AssertCompare ("#8", 0, "aE", "ae", CompareOptions.OrdinalIgnoreCase);
1180                 AssertCompare ("#9", 0, "ae", "ae", CompareOptions.OrdinalIgnoreCase);
1181                 AssertCompare ("#10", 0, "AE", "AE", CompareOptions.OrdinalIgnoreCase);
1182                 AssertCompare ("#11", 0, "aE", "AE", CompareOptions.OrdinalIgnoreCase);
1183                 AssertCompare ("#12", 0, "aE", "AE", CompareOptions.OrdinalIgnoreCase);
1184                 AssertCompare ("#13", 0, "ae", "AE", CompareOptions.OrdinalIgnoreCase);
1185                 AssertCompare ("#14", 0, "ola", "OLA", CompareOptions.OrdinalIgnoreCase);
1186                 // check ignorable characters
1187                 AssertCompare ("#15", 0, "AE\uFFFC", "AE", CompareOptions.None);
1188                 AssertCompare ("#16", 1, "AE\uFFFC", "AE", CompareOptions.OrdinalIgnoreCase);
1189         }
1190
1191         [Test]
1192         public void OrdinalIgnoreCaseIndexOf ()
1193         {
1194                 AssertIndexOf ("#1-1", 0, "ABC", "abc", CompareOptions.OrdinalIgnoreCase);
1195                 AssertIndexOf ("#1-2", -1, "AEBECE", "\u00E6", CompareOptions.OrdinalIgnoreCase);
1196                 AssertIndexOf ("#1-3", -1, "@_@", "`_`", CompareOptions.OrdinalIgnoreCase);
1197         }
1198
1199         [Test]
1200         public void OrdinalIgnoreCaseIndexOfChar ()
1201         {
1202                 AssertIndexOf ("#2-1", 0, "ABC", 'a', CompareOptions.OrdinalIgnoreCase);
1203                 AssertIndexOf ("#2-2", -1, "AEBECE", '\u00C0', CompareOptions.OrdinalIgnoreCase);
1204                 AssertIndexOf ("#2-3", -1, "@_@", '`', CompareOptions.OrdinalIgnoreCase);
1205         }
1206
1207         [Test]
1208         public void OrdinalIgnoreCaseLastIndexOf ()
1209         {
1210                 AssertLastIndexOf ("#1-1", 0, "ABC", "abc", CompareOptions.OrdinalIgnoreCase);
1211                 AssertLastIndexOf ("#1-2", -1, "AEBECE", "\u00E6", CompareOptions.OrdinalIgnoreCase);
1212                 AssertLastIndexOf ("#1-3", -1, "@_@", "`_`", CompareOptions.OrdinalIgnoreCase);
1213                 AssertLastIndexOf ("#1-4", 1, "ABCDE", "bc", CompareOptions.OrdinalIgnoreCase);
1214                 AssertLastIndexOf ("#1-5", -1, "BBBBB", "ab", CompareOptions.OrdinalIgnoreCase);
1215         }
1216
1217         [Test]
1218         public void OrdinalIgnoreCaseLastIndexOfChar ()
1219         {
1220                 AssertLastIndexOf ("#2-1", 0, "ABC", 'a', CompareOptions.OrdinalIgnoreCase);
1221                 AssertLastIndexOf ("#2-2", -1, "AEBECE", '\u00C0', CompareOptions.OrdinalIgnoreCase);
1222                 AssertLastIndexOf ("#2-3", -1, "@_@", '`', CompareOptions.OrdinalIgnoreCase);
1223         }
1224
1225         [Test] // bug #80865
1226         public void IsPrefixOrdinalIgnoreCase ()
1227         {
1228                 Assert.IsTrue ("aaaa".StartsWith ("A", StringComparison.OrdinalIgnoreCase));
1229         }
1230
1231         [Test]
1232         [ExpectedException (typeof (ArgumentNullException))]
1233         public void IsPrefix_SourceNull ()
1234         {
1235                 invariant.IsPrefix (null, "b");
1236         }
1237
1238         [Test]
1239         [ExpectedException (typeof (ArgumentNullException))]
1240         public void IsPrefix_PrefixNull ()
1241         {
1242                 invariant.IsPrefix ("a", null, CompareOptions.None);
1243         }
1244
1245         [Test]
1246         public void IsPrefix_PrefixEmpty ()
1247         {
1248                 Assert.IsTrue (invariant.IsPrefix ("a", String.Empty));
1249         }
1250
1251         [Test]
1252         [ExpectedException (typeof (ArgumentException))]
1253         public void IsPrefix_CompareOptions_Invalid ()
1254         {
1255                 invariant.IsPrefix ("a", "b", (CompareOptions) Int32.MinValue);
1256         }
1257
1258         [Test]
1259         [ExpectedException (typeof (ArgumentException))]
1260         public void IsPrefix_CompareOptions_StringSort ()
1261         {
1262                 invariant.IsPrefix ("a", "b", CompareOptions.StringSort);
1263         }
1264
1265         [Test]
1266         [ExpectedException (typeof (ArgumentNullException))]
1267         public void IsSuffix_SourceNull ()
1268         {
1269                 invariant.IsSuffix (null, "b");
1270         }
1271
1272         [Test]
1273         [ExpectedException (typeof (ArgumentNullException))]
1274         public void IsSuffix_SuffixNull ()
1275         {
1276                 invariant.IsSuffix ("a", null, CompareOptions.None);
1277         }
1278
1279         [Test]
1280         public void IsSuffix_PrefixEmpty ()
1281         {
1282                 Assert.IsTrue (invariant.IsSuffix ("a", String.Empty));
1283         }
1284
1285         [Test]
1286         [ExpectedException (typeof (ArgumentException))]
1287         public void IsSuffix_CompareOptions_Invalid ()
1288         {
1289                 invariant.IsSuffix ("a", "b", (CompareOptions) Int32.MinValue);
1290         }
1291
1292         [Test]
1293         [ExpectedException (typeof (ArgumentException))]
1294         public void IsSuffix_CompareOptions_StringSort ()
1295         {
1296                 invariant.IsSuffix ("a", "b", CompareOptions.StringSort);
1297         }
1298
1299         [Test]
1300         [ExpectedException (typeof (ArgumentException))]
1301         public void Compare_String_String_CompareOptions_Invalid ()
1302         {
1303                 // validation of CompareOptions is made before null checks
1304                 invariant.Compare (null, null, (CompareOptions) Int32.MinValue);
1305         }
1306
1307         [Test]
1308         public void Compare_String_String_CompareOptions_StringSort ()
1309         {
1310                 // StringSort is valid for Compare only
1311                 Assert.AreEqual (-1, invariant.Compare ("a", "b", CompareOptions.StringSort));
1312         }
1313
1314         [Test]
1315         [ExpectedException (typeof (ArgumentException))]
1316         public void Compare_String_Int_String_Int_CompareOptions_Invalid ()
1317         {
1318                 invariant.Compare (null, 0, null, 0, (CompareOptions) Int32.MinValue);
1319         }
1320
1321         [Test]
1322         [ExpectedException (typeof (ArgumentException))]
1323         public void Compare_String_Int_Int_String_Int_Int_CompareOptions_Invalid ()
1324         {
1325                 invariant.Compare (null, 0, 0, null, 0, 0, (CompareOptions) Int32.MinValue);
1326         }
1327
1328         [Test]
1329         [ExpectedException (typeof (ArgumentException))]
1330         public void IndexOf_String_Char_Int_Int_CompareOptions_Invalid ()
1331         {
1332                 invariant.IndexOf ("a", 'a', 0, 1, (CompareOptions) Int32.MinValue);
1333         }
1334
1335         [Test]
1336         [ExpectedException (typeof (ArgumentException))]
1337         public void IndexOf_String_Char_Int_Int_CompareOptions_StringSort ()
1338         {
1339                 invariant.IndexOf ("a", 'a', 0, 1, CompareOptions.StringSort);
1340         }
1341
1342         [Test]
1343         [ExpectedException (typeof (ArgumentException))]
1344         public void IndexOf_String_String_Int_Int_CompareOptions_Invalid ()
1345         {
1346                 invariant.IndexOf ("a", "a", 0, 1, (CompareOptions) Int32.MinValue);
1347         }
1348
1349         [Test]
1350         [ExpectedException (typeof (ArgumentException))]
1351         public void IndexOf_String_String_Int_Int_CompareOptions_StringSort ()
1352         {
1353                 invariant.IndexOf ("a", "a", 0, 1, CompareOptions.StringSort);
1354         }
1355
1356         [Test]
1357         [ExpectedException (typeof (ArgumentException))]
1358         public void LastIndexOf_String_Char_Int_Int_CompareOptions_Invalid ()
1359         {
1360                 invariant.LastIndexOf ("a", 'a', 0, 1, (CompareOptions) Int32.MinValue);
1361         }
1362
1363         [Test]
1364         [ExpectedException (typeof (ArgumentException))]
1365         public void LastIndexOf_String_Char_Int_Int_CompareOptions_StringSort ()
1366         {
1367                 invariant.LastIndexOf ("a", 'a', 0, 1, CompareOptions.StringSort);
1368         }
1369
1370         [Test]
1371         [ExpectedException (typeof (ArgumentException))]
1372         public void LastIndexOf_String_String_Int_Int_CompareOptions_Invalid ()
1373         {
1374                 invariant.LastIndexOf ("a", "a", 0, 1, (CompareOptions) Int32.MinValue);
1375         }
1376
1377         [Test]
1378         [ExpectedException (typeof (ArgumentException))]
1379         public void LastIndexOf_String_String_Int_Int_CompareOptions_StringSort ()
1380         {
1381                 invariant.LastIndexOf ("a", "a", 0, 1, CompareOptions.StringSort);
1382         }
1383 }
1384
1385 }
1386