-
-
Notifications
You must be signed in to change notification settings - Fork 159
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Update Swift tools version to 6.0 and refactor test cases to use new …
…testing framework
- Loading branch information
1 parent
30f8e4c
commit ba22a2f
Showing
12 changed files
with
422 additions
and
402 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,4 @@ | ||
// swift-tools-version:5.3 | ||
// swift-tools-version:6.0 | ||
|
||
import PackageDescription | ||
|
||
|
53 changes: 28 additions & 25 deletions
53
exercises/practice/matrix/Tests/MatrixTests/MatrixTests.swift
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,54 +1,57 @@ | ||
import XCTest | ||
import Foundation | ||
import Testing | ||
|
||
@testable import Matrix | ||
|
||
class MatrixTests: XCTestCase { | ||
let runAll = Bool(ProcessInfo.processInfo.environment["RUNALL", default: "false"]) ?? false | ||
let RUNALL = Bool(ProcessInfo.processInfo.environment["RUNALL", default: "false"]) ?? false | ||
|
||
@Suite struct MatrixTests { | ||
|
||
@Test("extract row from one number matrix") | ||
func testExtractRowFromOneNumberMatrix() { | ||
let matrix = Matrix("1") | ||
XCTAssertEqual([1], matrix.rows[0]) | ||
#expect([1] == matrix.rows[0]) | ||
} | ||
|
||
func testCanExtractRow() throws { | ||
try XCTSkipIf(true && !runAll) // change true to false to run this test | ||
@Test("can extract row", .enabled(if: RUNALL)) | ||
func testCanExtractRow() { | ||
let matrix = Matrix("1 2\n3 4") | ||
XCTAssertEqual([3, 4], matrix.rows[1]) | ||
#expect([3, 4] == matrix.rows[1]) | ||
} | ||
|
||
func testExtractRowWhereNumbersHaveDifferentWidths() throws { | ||
try XCTSkipIf(true && !runAll) // change true to false to run this test | ||
@Test("extract row where numbers have different widths", .enabled(if: RUNALL)) | ||
func testExtractRowWhereNumbersHaveDifferentWidths() { | ||
let matrix = Matrix("1 2\n10 20") | ||
XCTAssertEqual([10, 20], matrix.rows[1]) | ||
#expect([10, 20] == matrix.rows[1]) | ||
} | ||
|
||
func testCanExtractRowFromNonSquareMatrixWithNoCorrespondingColumn() throws { | ||
try XCTSkipIf(true && !runAll) // change true to false to run this test | ||
@Test("can extract row from non-square matrix with no corresponding column", .enabled(if: RUNALL)) | ||
func testCanExtractRowFromNonSquareMatrixWithNoCorrespondingColumn() { | ||
let matrix = Matrix("1 2 3\n4 5 6\n7 8 9\n8 7 6") | ||
XCTAssertEqual([8, 7, 6], matrix.rows[3]) | ||
#expect([8, 7, 6] == matrix.rows[3]) | ||
} | ||
|
||
func testExtractColumnFromOneNumberMatrix() throws { | ||
try XCTSkipIf(true && !runAll) // change true to false to run this test | ||
@Test("extract column from one number matrix", .enabled(if: RUNALL)) | ||
func testExtractColumnFromOneNumberMatrix() { | ||
let matrix = Matrix("1") | ||
XCTAssertEqual([1], matrix.columns[0]) | ||
#expect([1] == matrix.columns[0]) | ||
} | ||
|
||
func testCanExtractColumn() throws { | ||
try XCTSkipIf(true && !runAll) // change true to false to run this test | ||
@Test("can extract column", .enabled(if: RUNALL)) | ||
func testCanExtractColumn() { | ||
let matrix = Matrix("1 2 3\n4 5 6\n7 8 9") | ||
XCTAssertEqual([3, 6, 9], matrix.columns[2]) | ||
#expect([3, 6, 9] == matrix.columns[2]) | ||
} | ||
|
||
func testCanExtractColumnFromNonSquareMatrixWithNoCorrespondingRow() throws { | ||
try XCTSkipIf(true && !runAll) // change true to false to run this test | ||
@Test("can extract column from non-square matrix with no corresponding row", .enabled(if: RUNALL)) | ||
func testCanExtractColumnFromNonSquareMatrixWithNoCorrespondingRow() { | ||
let matrix = Matrix("1 2 3 4\n5 6 7 8\n9 8 7 6") | ||
XCTAssertEqual([4, 8, 6], matrix.columns[3]) | ||
#expect([4, 8, 6] == matrix.columns[3]) | ||
} | ||
|
||
func testExtractColumnWhereNumbersHaveDifferentWidths() throws { | ||
try XCTSkipIf(true && !runAll) // change true to false to run this test | ||
@Test("extract column where numbers have different widths", .enabled(if: RUNALL)) | ||
func testExtractColumnWhereNumbersHaveDifferentWidths() { | ||
let matrix = Matrix("89 1903 3\n18 3 1\n9 4 800") | ||
XCTAssertEqual([1903, 3, 4], matrix.columns[1]) | ||
#expect([1903, 3, 4] == matrix.columns[1]) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,17 +1,19 @@ | ||
import XCTest | ||
import Testing | ||
import Foundation | ||
@testable import {{exercise|camelCase}} | ||
class {{exercise|camelCase}}Tests: XCTestCase { | ||
let runAll = Bool(ProcessInfo.processInfo.environment["RUNALL", default: "false"]) ?? false | ||
|
||
let RUNALL = Bool(ProcessInfo.processInfo.environment["RUNALL", default: "false"]) ?? false | ||
|
||
@Suite struct {{exercise|camelCase}}Tests { | ||
{% for case in cases %} | ||
{% if forloop.first -%} | ||
func test{{case.description |camelCase }}() { | ||
@Test("{{case.description}}") | ||
{% else -%} | ||
func test{{case.description |camelCase }}() throws { | ||
try XCTSkipIf(true && !runAll) // change true to false to run this test | ||
@Test("{{case.description}}", .enabled(if: RUNALL)) | ||
{% endif -%} | ||
func test{{case.description |camelCase }}() { | ||
let meetUp = Meetup(year: {{case.input.year}}, month: {{case.input.month}}, week: "{{case.input.week}}", weekday: "{{case.input.dayofweek}}") | ||
XCTAssertEqual(meetUp.description, "{{case.expected}}") | ||
#expect(meetUp.description == "{{case.expected}}") | ||
} | ||
{% endfor -%} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,4 @@ | ||
// swift-tools-version:5.3 | ||
// swift-tools-version:6.0 | ||
|
||
import PackageDescription | ||
|
||
|
Oops, something went wrong.