@@ -805,14 +805,6 @@ class TestData : TestDataSuper {
805
805
object. verifier. reset ( )
806
806
expectTrue ( data. count == object. length)
807
807
expectFalse ( object. verifier. wasCopied, " Expected an invocation to copy " )
808
-
809
- object. verifier. reset ( )
810
- data. append ( " test " , count: 4 )
811
- expectTrue ( object. verifier. wasMutableCopied, " Expected an invocation to mutableCopy " )
812
-
813
- let d = data as NSData
814
- let preservedObjectness = d is ImmutableDataVerifier
815
- expectTrue ( preservedObjectness, " Expected ImmutableDataVerifier but got \( object_getClass ( d) ) " )
816
808
}
817
809
818
810
func test_basicMutableDataMutation( ) {
@@ -826,20 +818,6 @@ class TestData : TestDataSuper {
826
818
object. verifier. reset ( )
827
819
expectTrue ( data. count == object. length)
828
820
expectFalse ( object. verifier. wasCopied, " Expected an invocation to copy " )
829
-
830
- object. verifier. reset ( )
831
- data. append ( " test " , count: 4 )
832
- expectTrue ( object. verifier. wasMutableCopied, " Expected an invocation to mutableCopy " )
833
- object. verifier. dump ( )
834
-
835
- let d = data as NSData
836
- let preservedObjectness = d is ImmutableDataVerifier
837
- expectTrue ( preservedObjectness, " Expected ImmutableDataVerifier but got \( object_getClass ( d) ) " )
838
- }
839
-
840
- func test_roundTrip( ) {
841
- let data = returnsData ( )
842
- expectTrue ( identityOfData ( data) )
843
821
}
844
822
845
823
func test_passing( ) {
@@ -966,12 +944,13 @@ class TestData : TestDataSuper {
966
944
}
967
945
968
946
func test_noCopyBehavior( ) {
969
- let ptr = UnsafeMutableRawPointer ( bitPattern : 0x1 ) !
947
+ let ptr = UnsafeMutableRawPointer . allocate ( byteCount : 17 , alignment : 1 )
970
948
971
949
var deallocated = false
972
950
autoreleasepool {
973
- let data = Data ( bytesNoCopy: ptr, count: 1 , deallocator: . custom( { ( bytes, length) in
951
+ let data = Data ( bytesNoCopy: ptr, count: 17 , deallocator: . custom( { ( bytes, length) in
974
952
deallocated = true
953
+ ptr. deallocate ( )
975
954
} ) )
976
955
expectFalse ( deallocated)
977
956
let equal = data. withUnsafeBytes { ( bytes: UnsafePointer < UInt8 > ) -> Bool in
@@ -980,7 +959,6 @@ class TestData : TestDataSuper {
980
959
981
960
expectTrue ( equal)
982
961
}
983
-
984
962
expectTrue ( deallocated)
985
963
}
986
964
@@ -1013,10 +991,6 @@ class TestData : TestDataSuper {
1013
991
for i in 0 ..< d. count {
1014
992
for j in i..< d. count {
1015
993
let slice = d [ i..< j]
1016
- if i == 1 && j == 2 {
1017
- print ( " here " )
1018
-
1019
- }
1020
994
expectEqual ( slice. count, j - i, " where index range is \( i) ..< \( j) " )
1021
995
expectEqual ( slice. map { $0 } , a [ i..< j] . map { $0 } , " where index range is \( i) ..< \( j) " )
1022
996
expectEqual ( slice. startIndex, i, " where index range is \( i) ..< \( j) " )
@@ -3641,28 +3615,6 @@ class TestData : TestDataSuper {
3641
3615
expectEqual ( data, Data ( bytes: [ 4 , 5 , 6 , 7 , 0 , 0 ] ) )
3642
3616
}
3643
3617
3644
- func test_sliceEnumeration( ) {
3645
- var base = DispatchData . empty
3646
- let bytes : [ UInt8 ] = [ 0 , 1 , 2 , 3 , 4 ]
3647
- base. append ( bytes. withUnsafeBytes { DispatchData ( bytes: $0) } )
3648
- base. append ( bytes. withUnsafeBytes { DispatchData ( bytes: $0) } )
3649
- base. append ( bytes. withUnsafeBytes { DispatchData ( bytes: $0) } )
3650
- let data = ( ( base as AnyObject ) as! Data ) [ 3 ..< 11 ]
3651
- var regionRanges : [ Range < Int > ] = [ ]
3652
- var regionData : [ Data ] = [ ]
3653
- data. enumerateBytes { ( buffer, index, _) in
3654
- regionData. append ( Data ( bytes: buffer. baseAddress!, count: buffer. count) )
3655
- regionRanges. append ( index..< index + buffer. count)
3656
- }
3657
- expectEqual ( regionRanges. count, 3 )
3658
- expectEqual ( 3 ..< 5 , regionRanges [ 0 ] )
3659
- expectEqual ( 5 ..< 10 , regionRanges [ 1 ] )
3660
- expectEqual ( 10 ..< 11 , regionRanges [ 2 ] )
3661
- expectEqual ( Data ( bytes: [ 3 , 4 ] ) , regionData [ 0 ] ) //fails
3662
- expectEqual ( Data ( bytes: [ 0 , 1 , 2 , 3 , 4 ] ) , regionData [ 1 ] ) //passes
3663
- expectEqual ( Data ( bytes: [ 0 ] ) , regionData [ 2 ] ) //fails
3664
- }
3665
-
3666
3618
func test_hashEmptyData( ) {
3667
3619
let d1 = Data ( )
3668
3620
let h1 = d1. hashValue
@@ -3783,7 +3735,6 @@ DataTests.test("test_writeFailure") { TestData().test_writeFailure() }
3783
3735
DataTests . test ( " test_genericBuffers " ) { TestData ( ) . test_genericBuffers ( ) }
3784
3736
DataTests . test ( " test_basicDataMutation " ) { TestData ( ) . test_basicDataMutation ( ) }
3785
3737
DataTests . test ( " test_basicMutableDataMutation " ) { TestData ( ) . test_basicMutableDataMutation ( ) }
3786
- DataTests . test ( " test_roundTrip " ) { TestData ( ) . test_roundTrip ( ) }
3787
3738
DataTests . test ( " test_passing " ) { TestData ( ) . test_passing ( ) }
3788
3739
DataTests . test ( " test_bufferSizeCalculation " ) { TestData ( ) . test_bufferSizeCalculation ( ) }
3789
3740
DataTests . test ( " test_classForCoder " ) { TestData ( ) . test_classForCoder ( ) }
@@ -4056,7 +4007,6 @@ DataTests.test("test_validateMutation_slice_cow_customMutableBacking_replaceSubr
4056
4007
DataTests . test ( " test_validateMutation_slice_cow_customMutableBacking_replaceSubrangeWithBytes " ) { TestData ( ) . test_validateMutation_slice_cow_customMutableBacking_replaceSubrangeWithBytes ( ) }
4057
4008
DataTests . test ( " test_sliceHash " ) { TestData ( ) . test_sliceHash ( ) }
4058
4009
DataTests . test ( " test_slice_resize_growth " ) { TestData ( ) . test_slice_resize_growth ( ) }
4059
- DataTests . test ( " test_sliceEnumeration " ) { TestData ( ) . test_sliceEnumeration ( ) }
4060
4010
DataTests . test ( " test_hashEmptyData " ) { TestData ( ) . test_hashEmptyData ( ) }
4061
4011
DataTests . test ( " test_validateMutation_slice_withUnsafeMutableBytes_lengthLessThanLowerBound " ) { TestData ( ) . test_validateMutation_slice_withUnsafeMutableBytes_lengthLessThanLowerBound ( ) }
4062
4012
DataTests . test ( " test_validateMutation_slice_immutableBacking_withUnsafeMutableBytes_lengthLessThanLowerBound " ) { TestData ( ) . test_validateMutation_slice_immutableBacking_withUnsafeMutableBytes_lengthLessThanLowerBound ( ) }
0 commit comments