This repository has been archived by the owner on Jun 1, 2023. It is now read-only.
forked from refactoring-challenge/reversi-ios
-
Notifications
You must be signed in to change notification settings - Fork 0
/
BoardTests.swift
63 lines (58 loc) · 2.3 KB
/
BoardTests.swift
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
import XCTest
import MirrorDiffKit
@testable import Reversi
class BoardTests: XCTestCase {
func testAvailability() {
struct TestCase {
let board: Board<Disk?>
let diskToTest: Disk
let expected: Set<Line>
}
let testCases: [UInt: TestCase] = [
#line: TestCase(
board: Board(unsafeArray: [
[nil, nil, nil, nil, nil, nil, nil, nil],
[nil, nil, nil, nil, nil, nil, nil, nil],
[nil, nil, nil, nil, nil, nil, nil, nil],
[nil, nil, nil, .light, .dark, nil, nil, nil],
[nil, nil, nil, .dark, .light, nil, nil, nil],
[nil, nil, nil, nil, nil, nil, nil, nil],
[nil, nil, nil, nil, nil, nil, nil, nil],
[nil, nil, nil, nil, nil, nil, nil, nil],
]),
diskToTest: .light,
expected: Set([
Line(
start: Coordinate(x: .four, y: .four),
unsafeEnd: Coordinate(x: .four, y: .six),
direction: .bottom,
distance: .two
),
Line(
start: Coordinate(x: .four, y: .four),
unsafeEnd: Coordinate(x: .six, y: .four),
direction: .right,
distance: .two
),
Line(
start: Coordinate(x: .five, y: .five),
unsafeEnd: Coordinate(x: .five, y: .three),
direction: .top,
distance: .two
),
Line(
start: Coordinate(x: .five, y: .five),
unsafeEnd: Coordinate(x: .three, y: .five),
direction: .left,
distance: .two
),
])
),
]
testCases.forEach {
let (line, testCase) = $0
let actual = Set(testCase.board.availableCoordinates(for: testCase.diskToTest))
XCTAssertEqual(actual, testCase.expected, diff(between: testCase.expected, and: actual), line: line)
}
}
}