package test.leecode.linkedlist; import org.junit.Assert; import org.junit.Test; import cn.fansunion.leecode.linkedlist.ListNode; import cn.fansunion.leecode.linkedlist.MergeTwoSortedLists; /** * @author wen.lei@brgroup.com * * 2022-2-23 */ public class MergeTwoSortedListsTest // 1245+137=1123457 @Test public void test1245Plus137() MergeTwoSortedLists test = new MergeTwoSortedLists(); ListNode node5 = new ListNode( 5 , null ); ListNode node4 = new ListNode( 4 , node5); ListNode node2 = new ListNode( 2 , node4); ListNode list1 = new ListNode( 1 , node2); ListNode node7 = new ListNode( 7 , null ); ListNode node3 = new ListNode( 3 , node7); ListNode list2 = new ListNode( 1 , node3); ListNode merge1 = test.mergeTwoLists(list1, list2); int [] merge1Val = merge1.curNextValArray(); Assert.assertArrayEquals( new int [] 1 , 1 , 2 , 3 , 4 , 5 , 7 , merge1Val);
// 124+137=112347 @Test public void test124Plus137() MergeTwoSortedLists test = new MergeTwoSortedLists(); ListNode node4 = new ListNode( 4 , null ); ListNode node2 = new ListNode( 2 , node4); ListNode list1 = new ListNode( 1 , node2); ListNode node7 = new ListNode( 7 , null ); ListNode node3 = new ListNode( 3 , node7); ListNode list2 = new ListNode( 1 , node3); ListNode merge1 = test.mergeTwoLists(list1, list2); int [] merge1Val = merge1.curNextValArray(); Assert.assertArrayEquals( new int [] 1 , 1 , 2 , 3 , 4 , 7 , merge1Val);
// 124+1378=1123478 @Test public void test124Plus1378() MergeTwoSortedLists test = new MergeTwoSortedLists(); ListNode node4 = new ListNode( 4 , null ); ListNode node2 = new ListNode( 2 , node4); ListNode list1 = new ListNode( 1 , node2); ListNode node8 = new ListNode( 8 , null ); ListNode node7 = new ListNode( 7 , node8); ListNode node3 = new ListNode( 3 , node7); ListNode list2 = new ListNode( 1 , node3); ListNode merge1 = test.mergeTwoLists(list1, list2); int [] merge1Val = merge1.curNextValArray(); Assert.assertArrayEquals( new int [] 1 , 1 , 2 , 3 , 4 , 7 , 8 , merge1Val);
|