-
Notifications
You must be signed in to change notification settings - Fork 0
/
test.ts
49 lines (47 loc) · 1020 Bytes
/
test.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
import { assertEquals } from "https://deno.land/std@0.157.0/testing/asserts.ts";
import validPath from "./index.ts";
import validPath2 from "./validPath.ts";
Deno.test("find-if-path-exists-in-graph", () => {
testValidPath(validPath);
});
Deno.test("find-if-path-exists-in-graph", () => {
testValidPath(validPath2);
});
function testValidPath(validPath: {
(
n: number,
edges: number[][],
source: number,
destination: number,
): boolean;
}) {
assertEquals(true, validPath(1, [], 0, 0));
assertEquals(
false,
validPath(
6,
[
[0, 1],
[0, 2],
[3, 5],
[5, 4],
[4, 3],
],
0,
5,
),
);
assertEquals(
true,
validPath(
3,
[
[0, 1],
[1, 2],
[2, 0],
],
0,
2,
),
);
}