コード例 #1
0
        public void ReArrageListOddLenghtTest()
        {
            var list = SingleLinkedList <string> .CreateList("a1");

            list.InsertLast("a2");
            list.InsertLast("a3");
            list.InsertLast("a4");
            list.InsertLast("b1");
            list.InsertLast("b2");
            list.InsertLast("b3");

            list.Print();

            try
            {
                LinkedListProblems.ReArrageList(list);
            }
            catch (ArgumentException ex)
            {
                Assert.IsTrue(ex.Message.Equals("list length should be even."), "Odd length list should throw error");
            }

            list.InsertLast("b4");
            list.InsertLast("b5");
            try
            {
                LinkedListProblems.ReArrageList(list);
            }
            catch (ArgumentException ex)
            {
                Assert.IsTrue(ex.Message.Equals("list length should be even."), "Odd length list should throw error");
            }

            list.Print();
        }
コード例 #2
0
        public void ReArrageListTwoNodeTest()
        {
            var list = SingleLinkedList <string> .CreateList("a1");

            list.InsertLast("b1");

            list.Print();

            LinkedListProblems.ReArrageList(list);

            list.Print();
        }
コード例 #3
0
        public void ReArrageListNullTest()
        {
            var list = SingleLinkedList <string> .CreateList("a1");

            list.DeleteFirst();

            list.Print();

            LinkedListProblems.ReArrageList(list);

            list.Print();
        }
コード例 #4
0
        public void ReArrageListBigListTest()
        {
            var list = SingleLinkedList <string> .CreateList("a1");

            list.InsertLast("a2");
            list.InsertLast("a3");
            list.InsertLast("a4");
            list.InsertLast("b1");
            list.InsertLast("b2");
            list.InsertLast("b3");
            list.InsertLast("b4");

            list.Print();

            LinkedListProblems.ReArrageList(list);

            list.Print();
        }