File tree 1 file changed +3
-5
lines changed
1 file changed +3
-5
lines changed Original file line number Diff line number Diff line change @@ -481,16 +481,15 @@ class TestFileHandle : XCTestCase {
481
481
482
482
func test_readToEndOfFileAndNotify( ) {
483
483
let handle = createFileHandle ( )
484
- var readSomeData = false
485
-
484
+ let readSomeData = XCTestExpectation ( description: " At least some data must've been read " )
486
485
let done = expectation ( forNotification: FileHandle . readCompletionNotification, object: handle, notificationCenter: . default) { ( notification) -> Bool in
487
486
guard let data = notification. userInfo ? [ NSFileHandleNotificationDataItem] as? Data else {
488
487
XCTFail ( " Couldn't find the data in the user info: \( notification) " )
489
488
return true
490
489
}
491
490
492
491
if !data. isEmpty {
493
- readSomeData = true
492
+ readSomeData. fulfill ( )
494
493
handle. readInBackgroundAndNotify ( )
495
494
return false
496
495
} else {
@@ -500,8 +499,7 @@ class TestFileHandle : XCTestCase {
500
499
501
500
handle. readInBackgroundAndNotify ( )
502
501
503
- wait ( for: [ done] , timeout: 10 )
504
- XCTAssertTrue ( readSomeData, " At least some data must've been read " )
502
+ wait ( for: [ readSomeData, done] , timeout: 10 )
505
503
}
506
504
507
505
func test_readToEndOfFileAndNotify_readError( ) {
You can’t perform that action at this time.
0 commit comments