@@ -98,6 +98,9 @@ class TestNSBundle : XCTestCase {
9898
9999 private let _bundleName = " MyBundle.bundle "
100100 private let _bundleResourceNames = [ " hello.world " , " goodbye.world " , " swift.org " ]
101+ private let _subDirectory = " Sources "
102+ private let _main = " main "
103+ private let _type = " swift "
101104
102105 private func _setupPlayground( ) -> String ? {
103106 // Make sure the directory is uniquely named
@@ -114,6 +117,10 @@ class TestNSBundle : XCTestCase {
114117 for n in _bundleResourceNames {
115118 NSFileManager . defaultManager ( ) . createFileAtPath ( bundlePath + " / " + n, contents: nil , attributes: nil )
116119 }
120+ // Add a resource into a subdirectory
121+ let subDirPath = bundlePath + " / " + _subDirectory
122+ try NSFileManager . defaultManager ( ) . createDirectoryAtPath ( subDirPath, withIntermediateDirectories: false , attributes: nil )
123+ NSFileManager . defaultManager ( ) . createFileAtPath ( subDirPath + " / " + _main + " . " + _type, contents: nil , attributes: nil )
117124 } catch _ {
118125 return nil
119126 }
@@ -140,6 +147,9 @@ class TestNSBundle : XCTestCase {
140147 XCTAssertNotNil ( worldResources)
141148 XCTAssertEqual ( worldResources? . count, 2 )
142149
150+ let path = bundle? . pathForResource ( _main, ofType: _type, inDirectory: _subDirectory)
151+ XCTAssertNotNil ( path)
152+
143153 _cleanupPlayground ( playground)
144154 }
145155}
0 commit comments