@@ -94,11 +94,23 @@ final class ReplaceSubrangeTests: XCTestCase {
94
94
95
95
func testInsert( ) {
96
96
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
+ }
102
114
}
103
115
104
116
func testReplace( ) {
0 commit comments