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.
41 lines
1.8 KiB
41 lines
1.8 KiB
//
|
|
// File.swift
|
|
//
|
|
//
|
|
// Created by yorick geoffre on 07/02/2023.
|
|
//
|
|
|
|
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(){
|
|
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))
|
|
}
|
|
}
|