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