X-Git-Url: http://wien.tomnetworks.com/gitweb/?a=blobdiff_plain;f=mcs%2Fclass%2Fcorlib%2FTest%2FSystem.Collections.Generic%2FListTest.cs;fp=mcs%2Fclass%2Fcorlib%2FTest%2FSystem.Collections.Generic%2FListTest.cs;h=a6951d9fe6ccb24f640e32c37a3d7ee92dff03ea;hb=30c28c41d7859b7de6ecd7afb652468517048d12;hp=8004600953fd79eff1ceb8991600e3e32d06ad94;hpb=d3d3ae6b0132d8840a5be0b36afcf4240868eabb;p=mono.git diff --git a/mcs/class/corlib/Test/System.Collections.Generic/ListTest.cs b/mcs/class/corlib/Test/System.Collections.Generic/ListTest.cs index 8004600953f..a6951d9fe6c 100644 --- a/mcs/class/corlib/Test/System.Collections.Generic/ListTest.cs +++ b/mcs/class/corlib/Test/System.Collections.Generic/ListTest.cs @@ -141,6 +141,27 @@ namespace MonoTests.System.Collections.Generic { newRange.InsertRange (newRange.Count, li); Assert.AreEqual (2, newRange.Count); } + + [Test] + public void InsertSelfTest() + { + List range = new List (5); + for (int i = 0; i < 5; ++ i) + range.Add (i); + + range.InsertRange(2, range); + Assert.AreEqual (10, range.Count); + Assert.AreEqual (0, range [0]); + Assert.AreEqual (1, range [1]); + Assert.AreEqual (0, range [2]); + Assert.AreEqual (1, range [3]); + Assert.AreEqual (2, range [4]); + Assert.AreEqual (3, range [5]); + Assert.AreEqual (4, range [6]); + Assert.AreEqual (2, range [7]); + Assert.AreEqual (3, range [8]); + Assert.AreEqual (4, range [9]); + } [Test, ExpectedException (typeof (ArgumentNullException))] public void InsertRangeNullTest () @@ -165,6 +186,29 @@ namespace MonoTests.System.Collections.Generic { Assert.AreEqual (1, l.IndexOf (200), "Could not find value"); } + + [Test, ExpectedException(typeof (ArgumentException))] + public void IList_InsertInvalidType () + { + IList list = _list1 as IList; + list.Insert(0, new object()); + } + + [Test, ExpectedException(typeof (ArgumentException))] + public void IList_AddInvalidType() + { + IList list = _list1 as IList; + list.Add(new object()); + } + + [Test] + public void IList_RemoveInvalidType() + { + IList list = _list1 as IList; + int nCount = list.Count; + list.Remove(new object()); + Assert.AreEqual(nCount, list.Count); + } [Test, ExpectedException (typeof (ArgumentOutOfRangeException))] public void IndexOfOutOfRangeTest () @@ -277,6 +321,7 @@ namespace MonoTests.System.Collections.Generic { } [Test] + [Category ("TargetJvmNotWorking")] public void SerializeTest () { List list = new List (); @@ -284,7 +329,11 @@ namespace MonoTests.System.Collections.Generic { list.Add (0); list.Add (7); +#if TARGET_JVM + BinaryFormatter bf = (BinaryFormatter)vmw.@internal.remoting.BinaryFormatterUtils.CreateBinaryFormatter (false); +#else BinaryFormatter bf = new BinaryFormatter (); +#endif // TARGET_JVM MemoryStream ms = new MemoryStream (); bf.Serialize (ms, list); @@ -296,13 +345,18 @@ namespace MonoTests.System.Collections.Generic { } [Test] + [Category ("TargetJvmNotWorking")] public void DeserializeTest () { MemoryStream ms = new MemoryStream (); ms.Write (_serializedList, 0, _serializedList.Length); ms.Position = 0; +#if TARGET_JVM + BinaryFormatter bf = (BinaryFormatter)vmw.@internal.remoting.BinaryFormatterUtils.CreateBinaryFormatter (false); +#else BinaryFormatter bf = new BinaryFormatter (); +#endif // TARGET_JVM List list = (List) bf.Deserialize (ms); Assert.AreEqual (3, list.Count, "#1"); Assert.AreEqual (5, list [0], "#2"); @@ -1031,6 +1085,22 @@ namespace MonoTests.System.Collections.Generic { l.Sort (); // two element -> sort -> exception! } + + [Test] + void IList_Contains_InvalidType() + { + List list = new List(); + list.Add("foo"); + Assert.IsFalse (((IList)list).Contains(new object())); + } + + [Test] + void IList_IndexOf_InvalidType() + { + List list = new List(); + list.Add("foo"); + Assert.AreEqual (-1, ((IList)list).IndexOf(new object())); + } // for bug #77277 test case [Test] @@ -1051,6 +1121,22 @@ namespace MonoTests.System.Collections.Generic { Assert.AreEqual (2, list.LastIndexOf (item0), "#4"); Assert.AreEqual (2, list.LastIndexOf (new EquatableClass (0)), "#5"); } + + [Test] + [ExpectedException (typeof (ArgumentOutOfRangeException))] + public void SetItem_OutOfRange() + { + List list = new List(); + list[0] = "foo"; + } + + [Test] + [ExpectedException (typeof (ArgumentOutOfRangeException))] + public void SetItem_IList_OutOfRange() + { + IList list = new List(); + list[0] = "foo"; + } public class EquatableClass : IEquatable {