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.
29 lines
962 B
29 lines
962 B
import XCTest
|
|
@testable import Model
|
|
|
|
final class HumanPlayerTests: XCTestCase {
|
|
func testInit() {
|
|
let p = HumanPlayer(name: "the name", piece_type: .B, callback: { _, _ in fatalError("NOOP") })
|
|
|
|
XCTAssertEqual(p.name, "the name")
|
|
XCTAssertEqual(p.piece_type, .B)
|
|
}
|
|
|
|
func testChoose() async {
|
|
let board = Board(columns: 3, rows: 3)!
|
|
let moves: [Move.Action] = [.InsertAt(where: Coords(1, 2)), .InsertOnSide(side: .Left, offset: 1)]
|
|
|
|
let player = HumanPlayer(name: "name", piece_type: .A, callback: {
|
|
moves2, board2 in
|
|
|
|
XCTAssertEqual(moves2, moves)
|
|
XCTAssertEqual(board2, board)
|
|
|
|
return .InsertOnSide(side: .Bottom, offset: 99)
|
|
})
|
|
|
|
let result = await player.chooseMove(allowed_moves: moves, board: board)
|
|
XCTAssertEqual(result, .InsertOnSide(side: .Bottom, offset: 99))
|
|
}
|
|
}
|