You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
61 lines
1.6 KiB
61 lines
1.6 KiB
import XCTest
|
|
@testable import Model
|
|
|
|
final class FilledBoardTests: XCTestCase {
|
|
private static let playerA = Player(name: "dummy A", piece_type: .A)
|
|
private static let playerB = Player(name: "dummy B", piece_type: .B)
|
|
|
|
private var board: Board!
|
|
|
|
override func setUp() {
|
|
super.setUp()
|
|
|
|
guard var board = Board(columns: 5, rows: 6) else {
|
|
XCTFail()
|
|
return
|
|
}
|
|
|
|
for row in 0..<board.rows {
|
|
for col in 0..<board.columns {
|
|
board[col, row] = if (row & 1) == 1 {
|
|
Piece(owner: Self.playerA)
|
|
} else {
|
|
Piece(owner: Self.playerB)
|
|
}
|
|
}
|
|
}
|
|
|
|
self.board = board
|
|
}
|
|
|
|
func testRemovePiece() throws {
|
|
board[1, 2] = nil
|
|
|
|
XCTAssertNil(board[1, 2])
|
|
}
|
|
|
|
func testInsertsFallFail() throws {
|
|
for (from, direction): ((Int, Int), Direction) in [
|
|
((0, 0), .Bottom),
|
|
((0, 0), .Right),
|
|
((4, 5), .Left),
|
|
((4, 5), .Top),
|
|
|
|
((4, 5), .Bottom),
|
|
((4, 5), .Right),
|
|
((0, 0), .Left),
|
|
((0, 0), .Top),
|
|
] {
|
|
try self.setUpWithError()
|
|
|
|
try self._testInsertFallFail(from: Coords(pair: from), dir: direction)
|
|
|
|
try self.tearDownWithError()
|
|
}
|
|
}
|
|
|
|
private func _testInsertFallFail(from: Coords, dir: Direction) throws {
|
|
XCTAssertEqual(board.fallCoordinates(initialCoords: from, direction: dir), .Occupied)
|
|
}
|
|
}
|