-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Migrate tests to swift-testing (#22)
The tests were migrated to swift-testing because it is supported on Windows unlike Nimble. Furthermore, I added a job for running the tests on Windows to the pipeline. Since the project does not rely anymore on Quick and Nimble for the tests, I removed the packages. swift-testing does not have to be included as dependency. I removed SwiftDependencyGraphsTests because the file was generated by XCode or SwiftPM and I did not use it. I split ContainsVertexWithTests.swift since I found the file too big and I lost the overview. Closes #15 See pull request #22
- Loading branch information
Showing
9 changed files
with
142 additions
and
214 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
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
24 changes: 24 additions & 0 deletions
24
Tests/SwiftDependencyGraphsTests/ContainsTests/C4ContainsVertexTests.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 |
---|---|---|
@@ -0,0 +1,24 @@ | ||
import Testing | ||
|
||
@testable import DependencyGraphs | ||
|
||
@Suite("C4 with vertices v1, v2, v3 and v4") struct C4ContainsVertexTests { | ||
@Test("contains the vertex v1") func v1() { | ||
#expect(TestGraph.directedC4().contains(vertex: vertex1) == true) | ||
} | ||
|
||
@Test("does not contain the vertex v5") func notV5() { | ||
#expect(TestGraph.directedC4().contains(vertex: vertex5) == false) | ||
} | ||
|
||
@Test("contains the vertex v1' with v1' ≠ v1 and v1'.id = v1.id") func id1() { | ||
let vertexWithId1 = Vertex(id: vertex1.id, label: "not 1") | ||
#expect(TestGraph.directedC4().contains(vertex: vertexWithId1) == true) | ||
} | ||
|
||
@Test("does not contain the vertex v1' with v1' ≠ v1 and v1'.label = v1.label") func notLabel1() { | ||
// C4 has only vertices with the ids 1, 2, 3 and 4. | ||
let vertexWithLabel1 = Vertex(id: 5, label: "1") | ||
#expect(TestGraph.directedC4().contains(vertex: vertexWithLabel1) == false) | ||
} | ||
} |
37 changes: 37 additions & 0 deletions
37
Tests/SwiftDependencyGraphsTests/ContainsTests/C4ContainsVertexWithTests.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 |
---|---|---|
@@ -0,0 +1,37 @@ | ||
import Testing | ||
|
||
@testable import DependencyGraphs | ||
|
||
@Suite("C4 with vertices v1, v2, v3 and v4") struct C4ContainsVertexWithTests { | ||
@Test("contains a vertex with an odd id") func oddId() { | ||
#expect( | ||
TestGraph.directedC4().contains(vertexWith: { vertexInGraph in | ||
!vertexInGraph.id.isMultiple(of: 2) | ||
}) == true | ||
) | ||
} | ||
|
||
@Test("does not contain a vertex with an id that is divisible by 5") func notDivisibleBy5() { | ||
#expect( | ||
TestGraph.directedC4().contains(vertexWith: { vertexInGraph in | ||
vertexInGraph.id.isMultiple(of: 5) | ||
}) == false | ||
) | ||
} | ||
|
||
@Test("contains a vertex with a label that starts with 3") func labelStartsWith3() { | ||
#expect( | ||
TestGraph.directedC4().contains(vertexWith: { vertexInGraph in | ||
vertexInGraph.label.starts(with: "3") | ||
}) == true | ||
) | ||
} | ||
|
||
@Test("does not contain a vertex with a label that ends with .") func labelEndsWithDot() { | ||
#expect( | ||
TestGraph.directedC4().contains(vertexWith: { vertexInGraph in | ||
vertexInGraph.label.hasSuffix(".") | ||
}) == false | ||
) | ||
} | ||
} |
25 changes: 25 additions & 0 deletions
25
Tests/SwiftDependencyGraphsTests/ContainsTests/EmptyGraph.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 |
---|---|---|
@@ -0,0 +1,25 @@ | ||
import Testing | ||
|
||
@testable import DependencyGraphs | ||
|
||
@Suite("the empty graph") struct ContainsVertexWithTests { | ||
|
||
@Test("does not contain the vertex v") func notVertexV() { | ||
#expect(TestGraph.empty.contains(vertex: vertex1) == false) | ||
} | ||
|
||
@Test("does not contain a vertex with an even id") func notEvenId() { | ||
#expect( | ||
TestGraph.empty.contains(vertexWith: { vertexInGraph in vertexInGraph.id.isMultiple(of: 2) | ||
}) == false | ||
) | ||
} | ||
|
||
@Test("does not contain a vertex with a label that starts with a") func notLabelA() { | ||
#expect( | ||
TestGraph.empty.contains(vertexWith: { vertexInGraph in | ||
vertexInGraph.label.starts(with: "a") | ||
}) == false | ||
) | ||
} | ||
} |
91 changes: 0 additions & 91 deletions
91
Tests/SwiftDependencyGraphsTests/ContainsVertexWithTests.swift
This file was deleted.
Oops, something went wrong.
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,58 +1,48 @@ | ||
import Nimble | ||
import Quick | ||
import Testing | ||
|
||
@testable import DependencyGraphs | ||
|
||
class DfsPathTests: QuickSpec { | ||
override class func spec() { | ||
describe("starting from vertex 1 in forwards direction") { | ||
describe("visits all vertices") { | ||
it("with the public method") { | ||
expect( | ||
TestGraph.path().depthFirstSearch( | ||
startingFrom: vertex1, in: .forwards, reduceWith: appendReducer, withInitialValue: [] | ||
) | ||
) | ||
.to(equal([vertex1, vertex2, vertex3, vertex4, vertex5])) | ||
} | ||
@Suite("starting from vertex 1 in forwards direction") struct DfsPathTests { | ||
@Suite("visits all vertices") struct VisitAllVerticesTests { | ||
@Test("with the public method") func dfs() { | ||
#expect( | ||
TestGraph.path().depthFirstSearch( | ||
startingFrom: vertex1, in: .forwards, reduceWith: appendReducer, withInitialValue: [] | ||
) | ||
== [vertex1, vertex2, vertex3, vertex4, vertex5]) | ||
} | ||
|
||
it("with the private method") { | ||
expect( | ||
TestGraph.path().depthFirstSearchImpl( | ||
startingFrom: vertex1, in: .forwards, withVisited: [], reduceWith: appendReducer, | ||
withInitialValue: []) | ||
) | ||
.to(equal([vertex1, vertex2, vertex3, vertex4, vertex5])) | ||
} | ||
} | ||
@Test("with the private method") func dfsImpl() { | ||
#expect( | ||
TestGraph.path().depthFirstSearchImpl( | ||
startingFrom: vertex1, in: .forwards, withVisited: [], reduceWith: appendReducer, | ||
withInitialValue: []) | ||
== [vertex1, vertex2, vertex3, vertex4, vertex5]) | ||
} | ||
} | ||
|
||
it("stops at 2 because 3 was already discovered") { | ||
expect( | ||
TestGraph.path().depthFirstSearchImpl( | ||
startingFrom: vertex1, in: .forwards, withVisited: [vertex3], | ||
reduceWith: appendReducer, withInitialValue: []) | ||
) | ||
.to(equal([vertex1, vertex2])) | ||
} | ||
@Test("stops at 2 because 3 was already discovered") func stops() { | ||
#expect( | ||
TestGraph.path().depthFirstSearchImpl( | ||
startingFrom: vertex1, in: .forwards, withVisited: [vertex3], | ||
reduceWith: appendReducer, withInitialValue: []) | ||
== [vertex1, vertex2]) | ||
} | ||
|
||
it("visits no vertices because all were already discovered") { | ||
expect( | ||
TestGraph.path().depthFirstSearchImpl( | ||
startingFrom: vertex1, in: .forwards, | ||
withVisited: [vertex1, vertex2, vertex3, vertex4, vertex5], | ||
reduceWith: appendReducer, withInitialValue: emptyVertexList) | ||
) | ||
.to(equal([])) | ||
} | ||
@Test("visits no vertices because all were already discovered") func allDiscovered() { | ||
#expect( | ||
TestGraph.path().depthFirstSearchImpl( | ||
startingFrom: vertex1, in: .forwards, | ||
withVisited: [vertex1, vertex2, vertex3, vertex4, vertex5], | ||
reduceWith: appendReducer, withInitialValue: emptyVertexList) | ||
== []) | ||
} | ||
|
||
it("visits no vertices because 1 was already discovered") { | ||
expect( | ||
TestGraph.path().depthFirstSearchImpl( | ||
startingFrom: vertex1, in: .forwards, withVisited: [vertex1], | ||
reduceWith: appendReducer, withInitialValue: emptyVertexList) | ||
) | ||
.to(equal([])) | ||
} | ||
} | ||
@Test("visits no vertices because 1 was already discovered") func nextDiscovered() { | ||
#expect( | ||
TestGraph.path().depthFirstSearchImpl( | ||
startingFrom: vertex1, in: .forwards, withVisited: [vertex1], | ||
reduceWith: appendReducer, withInitialValue: emptyVertexList) | ||
== []) | ||
} | ||
} |
Oops, something went wrong.