Skip to content

Commit 01c73b8

Browse files
committed
Add tests for replacing the entire base collection
1 parent 799bc7c commit 01c73b8

File tree

1 file changed

+18
-0
lines changed

1 file changed

+18
-0
lines changed

Tests/SwiftAlgorithmsTests/ReplaceSubrangeTests.swift

+18
Original file line numberDiff line numberDiff line change
@@ -176,5 +176,23 @@ final class ReplaceSubrangeTests: XCTestCase {
176176
XCTAssertEqualCollections(result, "hello, wo")
177177
IndexValidator().validate(result, expectedCount: 9)
178178
}
179+
180+
// Location: entire collection
181+
// Replacement: non-empty
182+
do {
183+
let base = "hello, world!"
184+
let result = base.lazy.replacingSubrange(base.startIndex..<base.endIndex, with: Array("blah blah blah"))
185+
XCTAssertEqualCollections(result, "blah blah blah")
186+
IndexValidator().validate(result, expectedCount: 14)
187+
}
188+
189+
// Location: entire collection
190+
// Replacement: empty
191+
do {
192+
let base = "hello, world!"
193+
let result = base.lazy.replacingSubrange(base.startIndex..<base.endIndex, with: EmptyCollection())
194+
XCTAssertEqualCollections(result, "")
195+
IndexValidator().validate(result, expectedCount: 0)
196+
}
179197
}
180198
}

0 commit comments

Comments
 (0)