|
|
|
@ -7,9 +7,34 @@
|
|
|
|
|
|
|
|
|
|
import Foundation
|
|
|
|
|
import XCTest
|
|
|
|
|
import forcesPack
|
|
|
|
|
|
|
|
|
|
final class BoardRulesTests: XCTestCase {
|
|
|
|
|
private var boardEmpty: [[Int?]] = [[nil,nil,nil,nil],[nil,nil,nil,nil],[nil,nil,nil,nil],[nil,nil,nil,nil]]
|
|
|
|
|
private var boardRow: [[Int?]] = [[0,0,0,0],[nil,nil,nil,nil],[nil,nil,nil,nil],[nil,nil,nil,nil]]
|
|
|
|
|
private var boardCol: [[Int?]] = [[0,nil,nil,nil],[0,nil,nil,nil],[0,nil,nil,nil],[0,nil,nil,nil]]
|
|
|
|
|
private var boardDiag: [[Int?]] = [[0,nil,nil,nil],[nil,0,nil,nil],[nil,nil,0,nil],[nil,nil,nil,0]]
|
|
|
|
|
|
|
|
|
|
func testRules(){
|
|
|
|
|
//let rule : Rule
|
|
|
|
|
var ruleCol : Rule = AreCols4x()
|
|
|
|
|
var ruleRow: Rule = AreRows4x()
|
|
|
|
|
var ruleDiag: Rule = AreDiags4x()
|
|
|
|
|
|
|
|
|
|
XCTAssertFalse(ruleCol.isRuleMet(grid: boardEmpty, targetedRow: 0, targetedCol: 0))
|
|
|
|
|
XCTAssertFalse(ruleRow.isRuleMet(grid: boardEmpty, targetedRow: 0, targetedCol: 0))
|
|
|
|
|
XCTAssertFalse(ruleDiag.isRuleMet(grid: boardEmpty, targetedRow: 0, targetedCol: 0))
|
|
|
|
|
|
|
|
|
|
XCTAssertTrue(ruleCol.isRuleMet(grid: boardRow, targetedRow: 0, targetedCol: 0))
|
|
|
|
|
XCTAssertFalse(ruleRow.isRuleMet(grid: boardRow, targetedRow: 0, targetedCol: 0))
|
|
|
|
|
XCTAssertFalse(ruleDiag.isRuleMet(grid: boardRow, targetedRow: 0, targetedCol: 0))
|
|
|
|
|
|
|
|
|
|
XCTAssertFalse(ruleCol.isRuleMet(grid: boardCol, targetedRow: 0, targetedCol: 0))
|
|
|
|
|
XCTAssertTrue(ruleRow.isRuleMet(grid: boardCol, targetedRow: 0, targetedCol: 0))
|
|
|
|
|
XCTAssertFalse(ruleDiag.isRuleMet(grid: boardCol, targetedRow: 0, targetedCol: 0))
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
XCTAssertFalse(ruleCol.isRuleMet(grid: boardDiag, targetedRow: 0, targetedCol: 0))
|
|
|
|
|
XCTAssertFalse(ruleRow.isRuleMet(grid: boardDiag, targetedRow: 0, targetedCol: 0))
|
|
|
|
|
XCTAssertTrue(ruleDiag.isRuleMet(grid: boardDiag, targetedRow: 0, targetedCol: 0))
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|