remove TARGET_JVM
[mono.git] / mcs / class / corlib / Test / System.Text / EncodingInfoTest.cs
1 //
2 // EncodingInfoTest.cs
3 //
4 // Author:
5 //      Atsushi Enomoto  <atsushi@ximian.com>
6 //
7 // (C) 2006 Novell, Inc.
8 // 
9
10 #if NET_2_0
11
12 using NUnit.Framework;
13 using System;
14 using System.Collections.Generic;
15 using System.IO;
16 using System.Reflection;
17 using System.Text;
18
19 namespace MonoTests.System.Text
20 {
21         [TestFixture]
22         public class EncodingInfoTest
23         {
24                 [Test]
25 #if TARGET_JVM
26                 [Category("NotWorking")]
27 #endif
28                 // The purpose of this test is to make sure that
29                 // new encodings added to I18N are also listed in the
30                 // returned array from Encoding.GetEncodings() so that
31                 // we can make sure to put additional encodings into
32                 // Encoding.GetEncodings() code.
33                 public void EncodingGetEncodingsReturnsAll ()
34                 {
35                         // Make sure that those I18N assemblies are loaded.
36                         string basePath = Assembly.GetAssembly (typeof (int)).CodeBase;
37                         basePath = basePath.Substring (0, basePath.LastIndexOf ('/'));
38                         Assert.IsNotNull (Assembly.LoadFrom (basePath + "/I18N.West.dll"), "West");
39                         Assert.IsNotNull (Assembly.LoadFrom (basePath + "/I18N.CJK.dll"), "CJK");
40                         Assert.IsNotNull (Assembly.LoadFrom (basePath + "/I18N.MidEast.dll"), "MidEast");
41                         Assert.IsNotNull (Assembly.LoadFrom (basePath + "/I18N.Rare.dll"), "Rare");
42                         Assert.IsNotNull (Assembly.LoadFrom (basePath + "/I18N.Other.dll"), "Other");
43
44                         List<int> list = new List<int> ();
45                         for (int i = 1; i < 0x10000; i++) {
46                                 try {
47                                         Encoding.GetEncoding (i);
48                                         list.Add (i);
49                                 } catch {
50                                 }
51                         }
52                         int [] reference = list.ToArray ();
53
54                         EncodingInfo [] infos = Encoding.GetEncodings ();
55                         int [] actual = new int [infos.Length];
56
57                         for (int i = 0; i < infos.Length; i++)
58                                 actual [i] = infos [i].CodePage;
59
60                         Assert.AreEqual (reference, actual);
61                 }
62
63                 [Test]
64                 public void GetEncodingForAllInfo ()
65                 {
66                         foreach (EncodingInfo i in Encoding.GetEncodings ())
67                                 Assert.IsNotNull (i.GetEncoding (), "codepage " + i);
68                 }
69         }
70 }
71
72 #endif