Skip to content

Commit d1ca13d

Browse files
committed
Create test.ts
1 parent dc2d058 commit d1ca13d

File tree

1 file changed

+17
-0
lines changed

1 file changed

+17
-0
lines changed

design-circular-queue/test.ts

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
import { assertEquals } from "../deps.ts";
2+
import MyCircularQueue from "./index.ts";
3+
4+
Deno.test("design-circular-queue", () => {
5+
const results = [];
6+
const circularQueue: MyCircularQueue = MyCircularQueue(3); // 设置长度为 3
7+
results.push(circularQueue.enQueue(1)); // 返回 true
8+
results.push(circularQueue.enQueue(2)); // 返回 true
9+
results.push(circularQueue.enQueue(3)); // 返回 true
10+
results.push(circularQueue.enQueue(4)); // 返回 false,队列已满
11+
results.push(circularQueue.Rear()); // 返回 3
12+
results.push(circularQueue.isFull()); // 返回 true
13+
results.push(circularQueue.deQueue()); // 返回 true
14+
results.push(circularQueue.enQueue(4)); // 返回 true
15+
results.push(circularQueue.Rear()); // 返回 4
16+
assertEquals(results, [true, true, true, false, 3, true, true, true, 4]);
17+
});

0 commit comments

Comments
 (0)