Change pieces names

Boards
Mathieu GROUSSEAU 5 months ago
parent 9d200b7b79
commit 164a0528f0

@ -39,9 +39,9 @@ public struct Board {
for column in grid {
for piece in column {
switch piece {
case .Player1:
case .PlayerA:
a += 1
case .Player2:
case .PlayerB:
b += 1
case nil:
break

@ -1,3 +1,3 @@
public enum Piece {
case Player1, Player2
case PlayerA, PlayerB
}

@ -31,13 +31,13 @@ final class EmptyBoardTests: XCTestCase {
}
func testSetGet() throws {
board[1, 1] = Piece.Player1;
board[1, 1] = Piece.PlayerA;
XCTAssertEqual(board[1, 1], .Player1)
XCTAssertEqual(board[1, 1], .PlayerA)
}
func testCounts() throws {
board[1, 2] = .Player2
board[1, 2] = .PlayerB
let counts = board.countPieces()
XCTAssertEqual(counts.a, 0)
@ -45,22 +45,22 @@ final class EmptyBoardTests: XCTestCase {
}
func testInsertTopNoPush() {
XCTAssert(board.insert(piece: .Player1, side: .Top, offset: 2))
XCTAssertEqual(board[2, 0], .Player1)
XCTAssert(board.insert(piece: .PlayerA, side: .Top, offset: 2))
XCTAssertEqual(board[2, 0], .PlayerA)
}
func testInsertBottomNoPush() {
XCTAssert(board.insert(piece: .Player2, side: .Bottom, offset: 2))
XCTAssertEqual(board[2, board.rows - 1], .Player2)
XCTAssert(board.insert(piece: .PlayerB, side: .Bottom, offset: 2))
XCTAssertEqual(board[2, board.rows - 1], .PlayerB)
}
func testInsertLeftNoPush() {
XCTAssert(board.insert(piece: .Player1, side: .Left, offset: 2))
XCTAssertEqual(board[0, 2], .Player1)
XCTAssert(board.insert(piece: .PlayerA, side: .Left, offset: 2))
XCTAssertEqual(board[0, 2], .PlayerA)
}
func testInsertRightNoPush() {
XCTAssert(board.insert(piece: .Player2, side: .Right, offset: 2))
XCTAssertEqual(board[board.columns - 1, 2], .Player2)
XCTAssert(board.insert(piece: .PlayerB, side: .Right, offset: 2))
XCTAssertEqual(board[board.columns - 1, 2], .PlayerB)
}
}

@ -15,9 +15,9 @@ final class FilledBoardTests: XCTestCase {
for row in 0..<board.rows {
for col in 0..<board.columns {
board[col, row] = if (row & 1) == 1 {
.Player1
.PlayerA
} else {
.Player2
.PlayerB
}
}
}
@ -27,25 +27,25 @@ final class FilledBoardTests: XCTestCase {
func testInsertFailTopNoPush() {
let before = board[2, 0]
XCTAssertFalse(board.insert(piece: .Player1, side: .Top, offset: 2))
XCTAssertFalse(board.insert(piece: .PlayerA, 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))
XCTAssertFalse(board.insert(piece: .PlayerB, 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))
XCTAssertFalse(board.insert(piece: .PlayerA, 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))
XCTAssertFalse(board.insert(piece: .PlayerB, side: .Right, offset: 2))
XCTAssertEqual(before, board[board.columns - 1, 2])
}