206.反转链表 测试函数 使用Vec初始化ListNode

This commit is contained in:
游由 2021-11-18 09:45:31 +08:00
parent 6b0a1eeebe
commit a82ba4fb75
1 changed files with 2 additions and 2 deletions

View File

@ -53,9 +53,9 @@ mod test {
#[test]
fn test_q0206() {
let t1 = Some(Box::new(ListNode { val: 1, next: Some(Box::new(ListNode { val: 2, next: Some(Box::new(ListNode { val: 3, next: Some(Box::new(ListNode { val: 4, next: Some(Box::new(ListNode { val: 5, next: None })) })) })) })) }));
let t1 = ListNode::from_vec(vec![1, 2, 3, 4, 5]);
let t2 = Solution::reverse_list(t1);
let ans = Some(Box::new(ListNode { val: 5, next: Some(Box::new(ListNode { val: 4, next: Some(Box::new(ListNode { val: 3, next: Some(Box::new(ListNode { val: 2, next: Some(Box::new(ListNode { val: 1, next: None })) })) })) })) }));
let ans = ListNode::from_vec(vec![5, 4, 3, 2, 1]);
assert_eq!(t2, ans)
}
}