Author: lluis
Date: 2005-03-23 14:13:44 -0500 (Wed, 23 Mar 2005)
New Revision: 42163
Added:
trunk/mcs/class/corlib/Test/System.Runtime.Serialization/ArraySerializationTest.cs
Modified:
trunk/mcs/class/corlib/Test/System.Runtime.Serialization/ChangeLog
Log:
2005-03-23 Lluis Sanchez Gual <[EMAIL PROTECTED]>
* ArraySerializationTest.cs: New serialization tests.
Added:
trunk/mcs/class/corlib/Test/System.Runtime.Serialization/ArraySerializationTest.cs
===================================================================
---
trunk/mcs/class/corlib/Test/System.Runtime.Serialization/ArraySerializationTest.cs
2005-03-23 19:11:05 UTC (rev 42162)
+++
trunk/mcs/class/corlib/Test/System.Runtime.Serialization/ArraySerializationTest.cs
2005-03-23 19:13:44 UTC (rev 42163)
@@ -0,0 +1,197 @@
+// ArraySerializationTest.cs
+//
+// Author:
+// Lluis Sanchez Gual ([EMAIL PROTECTED])
+//
+// (C) 2005 Lluis Sanchez Gual
+
+//
+// Copyright (C) 2005 Novell, Inc (http://www.novell.com)
+//
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+//
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+//
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+//
+
+
+using System;
+using System.IO;
+using System.Runtime.Serialization;
+using System.Runtime.Serialization.Formatters.Binary;
+using System.Reflection;
+using System.Collections;
+using NUnit.Framework;
+
+namespace MonoTests.System.Runtime.Serialization
+{
+ [TestFixture]
+ public class ArraySerializationTest
+ {
+ [Test]
+ public void TestBoolArray ()
+ {
+ bool[] array = new bool[2000];
+ for (int n=0; n<2000; n++)
+ array [n] = (n % 3) == 0;
+ CheckArray (array);
+ }
+
+ [Test]
+ public void TestByteArray ()
+ {
+ byte[] array = new byte[10000];
+ for (int n=0; n<10000; n++)
+ array [n] = (byte) (n % 253);
+ CheckArray (array);
+ }
+
+ [Test]
+ public void TestCharArray ()
+ {
+ char[] array = new char[2000];
+ for (int n=0; n<2000; n++)
+ array [n] = (char) n;
+ CheckArray (array);
+ }
+
+ [Test]
+ public void TestDateTimeArray ()
+ {
+ DateTime[] array = new DateTime[10000];
+ for (int n=0; n<10000; n++)
+ array [n] = new DateTime (n);
+ CheckArray (array);
+ }
+
+ [Test]
+ public void TestDecimalArray ()
+ {
+ decimal[] array = new decimal[2000];
+ for (int n=0; n<2000; n++)
+ array [n] = decimal.MaxValue / (decimal) (n+1);
+ CheckArray (array);
+ }
+
+ [Test]
+ public void TestDoubleArray ()
+ {
+ double[] array = new double[10000];
+ for (int n=0; n<10000; n++)
+ array [n] = (double) n;
+ CheckArray (array);
+ }
+
+ [Test]
+ public void TestShortArray ()
+ {
+ short[] array = new short[10000];
+ for (int n=0; n<10000; n++)
+ array [n] = (short) n;
+ CheckArray (array);
+ }
+
+ [Test]
+ public void TestIntArray ()
+ {
+ int[] array = new int[10000];
+ for (int n=0; n<10000; n++)
+ array [n] = n;
+ CheckArray (array);
+ }
+
+ [Test]
+ public void TestLongArray ()
+ {
+ long[] array = new long[10000];
+ for (int n=0; n<10000; n++)
+ array [n] = n;
+ CheckArray (array);
+ }
+
+ [Test]
+ public void TestSByteArray ()
+ {
+ sbyte[] array = new sbyte[10000];
+ for (int n=0; n<10000; n++)
+ array [n] = (sbyte) (n % 121);
+ CheckArray (array);
+ }
+
+ [Test]
+ public void TestFloatArray ()
+ {
+ float[] array = new float[10000];
+ for (int n=0; n<10000; n++)
+ array [n] = (float) n;
+ CheckArray (array);
+ }
+
+ [Test]
+ public void TestUShortArray ()
+ {
+ ushort[] array = new ushort[10000];
+ for (int n=0; n<10000; n++)
+ array [n] = (ushort) n;
+ CheckArray (array);
+ }
+
+ [Test]
+ public void TestUIntArray ()
+ {
+ uint[] array = new uint[10000];
+ for (int n=0; n<10000; n++)
+ array [n] = (uint) n;
+ CheckArray (array);
+ }
+
+ [Test]
+ public void TestULongArray ()
+ {
+ ulong[] array = new ulong[10000];
+ for (int n=0; n<10000; n++)
+ array [n] = (ulong) n;
+ CheckArray (array);
+ }
+
+ [Test]
+ public void TestStringArray ()
+ {
+ string[] array = new string[10000];
+ for (int n=0; n<10000; n++)
+ array [n] = n.ToString ();
+ CheckArray (array);
+ }
+
+ void CheckArray (Array src)
+ {
+ MemoryStream ms = new MemoryStream ();
+ BinaryFormatter bf = new BinaryFormatter ();
+ bf.Serialize (ms, src);
+ ms.Position = 0;
+ Array des = (Array) bf.Deserialize (ms);
+ CompareArrays (src.GetType().ToString(), src, des);
+ }
+
+ void CompareArrays (string txt, Array a1, Array a2)
+ {
+ Assertion.AssertEquals (txt + " length", a1.Length,
a2.Length);
+ for (int n=0; n<a1.Length; n++)
+ Assertion.AssertEquals (txt + " [" + n + "]",
a1.GetValue (n), a2.GetValue (n));
+ }
+ }
+}
Modified: trunk/mcs/class/corlib/Test/System.Runtime.Serialization/ChangeLog
===================================================================
--- trunk/mcs/class/corlib/Test/System.Runtime.Serialization/ChangeLog
2005-03-23 19:11:05 UTC (rev 42162)
+++ trunk/mcs/class/corlib/Test/System.Runtime.Serialization/ChangeLog
2005-03-23 19:13:44 UTC (rev 42163)
@@ -1,3 +1,7 @@
+2005-03-23 Lluis Sanchez Gual <[EMAIL PROTECTED]>
+
+ * ArraySerializationTest.cs: New serialization tests.
+
2005-03-04 Lluis Sanchez Gual <[EMAIL PROTECTED]>
* SerializationTest.cs: Improved test.
_______________________________________________
Mono-patches maillist - [email protected]
http://lists.ximian.com/mailman/listinfo/mono-patches