Mark tests as not working under TARGET_JVM
[mono.git] / mcs / class / corlib / Test / System.Collections.Generic / ListTest.cs
index 8004600953fd79eff1ceb8991600e3e32d06ad94..a6951d9fe6ccb24f640e32c37a3d7ee92dff03ea 100644 (file)
@@ -141,6 +141,27 @@ namespace MonoTests.System.Collections.Generic {
                        newRange.InsertRange (newRange.Count, li);
                        Assert.AreEqual (2, newRange.Count);
                }
+               
+               [Test]
+               public void InsertSelfTest()
+               {
+                       List <int> range = new List <int> (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 <int> list = new List <int> ();
@@ -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<int> list = (List<int>) 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<string> list = new List<string>();
+                       list.Add("foo");
+                       Assert.IsFalse (((IList)list).Contains(new object()));
+               }
+               
+               [Test]
+               void IList_IndexOf_InvalidType()
+               {
+                       List<string> list = new List<string>();
+                       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<string> list = new List<string>();
+                       list[0] = "foo";
+               }
+               
+               [Test]
+               [ExpectedException (typeof (ArgumentOutOfRangeException))]
+               public void SetItem_IList_OutOfRange()
+               {
+                       IList<string> list = new List<string>();
+                       list[0] = "foo";
+               }
 
                public class EquatableClass : IEquatable<EquatableClass>
                {