deno.land / x / masx200_leetcode_test@10.6.5 / iterator-for-combination / test.ts

نووسراو ببینە
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
import { assertEquals } from "https://deno.land/std@0.157.0/testing/asserts.ts";
import CombinationIterator from "./index.ts";
Deno.test("iterator-for-combination", () => { const res = []; const iterator: CombinationIterator = new CombinationIterator("abc", 2); // 创建迭代器 iterator res.push(iterator.next()); // 返回 "ab" res.push(iterator.hasNext()); // 返回 true res.push(iterator.next()); // 返回 "ac" res.push(iterator.hasNext()); // 返回 true res.push(iterator.next()); // 返回 "bc" res.push(iterator.hasNext()); // 返回 false assertEquals(res, ["ab", true, "ac", true, "bc", false]);});
masx200_leetcode_test

Version Info

Tagged at
a year ago