@@ -94,11 +94,23 @@ final class ReplaceSubrangeTests: XCTestCase {
9494
9595 func testInsert( ) {
9696
97- let base = 0 ..< 10
98- let i = base. index ( base. startIndex, offsetBy: 5 )
99- let result = base. lazy. replacingSubrange ( i..< i, with: 20 ..< 25 )
100- XCTAssertEqualCollections ( result, [ 0 , 1 , 2 , 3 , 4 , 20 , 21 , 22 , 23 , 24 , 5 , 6 , 7 , 8 , 9 ] )
101- IndexValidator ( ) . validate ( result, expectedCount: 15 )
97+ // Inserting: non-empty
98+ do {
99+ let base = 0 ..< 10
100+ let i = base. index ( base. startIndex, offsetBy: 5 )
101+ let result = base. lazy. replacingSubrange ( i..< i, with: 20 ..< 25 )
102+ XCTAssertEqualCollections ( result, [ 0 , 1 , 2 , 3 , 4 , 20 , 21 , 22 , 23 , 24 , 5 , 6 , 7 , 8 , 9 ] )
103+ IndexValidator ( ) . validate ( result, expectedCount: 15 )
104+ }
105+
106+ // Inserting: empty
107+ do {
108+ let base = 0 ..< 10
109+ let i = base. index ( base. startIndex, offsetBy: 5 )
110+ let result = base. lazy. replacingSubrange ( i..< i, with: EmptyCollection ( ) )
111+ XCTAssertEqualCollections ( result, [ 0 , 1 , 2 , 3 , 4 , 5 , 6 , 7 , 8 , 9 ] )
112+ IndexValidator ( ) . validate ( result, expectedCount: 10 )
113+ }
102114 }
103115
104116 func testReplace( ) {
0 commit comments