コード例 #1
0
        public void TestCompareTo()
        {
            VisitableLinkedList <int> l1 = new VisitableLinkedList <int>();

            l1.AddFirst(5);

            VisitableLinkedList <int> l2 = new VisitableLinkedList <int>();

            l2.AddFirst(3);
            l2.AddFirst(4);

            Assert.AreEqual(l1.CompareTo(l2), -1);
            Assert.AreEqual(l2.CompareTo(l1), 1);
            Assert.AreEqual(l1.CompareTo(l1), 0);

            object o = new object();

            Assert.AreEqual(l1.CompareTo(o), -1);
        }
コード例 #2
0
        public void TestAddFirstFullList()
        {
            VisitableLinkedList <int> testList = GetTestCustomLinkedList();

            testList.AddFirst(15);

            Assert.AreEqual(testList.First.Value, 15);
            Assert.AreNotEqual(testList.First.Next, null);
            Assert.AreEqual(testList.First.Next.Value, 0);
        }
コード例 #3
0
        public void TestFixedSize()
        {
            VisitableLinkedList <int> l = new VisitableLinkedList <int>();

            Assert.AreEqual(l.IsFixedSize, false);

            l = new VisitableLinkedList <int>();
            l.AddFirst(4);

            Assert.AreEqual(l.IsFixedSize, false);
        }
コード例 #4
0
        public void TestAddFirstEmptyList()
        {
            VisitableLinkedList <int> testList = new VisitableLinkedList <int>();

            testList.AddFirst(16);

            Assert.AreNotEqual(testList.First, null);
            Assert.AreEqual(testList.First.Value, 16);
            Assert.AreNotEqual(testList.Last, null);
            Assert.AreEqual(testList.Last.Value, 16);
            Assert.AreEqual(testList.First.Next, null);
        }