Skip to content

Commit 1b50c16

Browse files
committed
And more linux fixes - this time for unit tests
1 parent 7980e6c commit 1b50c16

File tree

1 file changed

+7
-7
lines changed

1 file changed

+7
-7
lines changed

TestFoundation/TestNSData.swift

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -64,9 +64,9 @@ class TestNSData: XCTestCase {
6464
// Copy the data to our new length buffer
6565
let newBuffer = malloc(newValue)!
6666
if newValue <= _length {
67-
memmove(newBuffer, ptr.baseAddress, newValue)
67+
memmove(newBuffer, ptr.baseAddress!, newValue)
6868
} else if newValue > _length {
69-
memmove(newBuffer, ptr.baseAddress, _length)
69+
memmove(newBuffer, ptr.baseAddress!, _length)
7070
memset(newBuffer + _length, 1, newValue - _length)
7171
}
7272
let bytePtr = newBuffer.bindMemory(to: UInt8.self, capacity: newValue)
@@ -84,7 +84,7 @@ class TestNSData: XCTestCase {
8484
// Need to allocate the buffer now.
8585
// It doesn't matter if the buffer is uniquely referenced or not here.
8686
let buffer = malloc(length)
87-
memset(buffer, 1, length)
87+
memset(buffer!, 1, length)
8888
let bytePtr = buffer!.bindMemory(to: UInt8.self, capacity: length)
8989
let result = UnsafeMutableBufferPointer(start: bytePtr, count: length)
9090
_pointer = result
@@ -97,10 +97,10 @@ class TestNSData: XCTestCase {
9797
let newBuffer = malloc(newBufferLength)
9898
if let ptr = _pointer {
9999
// Copy the existing data to the new box, then return its pointer
100-
memmove(newBuffer, ptr.baseAddress, newBufferLength)
100+
memmove(newBuffer!, ptr.baseAddress, newBufferLength)
101101
} else {
102102
// Set new data to 1s
103-
memset(newBuffer, 1, newBufferLength)
103+
memset(newBuffer!, 1, newBufferLength)
104104
}
105105
let bytePtr = newBuffer!.bindMemory(to: UInt8.self, capacity: newBufferLength)
106106
let result = UnsafeMutableBufferPointer(start: bytePtr, count: newBufferLength)
@@ -112,7 +112,7 @@ class TestNSData: XCTestCase {
112112
override func getBytes(_ buffer: UnsafeMutableRawPointer, length: Int) {
113113
if let d = _pointer {
114114
// Get the real data from the buffer
115-
memmove(buffer, d.baseAddress, length)
115+
memmove(buffer, d.baseAddress!, length)
116116
} else {
117117
// A more efficient implementation of getBytes in the case where no one has asked for our backing bytes
118118
memset(buffer, 1, length)
@@ -663,7 +663,7 @@ extension TestNSData {
663663

664664
// Create a home for our test data
665665
let x = NSString()
666-
let dirPath = try! (NSTemporaryDirectory().bridge()).stringByAppendingPathComponent(NSUUID().uuidString)
666+
let dirPath = (NSTemporaryDirectory().bridge()).stringByAppendingPathComponent(NSUUID().uuidString)
667667
try! FileManager.default.createDirectory(atPath: dirPath, withIntermediateDirectories: true, attributes: nil)
668668
let filePath = (dirPath.bridge()).stringByAppendingPathComponent("temp_file")
669669
guard FileManager.default.createFile(atPath: filePath, contents: nil, attributes: nil) else { XCTAssertTrue(false, "Unable to create temporary file"); return}

0 commit comments

Comments
 (0)