def test_blank_false(self): input = has_cycle(ListNode.build([])) self.assertFalse(input)
def test_1234567888(self): input = remove_dupes(ListNode.build([1, 2, 3, 4, 5, 6, 7, 8, 8, 8])) output = ListNode.build([1, 2, 3, 4, 5, 6, 7, 8]) self.assertEqual(input, output)
def test_blank(self): input = remove_dupes(ListNode.build([])) output = ListNode.build([]) self.assertEqual(input, output)
def test_short_true(self): head = ListNode.build([1, 2, 2, 1]) self.assertTrue(is_palindrome(head))
def test_11112233(self): input = remove_dupes(ListNode.build([0, 11, 11, 22, 33])) output = ListNode.build([0, 11, 22, 33]) self.assertEqual(input, output)
def test_81632_519100(self): list1 = ListNode.build([8, 16, 32]) list2 = ListNode.build([5, 19, 100]) input = merge_sorted_lists(list1, list2) output = ListNode.build([5, 8, 16, 19, 32, 100]) self.assertEqual(input, output)
def test_uneven_lists(self): list1 = ListNode.build([1, 2, 3, 4]) list2 = ListNode.build([-99, 4, 32]) input = merge_sorted_lists(list1, list2) output = ListNode.build([-99, 1, 2, 3, 4, 4, 32]) self.assertEqual(input, output)
def test_4519_1(self): head = ListNode.build([4, 5, 1, 9]) node = head.next.next del_node(node) out_list = ListNode.build([4, 5, 9]) self.assertEqual(head, out_list)
def test_45_4(self): head = ListNode.build([4, 5]) node = head del_node(node) out_list = ListNode.build([5]) self.assertEqual(head, out_list)
def test_123_3(self): input = remove_nth_node_from_end(ListNode.build([1, 2, 3]), 3) output = ListNode.build([2, 3]) self.assertEqual(input, output)
def test_123456789_9(self): input = remove_nth_node_from_end( ListNode.build([1, 2, 3, 4, 5, 6, 7, 8, 9]), 9) output = ListNode.build([2, 3, 4, 5, 6, 7, 8, 9]) self.assertEqual(input, output)
def test_1_1(self): # Test works on LeetCode, but not here input = remove_nth_node_from_end(ListNode.build([1]), 1) output = ListNode.build("") self.assertEqual(input, output)
def test_12_2(self): input = remove_nth_node_from_end(ListNode.build([1, 2]), 2) output = ListNode.build([2]) self.assertEqual(input, output)
def test_1263456_6(self): input = remove_linked_list_val(ListNode.build([1, 2, 6, 3, 4, 5, 6]), 6) self.assertEqual(input, ListNode.build([1, 2, 3, 4, 5]))
def test_12345678_false(self): input = has_cycle(ListNode.build([1, 2, 3, 4, 5, 6, 7, 8])) self.assertFalse(input)
def test_12345(self): head = ListNode.build([1, 2, 3, 4, 5]) reversed = ListNode.build([5, 4, 3, 2, 1]) self.assertEqual(reverse_ll(head), reversed)
def test_124_134(self): list1 = ListNode.build([1, 2, 4]) list2 = ListNode.build([1, 3, 4]) input = merge_sorted_lists(list1, list2) output = ListNode.build([1, 1, 2, 3, 4, 4]) self.assertEqual(input, output)
def test_blank(self): head = ListNode.build([]) reversed = ListNode.build([]) self.assertEqual(reverse_ll(head), reversed)
def test_minus1248_minus6945(self): list1 = ListNode.build([-12, 4, 8]) list2 = ListNode.build([-6, 9, 45]) input = merge_sorted_lists(list1, list2) output = ListNode.build([-12, -6, 4, 8, 9, 45]) self.assertEqual(input, output)
def test_112(self): input = remove_dupes(ListNode.build([1, 1, 2])) output = ListNode.build([1, 2]) self.assertEqual(input, output)
def test_blank_lists(self): list1 = ListNode.build([]) list2 = ListNode.build([]) input = merge_sorted_lists(list1, list2) output = ListNode('') self.assertEqual(input, output)
def test_short_false(self): head = ListNode.build([1, 2]) self.assertFalse(is_palindrome(head))