Ejemplo n.º 1
0
        public void HandleNullHeadSorted()
        {
            var list = new CircularLinkedList();
            list.InsertSorted(1);

            var head = list.Head;
            Assert.IsNotNull(head);
            Assert.AreEqual(1, head.Value);
        }
Ejemplo n.º 2
0
        public void HandleValueInTheMiddle()
        {
            var list = new CircularLinkedList();
            list.InsertSorted(1);
            list.InsertSorted(3);
            list.InsertSorted(2);

            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);
        }
Ejemplo n.º 3
0
        public void HandleValueSmallerThanHead()
        {
            var list = new CircularLinkedList();
            list.InsertSorted(5);
            list.InsertSorted(2);

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

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

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