|
1 | | -import XCTest |
| 1 | +import Foundation |
| 2 | +import Testing |
2 | 3 |
|
3 | 4 | @testable import Matrix |
4 | 5 |
|
5 | | -class MatrixTests: XCTestCase { |
6 | | - let runAll = Bool(ProcessInfo.processInfo.environment["RUNALL", default: "false"]) ?? false |
| 6 | +let RUNALL = Bool(ProcessInfo.processInfo.environment["RUNALL", default: "false"]) ?? false |
7 | 7 |
|
| 8 | +@Suite struct MatrixTests { |
| 9 | + |
| 10 | + @Test("extract row from one number matrix") |
8 | 11 | func testExtractRowFromOneNumberMatrix() { |
9 | 12 | let matrix = Matrix("1") |
10 | | - XCTAssertEqual([1], matrix.rows[0]) |
| 13 | + #expect([1] == matrix.rows[0]) |
11 | 14 | } |
12 | 15 |
|
13 | | - func testCanExtractRow() throws { |
14 | | - try XCTSkipIf(true && !runAll) // change true to false to run this test |
| 16 | + @Test("can extract row", .enabled(if: RUNALL)) |
| 17 | + func testCanExtractRow() { |
15 | 18 | let matrix = Matrix("1 2\n3 4") |
16 | | - XCTAssertEqual([3, 4], matrix.rows[1]) |
| 19 | + #expect([3, 4] == matrix.rows[1]) |
17 | 20 | } |
18 | 21 |
|
19 | | - func testExtractRowWhereNumbersHaveDifferentWidths() throws { |
20 | | - try XCTSkipIf(true && !runAll) // change true to false to run this test |
| 22 | + @Test("extract row where numbers have different widths", .enabled(if: RUNALL)) |
| 23 | + func testExtractRowWhereNumbersHaveDifferentWidths() { |
21 | 24 | let matrix = Matrix("1 2\n10 20") |
22 | | - XCTAssertEqual([10, 20], matrix.rows[1]) |
| 25 | + #expect([10, 20] == matrix.rows[1]) |
23 | 26 | } |
24 | 27 |
|
25 | | - func testCanExtractRowFromNonSquareMatrixWithNoCorrespondingColumn() throws { |
26 | | - try XCTSkipIf(true && !runAll) // change true to false to run this test |
| 28 | + @Test("can extract row from non-square matrix with no corresponding column", .enabled(if: RUNALL)) |
| 29 | + func testCanExtractRowFromNonSquareMatrixWithNoCorrespondingColumn() { |
27 | 30 | let matrix = Matrix("1 2 3\n4 5 6\n7 8 9\n8 7 6") |
28 | | - XCTAssertEqual([8, 7, 6], matrix.rows[3]) |
| 31 | + #expect([8, 7, 6] == matrix.rows[3]) |
29 | 32 | } |
30 | 33 |
|
31 | | - func testExtractColumnFromOneNumberMatrix() throws { |
32 | | - try XCTSkipIf(true && !runAll) // change true to false to run this test |
| 34 | + @Test("extract column from one number matrix", .enabled(if: RUNALL)) |
| 35 | + func testExtractColumnFromOneNumberMatrix() { |
33 | 36 | let matrix = Matrix("1") |
34 | | - XCTAssertEqual([1], matrix.columns[0]) |
| 37 | + #expect([1] == matrix.columns[0]) |
35 | 38 | } |
36 | 39 |
|
37 | | - func testCanExtractColumn() throws { |
38 | | - try XCTSkipIf(true && !runAll) // change true to false to run this test |
| 40 | + @Test("can extract column", .enabled(if: RUNALL)) |
| 41 | + func testCanExtractColumn() { |
39 | 42 | let matrix = Matrix("1 2 3\n4 5 6\n7 8 9") |
40 | | - XCTAssertEqual([3, 6, 9], matrix.columns[2]) |
| 43 | + #expect([3, 6, 9] == matrix.columns[2]) |
41 | 44 | } |
42 | 45 |
|
43 | | - func testCanExtractColumnFromNonSquareMatrixWithNoCorrespondingRow() throws { |
44 | | - try XCTSkipIf(true && !runAll) // change true to false to run this test |
| 46 | + @Test("can extract column from non-square matrix with no corresponding row", .enabled(if: RUNALL)) |
| 47 | + func testCanExtractColumnFromNonSquareMatrixWithNoCorrespondingRow() { |
45 | 48 | let matrix = Matrix("1 2 3 4\n5 6 7 8\n9 8 7 6") |
46 | | - XCTAssertEqual([4, 8, 6], matrix.columns[3]) |
| 49 | + #expect([4, 8, 6] == matrix.columns[3]) |
47 | 50 | } |
48 | 51 |
|
49 | | - func testExtractColumnWhereNumbersHaveDifferentWidths() throws { |
50 | | - try XCTSkipIf(true && !runAll) // change true to false to run this test |
| 52 | + @Test("extract column where numbers have different widths", .enabled(if: RUNALL)) |
| 53 | + func testExtractColumnWhereNumbersHaveDifferentWidths() { |
51 | 54 | let matrix = Matrix("89 1903 3\n18 3 1\n9 4 800") |
52 | | - XCTAssertEqual([1903, 3, 4], matrix.columns[1]) |
| 55 | + #expect([1903, 3, 4] == matrix.columns[1]) |
53 | 56 | } |
54 | 57 | } |
0 commit comments