Exemple #1
0
        public void TestRetainAll()
        {
            IntList list = new IntList();

            for (int j = 0; j < 1000; j++)
            {
                list.Add(j);
            }
            IntList listCopy = new IntList(list);
            IntList listOdd  = new IntList();
            IntList listEven = new IntList();

            for (int j = 0; j < 1000; j++)
            {
                if (j % 2 == 0)
                {
                    listEven.Add(j);
                }
                else
                {
                    listOdd.Add(j);
                }
            }
            list.RetainAll(listOdd);
            //Assert.AreEqual(list, listOdd);
            Assert.IsTrue(list.Equals(listOdd));
            list.RetainAll(listEven);
            Assert.IsTrue(list.IsEmpty());
            listCopy.RetainAll(listEven);
            //Assert.AreEqual(listCopy, listEven);
            Assert.IsTrue(listCopy.Equals(listEven));
            listCopy.RetainAll(listOdd);
            Assert.IsTrue(listCopy.IsEmpty());
        }
Exemple #2
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());
        }
Exemple #3
0
        public void TestConstructors()
        {
            IntList list = new IntList();

            Assert.IsTrue(list.IsEmpty());
            list.Add(0);
            list.Add(1);
            IntList list2 = new IntList(list);

            //Assert.AreEqual(list, list2);
            Assert.IsTrue(list.Equals(list2));
            IntList list3 = new IntList(2);

            Assert.IsTrue(list3.IsEmpty());
        }