@@ -98,6 +98,9 @@ class TestNSBundle : XCTestCase {
98
98
99
99
private let _bundleName = " MyBundle.bundle "
100
100
private let _bundleResourceNames = [ " hello.world " , " goodbye.world " , " swift.org " ]
101
+ private let _subDirectory = " Sources "
102
+ private let _main = " main "
103
+ private let _type = " swift "
101
104
102
105
private func _setupPlayground( ) -> String ? {
103
106
// Make sure the directory is uniquely named
@@ -114,6 +117,10 @@ class TestNSBundle : XCTestCase {
114
117
for n in _bundleResourceNames {
115
118
NSFileManager . defaultManager ( ) . createFileAtPath ( bundlePath + " / " + n, contents: nil , attributes: nil )
116
119
}
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 )
117
124
} catch _ {
118
125
return nil
119
126
}
@@ -140,6 +147,9 @@ class TestNSBundle : XCTestCase {
140
147
XCTAssertNotNil ( worldResources)
141
148
XCTAssertEqual ( worldResources? . count, 2 )
142
149
150
+ let path = bundle? . pathForResource ( _main, ofType: _type, inDirectory: _subDirectory)
151
+ XCTAssertNotNil ( path)
152
+
143
153
_cleanupPlayground ( playground)
144
154
}
145
155
}
0 commit comments