We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
1 parent 1bbb774 commit 7dda718Copy full SHA for 7dda718
test/listNode.spec.ts
@@ -0,0 +1,26 @@
1
+import { test, expect, describe } from 'vitest';
2
+const ListNode = require('../common/structures/ListNode');
3
+
4
+test('toArray 正常数组', () => {
5
+ // 创建链表
6
+ const head = new ListNode(1);
7
+ const node1 = new ListNode(2);
8
+ const node2 = new ListNode(3);
9
+ head.next = node1;
10
+ node1.next = node2;
11
12
+ const arr = ListNode.toArray(head)
13
+ expect(arr).toEqual([1, 2, 3])
14
+})
15
+test('toArray undefined', () => {
16
+ const arr = ListNode.toArray(undefined)
17
+ expect(arr).toEqual([])
18
19
+test('toArray false', () => {
20
+ const arr = ListNode.toArray(false)
21
+ expect(arr).toEqual([undefined])
22
23
+test('toArray 1', () => {
24
+ const arr = ListNode.toArray(1)
25
26
0 commit comments