Merge pull request #948 from ermshiperete/bug-xamarin-2394
[mono.git] / mcs / class / corlib / Mono.Globalization.Unicode / StringNormalizationTestSource.cs
1 using System;
2 using System.Globalization;
3 using System.Collections;
4 using System.Text;
5
6 using Mono.Globalization.Unicode;
7
8 namespace MonoTests.System
9 {
10         public class StringNormalizationTest
11         {
12                 ArrayList tests = new ArrayList ();
13
14                 class Testcase
15                 {
16                         public Testcase (string src, string nfc, string nfd, string nfkc, string nfkd, int testType)
17                         {
18                                 this.Source = src;
19                                 NFC = nfc;
20                                 NFD = nfd;
21                                 NFKC = nfkc;
22                                 NFKD = nfkd;
23                                 TestType = testType;
24                         }
25
26                         public string Source;
27                         public string NFC;
28                         public string NFD;
29                         public string NFKC;
30                         public string NFKD;
31                         public int TestType;
32                 }
33
34 #if TEST_STANDALONE
35                 public static void Main ()
36                 {
37                         new StringNormalizationTest ().Run ();
38                 }
39 #endif
40
41                 public StringNormalizationTest ()
42                 {
43                         Fill ();
44                 }
45
46                 void Run ()
47                 {
48                         foreach (Testcase tc in tests) {
49                                 TestString (tc, tc.NFD, NormalizationForm.FormD);
50                                 TestString (tc, tc.NFKD, NormalizationForm.FormKD);
51                                 TestString (tc, tc.NFC, NormalizationForm.FormC);
52                                 TestString (tc, tc.NFKC, NormalizationForm.FormKC);
53                         }
54                 }
55
56                 void TestString (Testcase tc, string expected, NormalizationForm f)
57                 {
58                         string input = tc.Source;
59                         string actual = null;
60                         switch (f) {
61                         default:
62                                 actual = Normalization.Normalize (input, 0); break;
63                         case NormalizationForm.FormD:
64                                 actual = Normalization.Normalize (input, 1); break;
65                         case NormalizationForm.FormKC:
66                                 actual = Normalization.Normalize (input, 2); break;
67                         case NormalizationForm.FormKD:
68                                 actual = Normalization.Normalize (input, 3); break;
69                         }
70
71                         if (actual != expected)
72                                 Console.WriteLine ("Error: expected {0} but was {1} (for {2},type{3} form {4})",
73                                 expected, actual, tc.Source, tc.TestType, f);
74                 }
75
76                 public void Fill ()
77                 {
78 @@@@@@ Replace Here @@@@@@
79                 }
80         }
81 }