File tree Expand file tree Collapse file tree 1 file changed +12
-4
lines changed Expand file tree Collapse file tree 1 file changed +12
-4
lines changed Original file line number Diff line number Diff line change @@ -19,24 +19,32 @@ import SwiftXCTest
19
19
20
20
class TestNSPipe : XCTestCase {
21
21
22
+ public var allTests : [ ( String , ( ) -> ( ) ) ] {
23
+ return [
24
+ ( " test_NSPipe " , test_NSPipe)
25
+ ]
26
+ }
27
+
22
28
func test_NSPipe( ) {
23
29
let aPipe = NSPipe ( )
24
30
let text = " test-pipe "
25
31
26
32
// 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!)
28
36
29
37
// Then read it out again
30
38
let data = aPipe. fileHandleForReading. readDataOfLength ( text. characters. count)
31
39
32
- // Make sure we * did* get data
40
+ // Confirm that we did read data
33
41
XCTAssertNotNil ( data)
34
42
35
- // Make sure the data can be converted
43
+ // Confirm the data can be converted to a String
36
44
let convertedData = String ( data: data, encoding: NSUTF8StringEncoding)
37
45
XCTAssertNotNil ( convertedData)
38
46
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
40
48
XCTAssertEqual ( text, convertedData)
41
49
}
42
50
}
You can’t perform that action at this time.
0 commit comments