Skip to content

Commit dd5a49b

Browse files
mdznrMatt Zanchelli
authored andcommitted
Add partitioningIndex(where:) unit tests where all elements in a collection belong in one of the two partitions
1 parent 6b1c8e6 commit dd5a49b

File tree

1 file changed

+10
-0
lines changed

1 file changed

+10
-0
lines changed

Tests/SwiftAlgorithmsTests/PartitionTests.swift

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -102,6 +102,16 @@ final class PartitionTests: XCTestCase {
102102
XCTAssertEqual(b, input.endIndex)
103103
}
104104

105+
func testPartitioningIndexWithOneEmptyPartition() {
106+
let input: Range<Int> = (0 ..< 10)
107+
108+
let a = input.partitioningIndex(where: { $0 > 10 })
109+
XCTAssertEqual(a, input.endIndex)
110+
111+
let b = input.partitioningIndex(where: { $0 >= 0 })
112+
XCTAssertEqual(b, input.startIndex)
113+
}
114+
105115
func testPartitionWithSubrangeBidirectionalCollection() {
106116
for length in 10...20 {
107117
let a = Array(0..<length)

0 commit comments

Comments
 (0)