@@ -3807,6 +3807,34 @@ class TestData : TestDataSuper {
3807
3807
let range = slice. range ( of: " a " . data ( using: . ascii) !)
3808
3808
expectEqual ( range, Range < Data . Index > ( 4 ..< 5 ) )
3809
3809
}
3810
+
3811
+ func test_nsdataSequence( ) {
3812
+ let bytes : [ UInt8 ] = Array ( 0x00 ... 0xFF )
3813
+ let data = bytes. withUnsafeBytes { NSData ( bytes: $0. baseAddress, length: $0. count) }
3814
+
3815
+ for byte in bytes {
3816
+ expectEqual ( data [ Int ( byte) ] , byte)
3817
+ }
3818
+ }
3819
+
3820
+ func test_dispatchSequence( ) {
3821
+ let bytes1 : [ UInt8 ] = Array ( 0x00 ..< 0xF0 )
3822
+ let bytes2 : [ UInt8 ] = Array ( 0xF0 ..< 0xFF )
3823
+ var data = DispatchData . empty
3824
+ bytes1. withUnsafeBytes {
3825
+ data. append ( $0)
3826
+ }
3827
+ bytes2. withUnsafeBytes {
3828
+ data. append ( $0)
3829
+ }
3830
+
3831
+ for byte in bytes1 {
3832
+ expectEqual ( data [ Int ( byte) ] , byte)
3833
+ }
3834
+ for byte in bytes2 {
3835
+ expectEqual ( data [ Int ( byte) ] , byte)
3836
+ }
3837
+ }
3810
3838
}
3811
3839
3812
3840
#if !FOUNDATION_XCTEST
@@ -4126,6 +4154,9 @@ DataTests.test("test_validateMutation_slice_customBacking_withUnsafeMutableBytes
4126
4154
DataTests . test ( " test_validateMutation_slice_customMutableBacking_withUnsafeMutableBytes_lengthLessThanLowerBound " ) { TestData ( ) . test_validateMutation_slice_customMutableBacking_withUnsafeMutableBytes_lengthLessThanLowerBound ( ) }
4127
4155
DataTests . test ( " test_byte_access_of_discontiguousData " ) { TestData ( ) . test_byte_access_of_discontiguousData ( ) }
4128
4156
DataTests . test ( " test_rangeOfSlice " ) { TestData ( ) . test_rangeOfSlice ( ) }
4157
+ DataTests . test ( " test_nsdataSequence " ) { TestData ( ) . test_nsdataSequence ( ) }
4158
+ DataTests . test ( " test_dispatchSequence " ) { TestData ( ) . test_dispatchSequence ( ) }
4159
+
4129
4160
4130
4161
// XCTest does not have a crash detection, whereas lit does
4131
4162
DataTests . test ( " bounding failure subdata " ) {
0 commit comments