コード例 #1
0
        public void Ctor_SingleLinkedList_IsEmpty()
        {
            SingleLinkedList <int> emptyList = new SingleLinkedList <int>();

            int[] numbers = emptyList.ToArray();

            Assert.AreEqual(0, numbers.Length);
        }
コード例 #2
0
        public void InsertAtEnd_EmptySingleLinkedList_ReturnsProperValue()
        {
            SingleLinkedList <int> list = new SingleLinkedList <int>();

            list.InsertAtEnd(10);

            int[] numbers = list.ToArray();

            Assert.AreEqual(10, numbers[0]);
        }
コード例 #3
0
        public void InsertAtEnd_EmptySingleLinkedList_HasOneValue()
        {
            SingleLinkedList <int> list = new SingleLinkedList <int>();

            list.InsertAtEnd(10);

            int[] numbers = list.ToArray();

            Assert.AreEqual(1, numbers.Length);
        }
コード例 #4
0
        public void Iterate_SingleLinkedList_InProperOrder()
        {
            SingleLinkedList <int> list = new SingleLinkedList <int>();

            list.InsertFront(1);
            list.InsertFront(2);
            list.InsertFront(3);

            int[] numbers = list.ToArray();

            Assert.AreEqual(new int[] { 3, 2, 1 }, numbers);
        }
コード例 #5
0
        public void IterateAfterInsertAtEnd_SingleLinkedList_InProperOrder()
        {
            SingleLinkedList <int> list = new SingleLinkedList <int>();

            list.InsertAtEnd(1);
            list.InsertAtEnd(2);
            list.InsertAtEnd(3);

            int[] numbers = list.ToArray();

            Assert.AreEqual(new int[] { 1, 2, 3 }, numbers);
        }
コード例 #6
0
        public void Delete4_123_Returns123()
        {
            SingleLinkedList <int> list = new SingleLinkedList <int>();

            list.InsertAtEnd(1);
            list.InsertAtEnd(2);
            list.InsertAtEnd(3);

            list.Delete(4);

            int[] numbers = list.ToArray();
            Assert.AreEqual(new int[] { 1, 2, 3 }, numbers);
        }
コード例 #7
0
        public void Clone_123_Equals123()
        {
            SingleLinkedList <int> list = new SingleLinkedList <int>();

            list.InsertAtEnd(1);
            list.InsertAtEnd(2);
            list.InsertAtEnd(3);

            var copy = list.Clone();

            int[] numbers     = list.ToArray();
            int[] copyNumbers = copy.ToArray();
            Assert.AreEqual(numbers, copyNumbers);
        }