Ejemplo n.º 1
0
        public void TestIsEmpty()
        {
            IntList list1 = new IntList();
            IntList list2 = new IntList(1000);
            IntList list3 = new IntList(list1);

            Assert.IsTrue(list1.IsEmpty());
            Assert.IsTrue(list2.IsEmpty());
            Assert.IsTrue(list3.IsEmpty());
            list1.Add(1);
            list2.Add(2);
            list3 = new IntList(list2);
            Assert.IsTrue(!list1.IsEmpty());
            Assert.IsTrue(!list2.IsEmpty());
            Assert.IsTrue(!list3.IsEmpty());
            list1.Clear();
            list2.Remove(0);
            list3.RemoveValue(2);
            Assert.IsTrue(list1.IsEmpty());
            Assert.IsTrue(list2.IsEmpty());
            Assert.IsTrue(list3.IsEmpty());
        }
Ejemplo n.º 2
0
        public void TestClear()
        {
            IntList list = new IntList();

            for (int j = 0; j < 500; j++)
            {
                list.Add(j);
            }
            Assert.AreEqual(500, list.Count);
            list.Clear();
            Assert.AreEqual(0, list.Count);
            for (int j = 0; j < 500; j++)
            {
                list.Add(j + 1);
            }
            Assert.AreEqual(500, list.Count);
            for (int j = 0; j < 500; j++)
            {
                Assert.AreEqual(j + 1, list.Get(j));
            }
        }