@@ -253,79 +253,77 @@ XCTestTestSuite.test("XCTAssertThrowsError") {
253
253
}
254
254
255
255
XCTestTestSuite . test ( " XCTAssertNoThrow " ) {
256
- class ErrorTestCase : XCTestCase {
257
- var doThrow = true
258
- var errorCode = 42
259
-
260
- dynamic func throwSomething( ) throws {
261
- if doThrow {
262
- throw NSError ( domain: " MyDomain " , code: errorCode, userInfo: nil )
263
- }
264
- }
265
-
266
- dynamic func test_throws( ) {
267
-
268
- XCTAssertNoThrow ( try throwSomething ( ) ) {
269
- error in
270
- let nserror = error as NSError
271
- XCTAssertEqual ( nserror. domain, " MyDomain " )
272
- XCTAssertEqual ( nserror. code, 42 )
273
- }
274
- }
275
- }
276
-
277
- // Success
278
- do {
279
- let testCase = ErrorTestCase ( selector: #selector( ErrorTestCase . test_throws) )
280
- testCase. doThrow = false
281
- execute ( testCase. run)
282
- let testRun = testCase. testRun!
256
+ class ErrorTestCase : XCTestCase {
257
+ var doThrow = true
258
+ var errorCode = 42
283
259
284
- expectEqual ( 1 , testRun. testCaseCount)
285
- expectEqual ( 1 , testRun. executionCount)
286
- expectEqual ( 0 , testRun. failureCount)
287
- expectEqual ( 0 , testRun. unexpectedExceptionCount)
288
- expectEqual ( 0 , testRun. totalFailureCount)
289
- expectTrue ( testRun. hasSucceeded)
260
+ dynamic func throwSomething( ) throws {
261
+ if doThrow {
262
+ throw NSError ( domain: " MyDomain " , code: errorCode, userInfo: nil )
263
+ }
290
264
}
291
265
292
- // Failure
293
- do {
294
- let testCase = ErrorTestCase ( selector: #selector( ErrorTestCase . test_throws) )
295
- execute ( testCase. run)
296
- let testRun = testCase. testRun!
266
+ dynamic func test_throws( ) {
297
267
298
- expectEqual ( 1 , testRun . testCaseCount )
299
- expectEqual ( 1 , testRun . executionCount )
300
- expectEqual ( 1 , testRun . failureCount )
301
- expectEqual ( 0 , testRun . unexpectedExceptionCount )
302
- expectEqual ( 1 , testRun . totalFailureCount )
303
- expectFalse ( testRun . hasSucceeded )
268
+ XCTAssertNoThrow ( try throwSomething ( ) ) {
269
+ error in
270
+ let nserror = error as NSError
271
+ XCTAssertEqual ( nserror . domain , " MyDomain " )
272
+ XCTAssertEqual ( nserror . code , 42 )
273
+ }
304
274
}
275
+ }
305
276
306
- // Throws wrong thing
307
- do {
308
- let testCase = ErrorTestCase ( selector: #selector( ErrorTestCase . test_throws) )
309
- testCase. errorCode = 23
310
- execute ( testCase. run)
311
- let testRun = testCase. testRun!
277
+ // Success
278
+ do {
279
+ let testCase = ErrorTestCase ( selector: #selector( ErrorTestCase . test_throws) )
280
+ testCase. doThrow = false
281
+ execute ( testCase. run)
282
+ let testRun = testCase. testRun!
283
+
284
+ expectEqual ( 1 , testRun. testCaseCount)
285
+ expectEqual ( 1 , testRun. executionCount)
286
+ expectEqual ( 0 , testRun. failureCount)
287
+ expectEqual ( 0 , testRun. unexpectedExceptionCount)
288
+ expectEqual ( 0 , testRun. totalFailureCount)
289
+ expectTrue ( testRun. hasSucceeded)
290
+ }
312
291
313
- expectEqual ( 1 , testRun. testCaseCount)
314
- expectEqual ( 1 , testRun. executionCount)
315
- expectEqual ( 1 , testRun. failureCount)
316
- expectEqual ( 0 , testRun. unexpectedExceptionCount)
317
- expectEqual ( 1 , testRun. totalFailureCount)
318
- expectFalse ( testRun. hasSucceeded)
319
- }
292
+ // Failure
293
+ do {
294
+ let testCase = ErrorTestCase ( selector: #selector( ErrorTestCase . test_throws) )
295
+ execute ( testCase. run)
296
+ let testRun = testCase. testRun!
297
+
298
+ expectEqual ( 1 , testRun. testCaseCount)
299
+ expectEqual ( 1 , testRun. executionCount)
300
+ expectEqual ( 1 , testRun. failureCount)
301
+ expectEqual ( 0 , testRun. unexpectedExceptionCount)
302
+ expectEqual ( 1 , testRun. totalFailureCount)
303
+ expectFalse ( testRun. hasSucceeded)
304
+ }
320
305
306
+ // Throws wrong thing
307
+ do {
308
+ let testCase = ErrorTestCase ( selector: #selector( ErrorTestCase . test_throws) )
309
+ testCase. errorCode = 23
310
+ execute ( testCase. run)
311
+ let testRun = testCase. testRun!
312
+
313
+ expectEqual ( 1 , testRun. testCaseCount)
314
+ expectEqual ( 1 , testRun. executionCount)
315
+ expectEqual ( 1 , testRun. failureCount)
316
+ expectEqual ( 0 , testRun. unexpectedExceptionCount)
317
+ expectEqual ( 1 , testRun. totalFailureCount)
318
+ expectFalse ( testRun. hasSucceeded)
319
+ }
321
320
}
322
321
323
-
324
322
XCTestTestSuite . test ( " XCTAsserts with throwing expressions " ) {
325
323
class ErrorTestCase : XCTestCase {
326
324
var doThrow = true
327
325
var errorCode = 42
328
-
326
+
329
327
dynamic func throwSomething( ) throws -> String {
330
328
if doThrow {
331
329
throw NSError ( domain: " MyDomain " , code: errorCode, userInfo: nil )
0 commit comments