def test_reverseBetween1(): head = ListNode.stringToListNode("[1,2,3,4,5]") m = 2 n = 4 expect = "[1, 4, 3, 2, 5]" actual = ListNode.listNodeToString(solution.reverseBetween(head, m, n)) assert actual == expect
def test_reverseBetween5(): head = ListNode.stringToListNode("[1,2,3,4,5,6,7,8,9]") m = 1 n = 5 expect = "[5, 4, 3, 2, 1, 6, 7, 8, 9]" actual = ListNode.listNodeToString(solution.reverseBetween(head, m, n)) assert actual == expect
def test_insertionsortlist1(): head = ListNode.stringToListNode("[4,2,1,3]") expexct = ListNode.stringToListNode("[1,2,3,4]") actual = solution.insertionSortList(head) assert ListNode.listNodeToString(actual) == ListNode.listNodeToString( expexct)
def test_rotateRight1(): head = ListNode.stringToListNode("[1, 2, 3, 4, 5]") k = 2 actual = solution.rotateRight(head, k) expect = ListNode.stringToListNode("[4, 5, 1, 2, 3]") assert ListNode.listNodeToString(actual) == ListNode.listNodeToString(expect)
def test_rotateRight4(): head = ListNode.stringToListNode("[0, 1, 2]") k = 3 actual = solution.rotateRight(head, k) expect = ListNode.stringToListNode("[0, 1, 2]") assert ListNode.listNodeToString(actual) == ListNode.listNodeToString(expect)
def test_deleteDuplicates8(): head = ListNode.stringToListNode('[1, 1, 2, 2]') expect = '[]' actual = ListNode.listNodeToString(solution.deleteDuplicates(head)) assert actual == expect
def test_partitionList1(): head = ListNode.stringToListNode('[1, 4, 3, 2, 5, 2]') x = 3 expect = '[1, 2, 2, 4, 3, 5]' actual = ListNode.listNodeToString(solution.partition(head, x)) assert actual == expect