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.
28 lines
836 B
28 lines
836 B
import XCTest
|
|
@testable import Model
|
|
|
|
final class RandomPlayerTests: XCTestCase {
|
|
func testInit() {
|
|
for t in [PieceType.A, .B] {
|
|
let p = RandomPlayer(name: "the name", piece_type: t)
|
|
|
|
XCTAssertEqual(p.name, "the name")
|
|
XCTAssertEqual(p.piece_type, t)
|
|
}
|
|
}
|
|
|
|
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 = RandomPlayer(name: "name", piece_type: .A)
|
|
|
|
// +5 test quality credits
|
|
for _ in 1...10 {
|
|
let choosen = await player.chooseMove(allowed_moves: moves, board: board)
|
|
|
|
XCTAssertNotNil(moves.firstIndex(of: choosen))
|
|
}
|
|
}
|
|
}
|