Exemple #1
0
        public void TestEmptyListOperations()
        {
            VList <int> a = new VList <int>();
            VList <int> b = new VList <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); });
        }
Exemple #2
0
        public void TestInsertRemoveRange()
        {
            VList <int> oneTwo    = new VList <int>(1, 2);
            VList <int> threeFour = new VList <int>(3, 4);
            VList <int> list      = oneTwo;
            VList <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);
        }