parent
30dd50ffa8
commit
c1eb3a69e2
@ -0,0 +1,88 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<Scheme
|
||||||
|
LastUpgradeVersion = "1420"
|
||||||
|
version = "1.3">
|
||||||
|
<BuildAction
|
||||||
|
parallelizeBuildables = "YES"
|
||||||
|
buildImplicitDependencies = "YES">
|
||||||
|
<BuildActionEntries>
|
||||||
|
<BuildActionEntry
|
||||||
|
buildForTesting = "YES"
|
||||||
|
buildForRunning = "YES"
|
||||||
|
buildForProfiling = "YES"
|
||||||
|
buildForArchiving = "YES"
|
||||||
|
buildForAnalyzing = "YES">
|
||||||
|
<BuildableReference
|
||||||
|
BuildableIdentifier = "primary"
|
||||||
|
BlueprintIdentifier = "connect4_lib"
|
||||||
|
BuildableName = "connect4_lib"
|
||||||
|
BlueprintName = "connect4_lib"
|
||||||
|
ReferencedContainer = "container:">
|
||||||
|
</BuildableReference>
|
||||||
|
</BuildActionEntry>
|
||||||
|
</BuildActionEntries>
|
||||||
|
</BuildAction>
|
||||||
|
<TestAction
|
||||||
|
buildConfiguration = "Debug"
|
||||||
|
selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB"
|
||||||
|
selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB"
|
||||||
|
shouldUseLaunchSchemeArgsEnv = "YES"
|
||||||
|
codeCoverageEnabled = "YES"
|
||||||
|
onlyGenerateCoverageForSpecifiedTargets = "YES">
|
||||||
|
<CodeCoverageTargets>
|
||||||
|
<BuildableReference
|
||||||
|
BuildableIdentifier = "primary"
|
||||||
|
BlueprintIdentifier = "connect4_lib"
|
||||||
|
BuildableName = "connect4_lib"
|
||||||
|
BlueprintName = "connect4_lib"
|
||||||
|
ReferencedContainer = "container:">
|
||||||
|
</BuildableReference>
|
||||||
|
</CodeCoverageTargets>
|
||||||
|
<Testables>
|
||||||
|
<TestableReference
|
||||||
|
skipped = "NO">
|
||||||
|
<BuildableReference
|
||||||
|
BuildableIdentifier = "primary"
|
||||||
|
BlueprintIdentifier = "connect4_libTests"
|
||||||
|
BuildableName = "connect4_libTests"
|
||||||
|
BlueprintName = "connect4_libTests"
|
||||||
|
ReferencedContainer = "container:">
|
||||||
|
</BuildableReference>
|
||||||
|
</TestableReference>
|
||||||
|
</Testables>
|
||||||
|
</TestAction>
|
||||||
|
<LaunchAction
|
||||||
|
buildConfiguration = "Debug"
|
||||||
|
selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB"
|
||||||
|
selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB"
|
||||||
|
launchStyle = "0"
|
||||||
|
useCustomWorkingDirectory = "NO"
|
||||||
|
ignoresPersistentStateOnLaunch = "NO"
|
||||||
|
debugDocumentVersioning = "YES"
|
||||||
|
debugServiceExtension = "internal"
|
||||||
|
allowLocationSimulation = "YES">
|
||||||
|
</LaunchAction>
|
||||||
|
<ProfileAction
|
||||||
|
buildConfiguration = "Release"
|
||||||
|
shouldUseLaunchSchemeArgsEnv = "YES"
|
||||||
|
savedToolIdentifier = ""
|
||||||
|
useCustomWorkingDirectory = "NO"
|
||||||
|
debugDocumentVersioning = "YES">
|
||||||
|
<MacroExpansion>
|
||||||
|
<BuildableReference
|
||||||
|
BuildableIdentifier = "primary"
|
||||||
|
BlueprintIdentifier = "connect4_lib"
|
||||||
|
BuildableName = "connect4_lib"
|
||||||
|
BlueprintName = "connect4_lib"
|
||||||
|
ReferencedContainer = "container:">
|
||||||
|
</BuildableReference>
|
||||||
|
</MacroExpansion>
|
||||||
|
</ProfileAction>
|
||||||
|
<AnalyzeAction
|
||||||
|
buildConfiguration = "Debug">
|
||||||
|
</AnalyzeAction>
|
||||||
|
<ArchiveAction
|
||||||
|
buildConfiguration = "Release"
|
||||||
|
revealArchiveInOrganizer = "YES">
|
||||||
|
</ArchiveAction>
|
||||||
|
</Scheme>
|
@ -1,8 +1,47 @@
|
|||||||
//
|
|
||||||
// File.swift
|
|
||||||
//
|
|
||||||
//
|
|
||||||
// Created by etudiant on 2023-01-23.
|
|
||||||
//
|
|
||||||
|
|
||||||
import Foundation
|
import Foundation
|
||||||
|
import XCTest
|
||||||
|
import connect4_lib
|
||||||
|
|
||||||
|
final class BoardTest: XCTestCase {
|
||||||
|
|
||||||
|
func testInit() throws {
|
||||||
|
func expect(initBoardWithNbRows nbRows: Int,
|
||||||
|
andNbCols nbCols: Int,
|
||||||
|
shouldNotBeNil: Bool) {
|
||||||
|
let board = Board(withRows: nbRows, andWithCols: nbCols)
|
||||||
|
if !shouldNotBeNil {
|
||||||
|
XCTAssertNil(board)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
XCTAssertNotNil(board)
|
||||||
|
XCTAssertEqual(nbCols, board?.nbCols)
|
||||||
|
XCTAssertEqual(nbRows, board?.nbRows)
|
||||||
|
}
|
||||||
|
|
||||||
|
expect(initBoardWithNbRows: 6, andNbCols: 7, shouldNotBeNil: true)
|
||||||
|
expect(initBoardWithNbRows: -1, andNbCols: 7, shouldNotBeNil: false)
|
||||||
|
expect(initBoardWithNbRows: 6, andNbCols: -9, shouldNotBeNil: false)
|
||||||
|
expect(initBoardWithNbRows: 0, andNbCols: 7, shouldNotBeNil: false)
|
||||||
|
expect(initBoardWithNbRows: 6, andNbCols: 0, shouldNotBeNil: false)
|
||||||
|
}
|
||||||
|
|
||||||
|
func testInitLoad() throws {
|
||||||
|
func expect(withBoard orig: [[Int?]], shouldNotBeNil: Bool) {
|
||||||
|
let board = Board(withGrid: orig)
|
||||||
|
if !shouldNotBeNil {
|
||||||
|
XCTAssertNil(board)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
XCTAssertNotNil(board)
|
||||||
|
XCTAssertEqual(orig[0].count, board?.nbCols)
|
||||||
|
XCTAssertEqual(orig.count, board?.nbRows)
|
||||||
|
}
|
||||||
|
|
||||||
|
expect(withBoard: [[0, 1, 2], [0, 0, 0], [0, 0, 0]], shouldNotBeNil: true)
|
||||||
|
expect(withBoard: [], shouldNotBeNil: false)
|
||||||
|
expect(withBoard: [[], []], shouldNotBeNil: false)
|
||||||
|
expect(withBoard: [[0, 1], [0, 0]], shouldNotBeNil: false)
|
||||||
|
expect(withBoard: [[0, 1, 2], [0, 0, 0, 0]], shouldNotBeNil: false)
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
Loading…
Reference in new issue