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.
54 lines
1.5 KiB
54 lines
1.5 KiB
1 month ago
|
import XCTest
|
||
|
@testable import Model
|
||
|
|
||
|
final class FilledBoardTests: XCTestCase {
|
||
|
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 {
|
||
|
.Player1
|
||
|
} else {
|
||
|
.Player2
|
||
|
}
|
||
|
}
|
||
|
}
|
||
|
|
||
|
self.board = board
|
||
|
}
|
||
|
|
||
|
func testInsertFailTopNoPush() {
|
||
|
let before = board[2, 0]
|
||
|
XCTAssertFalse(board.insert(piece: .Player1, side: .Top, offset: 2))
|
||
|
XCTAssertEqual(before, board[2, 0])
|
||
|
}
|
||
|
|
||
|
func testInsertFailBottomNoPush() {
|
||
|
let before = board[2, board.rows - 1]
|
||
|
XCTAssertFalse(board.insert(piece: .Player2, side: .Bottom, offset: 2))
|
||
|
XCTAssertEqual(before, board[2, board.rows - 1])
|
||
|
}
|
||
|
|
||
|
func testInsertFailLeftNoPush() {
|
||
|
let before = board[2, 0]
|
||
|
XCTAssertFalse(board.insert(piece: .Player1, side: .Left, offset: 2))
|
||
|
XCTAssertEqual(before, board[0, 2])
|
||
|
}
|
||
|
|
||
|
func testInsertFailRightNoPush() {
|
||
|
let before = board[board.columns - 1, 2]
|
||
|
XCTAssertFalse(board.insert(piece: .Player2, side: .Right, offset: 2))
|
||
|
XCTAssertEqual(before, board[board.columns - 1, 2])
|
||
|
}
|
||
|
|
||
|
// TODO Test shifting
|
||
|
}
|