@@ -87,6 +87,7 @@ class TestNSData: XCTestCase {
87
87
( " test_rangeOfData " , test_rangeOfData) ,
88
88
( " test_initMutableDataWithLength " , test_initMutableDataWithLength) ,
89
89
( " test_replaceBytes " , test_replaceBytes) ,
90
+ ( " test_replaceBytesWithNil " , test_replaceBytesWithNil) ,
90
91
( " test_initDataWithCapacity " , test_initDataWithCapacity) ,
91
92
( " test_initDataWithCount " , test_initDataWithCount) ,
92
93
( " test_emptyStringToData " , test_emptyStringToData) ,
@@ -426,6 +427,17 @@ class TestNSData: XCTestCase {
426
427
XCTAssertEqual ( mData, expected)
427
428
}
428
429
430
+ func test_replaceBytesWithNil( ) {
431
+ func makeData( _ data: [ UInt8 ] ) -> NSMutableData {
432
+ return NSMutableData ( bytes: data, length: data. count)
433
+ }
434
+
435
+ let mData = makeData ( [ 1 , 2 , 3 , 4 , 5 ] )
436
+ mData. replaceBytes ( in: NSMakeRange ( 1 , 3 ) , withBytes: nil , length: 0 )
437
+ let expected = makeData ( [ 1 , 5 ] )
438
+ XCTAssertEqual ( mData, expected)
439
+ }
440
+
429
441
func test_initDataWithCapacity( ) {
430
442
let data = Data ( capacity: 123 )
431
443
XCTAssertEqual ( data. count, 0 )
0 commit comments