Skip to content

Commit 80a85e2

Browse files
committed
Updated the Unit Test
- Added `bridge()` to not rely on implicit bridging - Added `allTests` property - Updated Comments - Added assert for string to NSData conversion
1 parent d179350 commit 80a85e2

File tree

1 file changed

+12
-4
lines changed

1 file changed

+12
-4
lines changed

TestFoundation/TestNSPipe.swift

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -19,24 +19,32 @@ import SwiftXCTest
1919

2020
class TestNSPipe : XCTestCase {
2121

22+
public var allTests: [(String, () -> ())] {
23+
return [
24+
("test_NSPipe", test_NSPipe)
25+
]
26+
}
27+
2228
func test_NSPipe() {
2329
let aPipe = NSPipe()
2430
let text = "test-pipe"
2531

2632
// First write some data into the pipe
27-
aPipe.fileHandleForWriting.writeData(text.dataUsingEncoding(NSUTF8StringEncoding)!)
33+
let stringAsData = text.bridge().dataUsingEncoding(NSUTF8StringEncoding)
34+
XCTAssertNotNil(stringAsData)
35+
aPipe.fileHandleForWriting.writeData(stringAsData!)
2836

2937
// Then read it out again
3038
let data = aPipe.fileHandleForReading.readDataOfLength(text.characters.count)
3139

32-
// Make sure we *did* get data
40+
// Confirm that we did read data
3341
XCTAssertNotNil(data)
3442

35-
// Make sure the data can be converted
43+
// Confirm the data can be converted to a String
3644
let convertedData = String(data: data, encoding: NSUTF8StringEncoding)
3745
XCTAssertNotNil(convertedData)
3846

39-
// Make sure we did get back what we wrote in
47+
// Confirm the data written in is the same as the data we read
4048
XCTAssertEqual(text, convertedData)
4149
}
4250
}

0 commit comments

Comments
 (0)