@@ -29,6 +29,10 @@ class TestNSBundle : XCTestCase {
29
29
( " test_localizations " , test_localizations) ,
30
30
( " test_URLsForResourcesWithExtension " , test_URLsForResourcesWithExtension) ,
31
31
( " test_bundleLoad " , test_bundleLoad) ,
32
+ ( " test_bundleLoadWithError " , test_bundleLoadWithError) ,
33
+ ( " test_bundleWithInvalidPath " , test_bundleWithInvalidPath) ,
34
+ ( " test_bundlePreflight " , test_bundlePreflight) ,
35
+
32
36
]
33
37
}
34
38
@@ -153,10 +157,46 @@ class TestNSBundle : XCTestCase {
153
157
154
158
_cleanupPlayground ( playground)
155
159
}
160
+
156
161
func test_bundleLoad( ) {
157
162
let bundle = Bundle . main ( )
158
163
let _ = bundle. load ( )
159
164
XCTAssertTrue ( bundle. isLoaded)
160
165
}
166
+
167
+ func test_bundleLoadWithError( ) {
168
+ let bundleValid = NSBundle . mainBundle ( )
169
+ //test valid load using loadAndReturnError
170
+ do {
171
+ try bundleValid. loadAndReturnError ( )
172
+ } catch {
173
+ XCTFail ( " should not fail to load " )
174
+ }
175
+ // executable cannot be located
176
+ guard let playground = _setupPlayground ( ) else { XCTFail ( " Unable to create playground " ) ; return }
177
+ let bundle = NSBundle ( path: playground + _bundleName)
178
+ XCTAssertThrowsError ( try bundle!. loadAndReturnError ( ) )
179
+ _cleanupPlayground ( playground)
180
+ }
181
+
182
+ func test_bundleWithInvalidPath( ) {
183
+ let bundleInvalid = NSBundle ( path: " /tmp/test.playground " )
184
+ XCTAssertNil ( bundleInvalid)
185
+ }
186
+
187
+ func test_bundlePreflight( ) {
188
+ let bundleValid = NSBundle . mainBundle ( )
189
+ do {
190
+ try bundleValid. preflight ( )
191
+ } catch {
192
+ XCTFail ( " should not fail to load " )
193
+ }
194
+ // executable cannot be located ..preflight should report error
195
+ guard let playground = _setupPlayground ( ) else { XCTFail ( " Unable to create playground " ) ; return }
196
+ let bundle = NSBundle ( path: playground + _bundleName)
197
+ XCTAssertThrowsError ( try bundle!. preflight ( ) )
198
+ _cleanupPlayground ( playground)
199
+ }
200
+
161
201
162
202
}
0 commit comments