X-Git-Url: http://wien.tomnetworks.com/gitweb/?a=blobdiff_plain;f=mcs%2Fclass%2Fcorlib%2FTest%2FSystem%2FArrayTest.cs;h=36db33d6352b9ac3efc47122a7897ed4289ea21d;hb=410bb8a57e23a901ea47d8a74f88a20972de423d;hp=351d312c92d63c5d217d3f9df04524402671680b;hpb=ac432e4ba2f187bf6606a2a07bb87607306647b4;p=mono.git diff --git a/mcs/class/corlib/Test/System/ArrayTest.cs b/mcs/class/corlib/Test/System/ArrayTest.cs index 351d312c92d..36db33d6352 100644 --- a/mcs/class/corlib/Test/System/ArrayTest.cs +++ b/mcs/class/corlib/Test/System/ArrayTest.cs @@ -779,6 +779,14 @@ public class ArrayTest Array.CreateInstance (typeof (Int32), (long[])null); } + [Test] + public void CreateInstanceVoid () + { + Assert.Throws (delegate () { + Array.CreateInstance (typeof (void), 1); + }); + } + [Test] public void TestGetEnumerator() { String[] s1 = {"this", "is", "a", "test"}; @@ -995,7 +1003,6 @@ public class ArrayTest int[] myBoundArray = new int[1] { Int32.MinValue }; Array myExtremeArray=Array.CreateInstance ( typeof(String), myLengthArray, myBoundArray ); Assert.AreEqual (Int32.MaxValue, ((IList)myExtremeArray).IndexOf (42), "AD04"); - } [Test] @@ -2575,6 +2582,26 @@ public class ArrayTest } } + [Test] + public void TestSortComparableMixed() + { + var m = new TestSortComparableMixed_Comparer (); + var arr = new object [] { 1, 2, m, 4, 5, 6, 7, 8, 9, 10 }; + + Array.Sort (arr); + + var expected = new object [] { m, 1, 2, 4, 5, 6, 7, 8, 9, 10 }; + Assert.AreEqual (expected, arr); + } + + class TestSortComparableMixed_Comparer : IComparable + { + public int CompareTo (object other) + { + return -1; + } + } + [Test] public void TestInitializeEmpty() { @@ -3358,6 +3385,30 @@ public class ArrayTest } } + [Test] + public void IEnumerator_Dispose () + { + IEnumerable e = new int[] { 1 }; + var en = e.GetEnumerator (); + Assert.IsTrue (en.MoveNext (), "#1"); + Assert.IsFalse (en.MoveNext (), "#2"); + en.Dispose (); + Assert.IsFalse (en.MoveNext (), "#3"); + } + + [Test] + public void IEnumerator_ZeroSize () + { + IEnumerable e = Array.Empty (); + var en = e.GetEnumerator (); + Assert.IsFalse (en.MoveNext (), "#1"); + + e = Array.Empty (); + en = e.GetEnumerator (); + Assert.IsFalse (en.MoveNext (), "#2"); + } + + [Test] public void ICollection_IsReadOnly() { ICollection arr = new string [10]; @@ -3642,6 +3693,20 @@ public class ArrayTest Assert.AreEqual (3, c.Counter); } + [Test] + public void EnumeratorsEquality () + { + int [] normalBase = new int [0]; + IEnumerable specialBase = new int [0]; + + var firstSpecial = specialBase.GetEnumerator (); + var secondSpecial = specialBase.GetEnumerator (); + var firstNormal = normalBase.GetEnumerator (); + var secondNormal = normalBase.GetEnumerator (); + + Assert.IsFalse (object.ReferenceEquals (firstNormal, secondNormal)); + Assert.IsTrue (object.ReferenceEquals (firstSpecial, secondSpecial)); + } [Test] public void JaggedArrayCtor () @@ -3660,5 +3725,17 @@ public class ArrayTest Assert.AreEqual (10, ((object[])arr [i]).Length); } } + + [Test] + public unsafe void PointerArraysBoxing () + { + var x = new int*[10]; + var e = x.GetEnumerator (); + e.MoveNext (); + + Assert.Throws (() => { var _ = e.Current; }, "#1"); + Assert.Throws (() => { var _ = x.GetValue (0); }, "#2"); + Assert.Throws (() => { x.SetValue (0, 0); }, "#3"); + } } }