-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathgoban.spec.ts
39 lines (32 loc) · 1.2 KB
/
goban.spec.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
import { describe, it } from "node:test";
import assert from "node:assert/strict";
import { Goban } from "./goban";
describe("Goban", () => {
it("test_white_is_taken_when_surrounded_by_black", () => {
const goban = new Goban([".#.", "#o#", ".#."]);
assert.ok(goban.isTaken(1, 1));
});
it("test_white_is_not_taken_when_it_has_a_liberty", () => {
const goban = new Goban(["...", "#o#", ".#."]);
assert.equal(goban.isTaken(1, 1), false);
});
it("test_black_shape_is_taken_when_surrounded", () => {
const goban = new Goban(["oo.", "##o", "o#o", ".o."]);
assert.ok(goban.isTaken(0, 1));
assert.ok(goban.isTaken(1, 1));
assert.ok(goban.isTaken(1, 2));
});
it("test_black_shape_is_not_taken_when_it_has_a_liberty", () => {
const goban = new Goban(["oo.", "##.", "o#o", ".o."]);
assert.equal(goban.isTaken(0, 1), false);
assert.equal(goban.isTaken(1, 1), false);
assert.equal(goban.isTaken(1, 2), false);
});
it("test_square_shape_is_taken", () => {
const goban = new Goban(["oo.", "##o", "##o", "oo."]);
assert.ok(goban.isTaken(0, 1));
assert.ok(goban.isTaken(0, 2));
assert.ok(goban.isTaken(1, 1));
assert.ok(goban.isTaken(1, 2));
});
});