-
-
Notifications
You must be signed in to change notification settings - Fork 20
/
Copy pathutils_test.dart
67 lines (63 loc) · 1.71 KB
/
utils_test.dart
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
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
import 'package:dartchess/dartchess.dart';
import 'package:fast_immutable_collections/fast_immutable_collections.dart';
import 'package:test/test.dart';
void main() {
test('makeLegalMoves with Kh8', () {
final setup = Setup.parseFen(
'r1bq1r2/3n2k1/p1p1pp2/3pP2P/8/PPNB2Q1/2P2P2/R3K3 b Q - 1 22',
);
final pos = Chess.fromSetup(setup);
final moves = makeLegalMoves(pos);
expect(moves[Square.g7], contains(Square.h8));
expect(moves[Square.g7], isNot(contains(Square.g8)));
});
test('makeLegalMoves with regular castle', () {
final wtm =
Chess.fromSetup(Setup.parseFen('r3k2r/8/8/8/8/8/8/R3K2R w KQkq - 0 1'));
expect(
makeLegalMoves(wtm)[Square.e1],
equals(
{
Square.a1,
Square.c1,
Square.d1,
Square.d2,
Square.e2,
Square.f1,
Square.f2,
Square.g1,
Square.h1,
},
),
);
expect(makeLegalMoves(wtm)[Square.e8], null);
final btm =
Chess.fromSetup(Setup.parseFen('r3k2r/8/8/8/8/8/8/R3K2R b KQkq - 0 1'));
expect(
makeLegalMoves(btm)[Square.e8],
equals({
Square.a8,
Square.c8,
Square.d7,
Square.d8,
Square.e7,
Square.f7,
Square.f8,
Square.g8,
Square.h8,
}),
);
expect(makeLegalMoves(btm)[Square.e1], null);
});
test('makeLegalMoves with chess960 castle', () {
final pos = Chess.fromSetup(
Setup.parseFen(
'rk2r3/pppbnppp/3p2n1/P2Pp3/4P2q/R5NP/1PP2PP1/1KNQRB2 b Kkq - 0 1',
),
);
expect(
makeLegalMoves(pos, isChess960: true)[Square.b8],
equals(ISet(const {Square.a8, Square.c8, Square.e8})),
);
});
}