示例#1
0
        public void TestEquals()
        {
            ShortList list = new ShortList();

            //Assert.AreEqual(list, list);
            Assert.IsTrue(list.Equals(list));
            Assert.IsTrue(!list.Equals(null));
            ShortList list2 = new ShortList(200);

            //Assert.AreEqual(list, list2);
            Assert.IsTrue(list.Equals(list2));
            //Assert.AreEqual(list2, list);
            Assert.IsTrue(list2.Equals(list));
            Assert.AreEqual(list.GetHashCode(), list2.GetHashCode());
            list.Add((short)0);
            list.Add((short)1);
            list2.Add((short)1);
            list2.Add((short)0);
            Assert.IsTrue(!list.Equals(list2));
            list2.RemoveValue((short)1);
            list2.Add((short)1);
            //Assert.AreEqual(list, list2);
            Assert.IsTrue(list.Equals(list2));
            //Assert.AreEqual(list2, list);
            Assert.IsTrue(list2.Equals(list));
            list2.Add((short)2);
            Assert.IsTrue(!list.Equals(list2));
            Assert.IsTrue(!list2.Equals(list));
        }
示例#2
0
        public void TestRemoveValue()
        {
            ShortList list = new ShortList();

            for (short j = 0; j < 1000; j++)
            {
                list.Add((short)(j / 2));
            }
            for (short j = 0; j < 1000; j++)
            {
                if (j < 500)
                {
                    Assert.IsTrue(list.RemoveValue(j));
                    Assert.IsTrue(list.RemoveValue(j));
                }
                Assert.IsTrue(!list.RemoveValue(j));
            }
        }
示例#3
0
        public void TestSize()
        {
            ShortList list = new ShortList();

            for (short j = 0; j < 1000; j++)
            {
                Assert.AreEqual(j, list.Count);
                list.Add(j);
                Assert.AreEqual(j + 1, list.Count);
            }
            for (short j = 0; j < 1000; j++)
            {
                Assert.AreEqual(1000 - j, list.Count);
                list.RemoveValue(j);
                Assert.AreEqual(999 - j, list.Count);
            }
        }
示例#4
0
        public void TestIsEmpty()
        {
            ShortList list1 = new ShortList();
            ShortList list2 = new ShortList(1000);
            ShortList list3 = new ShortList(list1);

            Assert.IsTrue(list1.IsEmpty());
            Assert.IsTrue(list2.IsEmpty());
            Assert.IsTrue(list3.IsEmpty());
            list1.Add((short)1);
            list2.Add((short)2);
            list3 = new ShortList(list2);
            Assert.IsTrue(!list1.IsEmpty());
            Assert.IsTrue(!list2.IsEmpty());
            Assert.IsTrue(!list3.IsEmpty());
            list1.Clear();
            list2.Remove(0);
            list3.RemoveValue((short)2);
            Assert.IsTrue(list1.IsEmpty());
            Assert.IsTrue(list2.IsEmpty());
            Assert.IsTrue(list3.IsEmpty());
        }