File tree Expand file tree Collapse file tree 1 file changed +23
-1
lines changed Expand file tree Collapse file tree 1 file changed +23
-1
lines changed Original file line number Diff line number Diff line change @@ -429,7 +429,15 @@ class TestNSURL : XCTestCase {
429
429
XCTAssertEqual ( true , try ? url. checkResourceIsReachable ( ) )
430
430
431
431
url = URL ( string: " https://www.swift.org " ) !
432
- XCTAssertEqual ( false , try ? url. checkResourceIsReachable ( ) )
432
+ do {
433
+ _ = try url. checkResourceIsReachable ( )
434
+ XCTFail ( )
435
+ } catch let error as NSError {
436
+ XCTAssertEqual ( NSCocoaErrorDomain, error. domain)
437
+ XCTAssertEqual ( CocoaError . Code. fileNoSuchFile. rawValue, error. code)
438
+ } catch {
439
+ XCTFail ( )
440
+ }
433
441
434
442
url = URL ( fileURLWithPath: " /some_random_path " )
435
443
do {
@@ -441,6 +449,20 @@ class TestNSURL : XCTestCase {
441
449
} catch {
442
450
XCTFail ( )
443
451
}
452
+
453
+ var nsURL : NSURL ? = NSURL ( fileURLWithPath: " /usr " )
454
+ var error : NSError ?
455
+ XCTAssertEqual ( true , nsURL? . checkResourceIsReachableAndReturnError ( & error) )
456
+ XCTAssertNil ( error)
457
+
458
+ nsURL = NSURL ( string: " https://www.swift.org " )
459
+ XCTAssertEqual ( false , nsURL? . checkResourceIsReachableAndReturnError ( & error) )
460
+ XCTAssertNotNil ( error)
461
+ error = nil
462
+
463
+ nsURL = NSURL ( fileURLWithPath: " /some_random_path " )
464
+ XCTAssertEqual ( false , nsURL? . checkResourceIsReachableAndReturnError ( & error) )
465
+ XCTAssertNotNil ( error)
444
466
}
445
467
446
468
func test_copy( ) {
You can’t perform that action at this time.
0 commit comments