Пример #1
0
        public void HandleNullHead()
        {
            var list = new CircularLinkedList();
            list.InsertAtEnd(1);

            var head = list.Head;
            Assert.IsNotNull(head);
            Assert.AreEqual(1, head.Value);
        }
Пример #2
0
        public void TrueSingleCircular()
        {
            var list = new CircularLinkedList();
            list.InsertAtEnd(1);

            Assert.IsTrue(list.Detect());
        }
Пример #3
0
        public void InsertValueOnlyOne()
        {
            var list = new CircularLinkedList();
            list.InsertAtEnd(1);
            list.InsertAtEnd(2);

            var head = list.Head;
            Assert.IsNotNull(head);
            Assert.AreEqual(1, head.Value);

            var next = head.Next;
            Assert.IsNotNull(next);
            Assert.AreEqual(2, next.Value);

            var circular = next.Next;
            Assert.IsNotNull(circular);
            Assert.AreEqual(1, circular.Value);
        }
Пример #4
0
        public void TrueMultipleItemsCircular()
        {
            var list = new CircularLinkedList();
            list.InsertAtEnd(1);
            list.InsertAtEnd(2);

            Assert.IsTrue(list.Detect());
        }
Пример #5
0
        public void InsertValueCircular()
        {
            var list = new CircularLinkedList();
            list.InsertAtEnd(1);
            list.InsertAtEnd(2);
            list.InsertAtEnd(3);

            var head = list.Head;
            Assert.IsNotNull(head);
            Assert.AreEqual(1, head.Value);

            var second = head.Next;
            Assert.IsNotNull(second);
            Assert.AreEqual(2, second.Value);

            var third = second.Next;
            Assert.IsNotNull(third);
            Assert.AreEqual(3, third.Value);

            var circular = third.Next;
            Assert.IsNotNull(circular);
            Assert.AreEqual(1, circular.Value);
        }