Mark tests as not working under 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                 // The purpose of this test is to make sure that
26                 // new encodings added to I18N are also listed in the
27                 // returned array from Encoding.GetEncodings() so that
28                 // we can make sure to put additional encodings into
29                 // Encoding.GetEncodings() code.
30                 public void EncodingGetEncodingsReturnsAll ()
31                 {
32                         // Make sure that those I18N assemblies are loaded.
33                         string basePath = Assembly.GetAssembly (typeof (int)).CodeBase;
34                         basePath = basePath.Substring (0, basePath.LastIndexOf ('/'));
35                         Assert.IsNotNull (Assembly.LoadFrom (basePath + "/I18N.West.dll"), "West");
36                         Assert.IsNotNull (Assembly.LoadFrom (basePath + "/I18N.CJK.dll"), "CJK");
37                         Assert.IsNotNull (Assembly.LoadFrom (basePath + "/I18N.MidEast.dll"), "MidEast");
38                         Assert.IsNotNull (Assembly.LoadFrom (basePath + "/I18N.Rare.dll"), "Rare");
39                         Assert.IsNotNull (Assembly.LoadFrom (basePath + "/I18N.Other.dll"), "Other");
40
41                         List<int> list = new List<int> ();
42                         for (int i = 1; i < 0x10000; i++) {
43                                 try {
44                                         Encoding.GetEncoding (i);
45                                         list.Add (i);
46                                 } catch {
47                                 }
48                         }
49                         int [] reference = list.ToArray ();
50
51                         EncodingInfo [] infos = Encoding.GetEncodings ();
52                         int [] actual = new int [infos.Length];
53
54                         for (int i = 0; i < infos.Length; i++)
55                                 actual [i] = infos [i].CodePage;
56
57                         Assert.AreEqual (reference, actual);
58                 }
59
60                 [Test]
61                 public void GetEncodingForAllInfo ()
62                 {
63                         foreach (EncodingInfo i in Encoding.GetEncodings ())
64                                 Assert.IsNotNull (i.GetEncoding (), "codepage " + i);
65                 }
66         }
67 }
68
69 #endif