Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
let ranks = 1...8
let files = "A"..."H"

func isVaildSquare(rank: Int, file: String) -> Bool {
func isValidSquare(rank: Int, file: String) -> Bool {
return ranks.contains(rank) && files.contains(file)
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,10 @@
// TODO: define the 'files' constant


func isVaildSquare(rank: Int, file: String) -> Bool {
fatalError("Please implement the isVaildSquare(rank:file:) function")
func isValidSquare(rank: Int, file: String) -> Bool {
fatalError("Please implement the isValidSquare(rank:file:) function")
}

func getRow(_ board : [String], rank: Int) -> [String] {
fatalError("Please implement the isVaildSquare(_:rank:) function")
fatalError("Please implement the getRow(_:rank:) function")
}
Original file line number Diff line number Diff line change
Expand Up @@ -33,35 +33,35 @@ let RUNALL = Bool(ProcessInfo.processInfo.environment["RUNALL", default: "true"]
func testValidSquare() {
let rank = 1
let file = "A"
#expect(isVaildSquare(rank: rank, file: file))
#expect(isValidSquare(rank: rank, file: file))
}

@Test("that it returns true for another valid square", .enabled(if: RUNALL))
func testAnotherValidSquare() {
let rank = 8
let file = "H"
#expect(isVaildSquare(rank: rank, file: file))
#expect(isValidSquare(rank: rank, file: file))
}

@Test("that it returns false when rank is out of range", .enabled(if: RUNALL))
func testRankOutOfRange() {
let rank = 9
let file = "B"
#expect(!isVaildSquare(rank: rank, file: file))
#expect(!isValidSquare(rank: rank, file: file))
}

@Test("that it returns false when file is out of range", .enabled(if: RUNALL))
func testFileOutOfRange() {
let rank = 1
let file = "I"
#expect(!isVaildSquare(rank: rank, file: file))
#expect(!isValidSquare(rank: rank, file: file))
}

@Test("that it returns false when rank is less than one", .enabled(if: RUNALL))
func testRankLessThanOne() {
let rank = 0
let file = "A"
#expect(!isVaildSquare(rank: rank, file: file))
#expect(!isValidSquare(rank: rank, file: file))
}

@Test("that is returns correct first row", .enabled(if: RUNALL))
Expand Down