public void MergeTwoLists_l1輸入2_l2輸入1_應回傳12() { // arrange var l1 = new ListNode { Data = 2 }; var l2 = new ListNode { Data = 1 }; var expect = new ListNode { Data = 1, Next = new ListNode { Data = 2 } }; var sut = new Q0021_MergeTwoSortedLists(); // act var actual = sut.MergeTwoLists(l1, l2); // assert actual.Should().BeEquivalentTo(expect); }
public void MergeTwoLists_l1輸入null_l2輸入null_應回傳null() { // arrange ListNode l1 = null; ListNode l2 = null; var sut = new Q0021_MergeTwoSortedLists(); // act var actual = sut.MergeTwoLists(l1, l2); // assert actual.Should().BeNull(); }
public void MergeTwoLists_l1輸入0_l2輸入null_應回傳0() { // arrange var l1 = new ListNode { Data = 0 }; ListNode l2 = null; var expect = new ListNode { Data = 0 }; var sut = new Q0021_MergeTwoSortedLists(); // act var actual = sut.MergeTwoLists(l1, l2); // assert actual.Should().BeEquivalentTo(expect); }