コード例 #1
0
        public void MergeTwoLists_Test1(string left, string right, string expected)
        {
            var l   = InlineDataStringToList(left);
            var r   = InlineDataStringToList(right);
            var exp = InlineDataStringToList(expected);

            var actual = MergeTwoSortedLists_21.MergeTwoLists(l, r);

            AssertListsEqual(exp, actual);
        }
コード例 #2
0
        public void TestMethod1()
        {
            var Input_l1 = new ListNode(1)
            {
                next = new ListNode(2)
                {
                    next = new ListNode(4)
                }
            };

            var Input_l2 = new ListNode(1)
            {
                next = new ListNode(3)
                {
                    next = new ListNode(4)
                }
            };

            var Expected = new ListNode(1)
            {
                next = new ListNode(1)
                {
                    next = new ListNode(2)
                    {
                        next = new ListNode(3)
                        {
                            next = new ListNode(4)
                            {
                                next = new ListNode(4)
                            }
                        }
                    }
                }
            };

            var Actual = MergeTwoSortedLists_21.MergeTwoLists(Input_l1, Input_l2);

            while (Expected != null && Actual != null)
            {
                Assert.AreEqual(Expected.val, Actual.val);
                Expected = Expected.next;
                Actual   = Actual.next;
            }
        }