Skip to content

Commit 658a237

Browse files
committed
TestData.swift fails when backporting to pre-macOS10.15/iOS13
1 parent af82665 commit 658a237

File tree

1 file changed

+26
-21
lines changed

1 file changed

+26
-21
lines changed

Darwin/Foundation-swiftoverlay-Tests/TestData.swift

Lines changed: 26 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -3806,30 +3806,34 @@ class TestData : TestDataSuper {
38063806
}
38073807

38083808
func test_nsdataSequence() {
3809-
let bytes: [UInt8] = Array(0x00...0xFF)
3810-
let data = bytes.withUnsafeBytes { NSData(bytes: $0.baseAddress, length: $0.count) }
3809+
if #available(macOS 10.15, iOS 13, tvOS 13, watchOS 6, *) {
3810+
let bytes: [UInt8] = Array(0x00...0xFF)
3811+
let data = bytes.withUnsafeBytes { NSData(bytes: $0.baseAddress, length: $0.count) }
38113812

3812-
for byte in bytes {
3813-
expectEqual(data[Int(byte)], byte)
3813+
for byte in bytes {
3814+
expectEqual(data[Int(byte)], byte)
3815+
}
38143816
}
38153817
}
38163818

38173819
func test_dispatchSequence() {
3818-
let bytes1: [UInt8] = Array(0x00..<0xF0)
3819-
let bytes2: [UInt8] = Array(0xF0..<0xFF)
3820-
var data = DispatchData.empty
3821-
bytes1.withUnsafeBytes {
3822-
data.append($0)
3823-
}
3824-
bytes2.withUnsafeBytes {
3825-
data.append($0)
3826-
}
3820+
if #available(macOS 10.15, iOS 13, tvOS 13, watchOS 6, *) {
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+
}
38273830

3828-
for byte in bytes1 {
3829-
expectEqual(data[Int(byte)], byte)
3830-
}
3831-
for byte in bytes2 {
3832-
expectEqual(data[Int(byte)], byte)
3831+
for byte in bytes1 {
3832+
expectEqual(data[Int(byte)], byte)
3833+
}
3834+
for byte in bytes2 {
3835+
expectEqual(data[Int(byte)], byte)
3836+
}
38333837
}
38343838
}
38353839
}
@@ -4151,9 +4155,10 @@ DataTests.test("test_validateMutation_slice_customBacking_withUnsafeMutableBytes
41514155
DataTests.test("test_validateMutation_slice_customMutableBacking_withUnsafeMutableBytes_lengthLessThanLowerBound") { TestData().test_validateMutation_slice_customMutableBacking_withUnsafeMutableBytes_lengthLessThanLowerBound() }
41524156
DataTests.test("test_byte_access_of_discontiguousData") { TestData().test_byte_access_of_discontiguousData() }
41534157
DataTests.test("test_rangeOfSlice") { TestData().test_rangeOfSlice() }
4154-
DataTests.test("test_nsdataSequence") { TestData().test_nsdataSequence() }
4155-
DataTests.test("test_dispatchSequence") { TestData().test_dispatchSequence() }
4156-
4158+
if #available(macOS 10.15, iOS 13, tvOS 13, watchOS 6, *) {
4159+
DataTests.test("test_nsdataSequence") { TestData().test_nsdataSequence() }
4160+
DataTests.test("test_dispatchSequence") { TestData().test_dispatchSequence() }
4161+
}
41574162

41584163
// XCTest does not have a crash detection, whereas lit does
41594164
DataTests.test("bounding failure subdata") {

0 commit comments

Comments
 (0)