@@ -1,18 +1,9 @@
-from Cython.Compiler.ExprNodes import ListNode
-class Node:
- def __init__(self,cargo = None, next = None):
- self.cargo = cargo
- self.next = next
- def __str__(self):
- #测试基本功能,输出字符串
- return str(self.cargo)
-
-def printBackward(lists):
- if lists == None:
- return
- head = lists
- tail= lists.next
- print(head,tail)
- printBackward(tail)
-print(printBackward([123]))
+import pytest
+@pytest.mark.parametrize(
+ "list1, list2, expect",
+ [
+ ([1, 2, 4], [1, 3, 4], [1, 1, 2, 3, 4, 4])
+ ]
+)
+def test_cases(list1, list2, expect):
+ assert mergeTwoLists(list1, list2) == expect
@@ -1,4 +1,5 @@
from typing import Optional
# from Cython.Compiler.ExprNodes import ListNode
class ListNode:
@@ -23,3 +24,6 @@ class Solution:
pre.next = list1 if list1 else list2
return newList
+
+if __name__ == "__main__":
+ print(mergeTwoLists([1, 2, 4], [1, 3, 4]))