示例#1
0
文件: RVList.cs 项目: Shaykh/Loyc
        public void TestEmptyListOperations()
        {
            RVList <int> a = new RVList <int>();
            RVList <int> b = new RVList <int>();

            a.AddRange(b);
            a.InsertRange(0, b);
            a.RemoveRange(0, 0);
            Assert.That(!a.Remove(0));
            Assert.That(a.IsEmpty);

            a.Add(1);
            b.AddRange(a);
            ExpectList(b, 1);
            b.RemoveAt(0);
            Assert.That(b.IsEmpty);
            b.InsertRange(0, a);
            ExpectList(b, 1);
            b.RemoveRange(0, 1);
            Assert.That(b.IsEmpty);
            b.Insert(0, a[0]);
            ExpectList(b, 1);
            b.Remove(a.Last);
            Assert.That(b.IsEmpty);

            AssertThrows <InvalidOperationException>(delegate() { a.NextIn(b); });
        }
示例#2
0
文件: RVList.cs 项目: Shaykh/Loyc
        public void TestInsertRemoveRange()
        {
            RVList <int> oneTwo    = new RVList <int>(1, 2);
            RVList <int> threeFour = new RVList <int>(3, 4);
            RVList <int> list      = oneTwo;
            RVList <int> list2     = threeFour;

            ExpectList(list, 1, 2);
            list.InsertRange(1, threeFour);
            ExpectList(list, 1, 3, 4, 2);
            list2.InsertRange(2, oneTwo);
            ExpectList(list2, 3, 4, 1, 2);

            list.RemoveRange(1, 2);
            ExpectList(list, 1, 2);
            list2.RemoveRange(2, 2);
            ExpectList(list2, 3, 4);

            list.RemoveRange(0, 2);
            ExpectList(list);
            list2.RemoveRange(1, 1);
            ExpectList(list2, 3);

            list = oneTwo;
            list.AddRange(threeFour);
            ExpectList(list, 1, 2, 3, 4);
            list.InsertRange(1, list);
            ExpectList(list, 1, 1, 2, 3, 4, 2, 3, 4);
            list.RemoveRange(1, 1);
            list.RemoveRange(4, 3);
            ExpectList(list, 1, 2, 3, 4);

            list.RemoveRange(0, 4);
            ExpectList(list);

            list2.InsertRange(0, list);
            list2.InsertRange(1, list);
            ExpectList(list2, 3);
        }