public void Test1() { // Arrange ListNode[] lists = { new ListNode(1, new ListNode(4, new ListNode(5))) , new ListNode(1, new ListNode(3, new ListNode(4))) , new ListNode(2, new ListNode(6)) }; // Act var root = new Solution5().MergeKLists(lists); // Assert var vals = new List <int>(); var current = root; while (current != null) { vals.Add(current.val); current = current.next; } CollectionAssert.AreEqual(new[] { 1, 1, 2, 3, 4, 4, 5, 6 }, vals); }
public void Test3() { // Arrange ListNode[] lists = { null }; // Act var root = new Solution5().MergeKLists(lists); // Assert Assert.Null(root); }
public void Test2() { // Arrange var lists = new ListNode[0]; // Act var root = new Solution5().MergeKLists(lists); // Assert Assert.Null(root); }