Skip to content

Commit

Permalink
Add tests for replacing the entire base collection
Browse files Browse the repository at this point in the history
  • Loading branch information
karwa committed Sep 9, 2023
1 parent 799bc7c commit 01c73b8
Showing 1 changed file with 18 additions and 0 deletions.
18 changes: 18 additions & 0 deletions Tests/SwiftAlgorithmsTests/ReplaceSubrangeTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -176,5 +176,23 @@ final class ReplaceSubrangeTests: XCTestCase {
XCTAssertEqualCollections(result, "hello, wo")
IndexValidator().validate(result, expectedCount: 9)
}

// Location: entire collection
// Replacement: non-empty
do {
let base = "hello, world!"
let result = base.lazy.replacingSubrange(base.startIndex..<base.endIndex, with: Array("blah blah blah"))
XCTAssertEqualCollections(result, "blah blah blah")
IndexValidator().validate(result, expectedCount: 14)
}

// Location: entire collection
// Replacement: empty
do {
let base = "hello, world!"
let result = base.lazy.replacingSubrange(base.startIndex..<base.endIndex, with: EmptyCollection())
XCTAssertEqualCollections(result, "")
IndexValidator().validate(result, expectedCount: 0)
}
}
}

0 comments on commit 01c73b8

Please sign in to comment.