17
17
import SwiftXCTest
18
18
#endif
19
19
20
- private func XCTAssertEqual( _ expression1: @autoclosure ( ) -> CGRect ,
21
- _ expression2: @autoclosure ( ) -> CGRect ,
22
- accuracy: CGFloat ,
23
- _ message: @autoclosure ( ) -> String = " " ,
24
- file: StaticString = #file,
25
- line: UInt = #line) {
26
-
27
- let rect1 = expression1 ( )
28
- let rect2 = expression1 ( )
29
- XCTAssertEqual ( rect1. origin. x, rect2. origin. x, accuracy: accuracy, message, file: file, line: line)
30
- XCTAssertEqual ( rect1. origin. y, rect2. origin. y, accuracy: accuracy, message, file: file, line: line)
31
- XCTAssertEqual ( rect1. size. width, rect2. size. width, accuracy: accuracy, message, file: file, line: line)
32
- XCTAssertEqual ( rect1. size. height, rect2. size. height, accuracy: accuracy, message, file: file, line: line)
20
+ private func assertEqual( _ rect: CGRect ,
21
+ x: CGFloat ,
22
+ y: CGFloat ,
23
+ width: CGFloat ,
24
+ height: CGFloat ,
25
+ accuracy: CGFloat ? = nil ,
26
+ _ message: @autoclosure ( ) -> String = " " ,
27
+ file: StaticString = #file,
28
+ line: UInt = #line) {
29
+
30
+ if let accuracy = accuracy {
31
+ XCTAssertEqual ( rect. origin. x, x, accuracy: accuracy, message, file: file, line: line)
32
+ XCTAssertEqual ( rect. origin. y, y, accuracy: accuracy, message, file: file, line: line)
33
+ XCTAssertEqual ( rect. size. width, width, accuracy: accuracy, message, file: file, line: line)
34
+ XCTAssertEqual ( rect. size. height, height, accuracy: accuracy, message, file: file, line: line)
35
+ } else {
36
+ XCTAssertEqual ( rect. origin. x, x, message, file: file, line: line)
37
+ XCTAssertEqual ( rect. origin. y, y, message, file: file, line: line)
38
+ XCTAssertEqual ( rect. size. width, width, message, file: file, line: line)
39
+ XCTAssertEqual ( rect. size. height, height, message, file: file, line: line)
40
+ }
33
41
}
34
42
35
43
class TestNSGeometry : XCTestCase {
@@ -45,12 +53,12 @@ class TestNSGeometry : XCTestCase {
45
53
( " test_CGSize_BasicConstruction " , test_CGSize_BasicConstruction) ,
46
54
( " test_CGSize_ExtendedConstruction " , test_CGSize_ExtendedConstruction) ,
47
55
( " test_CGRect_BasicConstruction " , test_CGRect_BasicConstruction) ,
56
+ ( " test_CGRect_ExtendedConstruction " , test_CGRect_ExtendedConstruction) ,
57
+ ( " test_CGRect_SpecialValues " , test_CGRect_SpecialValues) ,
48
58
( " test_CGRect_IsNull " , test_CGRect_IsNull) ,
49
59
( " test_CGRect_IsInfinite " , test_CGRect_IsInfinite) ,
50
60
( " test_CGRect_IsEmpty " , test_CGRect_IsEmpty) ,
51
61
( " test_CGRect_Equatable " , test_CGRect_Equatable) ,
52
- ( " test_CGRect_ExtendedConstruction " , test_CGRect_ExtendedConstruction) ,
53
- ( " test_CGRect_SpecialValues " , test_CGRect_SpecialValues) ,
54
62
( " test_CGRect_CalculatedGeometricProperties " , test_CGRect_CalculatedGeometricProperties) ,
55
63
( " test_CGRect_Standardized " , test_CGRect_Standardized) ,
56
64
( " test_CGRect_Integral " , test_CGRect_Integral) ,
@@ -184,6 +192,48 @@ class TestNSGeometry : XCTestCase {
184
192
XCTAssertEqual ( s3. height, CGFloat ( 4.5 ) )
185
193
}
186
194
195
+ func test_CGRect_BasicConstruction( ) {
196
+ let r1 = CGRect ( )
197
+ XCTAssertEqual ( r1. origin. x, CGFloat ( 0.0 ) )
198
+ XCTAssertEqual ( r1. origin. y, CGFloat ( 0.0 ) )
199
+ XCTAssertEqual ( r1. size. width, CGFloat ( 0.0 ) )
200
+ XCTAssertEqual ( r1. size. height, CGFloat ( 0.0 ) )
201
+
202
+ let p = CGPoint ( x: CGFloat ( 2.2 ) , y: CGFloat ( 3.0 ) )
203
+ let s = CGSize ( width: CGFloat ( 5.0 ) , height: CGFloat ( 5.0 ) )
204
+ let r2 = CGRect ( origin: p, size: s)
205
+ XCTAssertEqual ( r2. origin. x, p. x)
206
+ XCTAssertEqual ( r2. origin. y, p. y)
207
+ XCTAssertEqual ( r2. size. width, s. width)
208
+ XCTAssertEqual ( r2. size. height, s. height)
209
+ }
210
+
211
+ func test_CGRect_ExtendedConstruction( ) {
212
+ let r1 = CGRect . zero
213
+ XCTAssertEqual ( r1. origin. x, CGFloat ( 0.0 ) )
214
+ XCTAssertEqual ( r1. origin. y, CGFloat ( 0.0 ) )
215
+ XCTAssertEqual ( r1. size. width, CGFloat ( 0.0 ) )
216
+ XCTAssertEqual ( r1. size. height, CGFloat ( 0.0 ) )
217
+
218
+ let r2 = CGRect ( x: CGFloat ( 1.2 ) , y: CGFloat ( 2.3 ) , width: CGFloat ( 3.4 ) , height: CGFloat ( 4.5 ) )
219
+ XCTAssertEqual ( r2. origin. x, CGFloat ( 1.2 ) )
220
+ XCTAssertEqual ( r2. origin. y, CGFloat ( 2.3 ) )
221
+ XCTAssertEqual ( r2. size. width, CGFloat ( 3.4 ) )
222
+ XCTAssertEqual ( r2. size. height, CGFloat ( 4.5 ) )
223
+
224
+ let r3 = CGRect ( x: Double ( 1.2 ) , y: Double ( 2.3 ) , width: Double ( 3.4 ) , height: Double ( 4.5 ) )
225
+ XCTAssertEqual ( r3. origin. x, CGFloat ( 1.2 ) )
226
+ XCTAssertEqual ( r3. origin. y, CGFloat ( 2.3 ) )
227
+ XCTAssertEqual ( r3. size. width, CGFloat ( 3.4 ) )
228
+ XCTAssertEqual ( r3. size. height, CGFloat ( 4.5 ) )
229
+
230
+ let r4 = CGRect ( x: Int ( 1 ) , y: Int ( 2 ) , width: Int ( 3 ) , height: Int ( 4 ) )
231
+ XCTAssertEqual ( r4. origin. x, CGFloat ( 1 ) )
232
+ XCTAssertEqual ( r4. origin. y, CGFloat ( 2 ) )
233
+ XCTAssertEqual ( r4. size. width, CGFloat ( 3 ) )
234
+ XCTAssertEqual ( r4. size. height, CGFloat ( 4 ) )
235
+ }
236
+
187
237
func test_CGRect_IsNull( ) {
188
238
XCTAssertTrue ( CGRect . null. isNull)
189
239
XCTAssertTrue ( CGRect ( x: CGFloat . infinity, y: CGFloat . infinity, width: 0 , height: 0 ) . isNull)
@@ -258,22 +308,6 @@ class TestNSGeometry : XCTestCase {
258
308
XCTAssertFalse ( CGRect . infinite. isEmpty)
259
309
}
260
310
261
- func test_CGRect_BasicConstruction( ) {
262
- let r1 = CGRect ( )
263
- XCTAssertEqual ( r1. origin. x, CGFloat ( 0.0 ) )
264
- XCTAssertEqual ( r1. origin. y, CGFloat ( 0.0 ) )
265
- XCTAssertEqual ( r1. size. width, CGFloat ( 0.0 ) )
266
- XCTAssertEqual ( r1. size. height, CGFloat ( 0.0 ) )
267
-
268
- let p = CGPoint ( x: CGFloat ( 2.2 ) , y: CGFloat ( 3.0 ) )
269
- let s = CGSize ( width: CGFloat ( 5.0 ) , height: CGFloat ( 5.0 ) )
270
- let r2 = CGRect ( origin: p, size: s)
271
- XCTAssertEqual ( r2. origin. x, p. x)
272
- XCTAssertEqual ( r2. origin. y, p. y)
273
- XCTAssertEqual ( r2. size. width, s. width)
274
- XCTAssertEqual ( r2. size. height, s. height)
275
- }
276
-
277
311
func test_CGRect_Equatable( ) {
278
312
XCTAssertEqual ( CGRect ( x: 10 , y: 20 , width: 30 , height: 40 ) , CGRect ( x: 10 , y: 20 , width: 30 , height: 40 ) )
279
313
XCTAssertEqual ( CGRect ( x: - 10 , y: - 20 , width: - 30 , height: - 40 ) , CGRect ( x: - 10 , y: - 20 , width: - 30 , height: - 40 ) )
@@ -304,32 +338,6 @@ class TestNSGeometry : XCTestCase {
304
338
r4. origin = CGPoint ( x: 10 , y: 20 )
305
339
XCTAssertNotEqual ( r4, CGRect . null)
306
340
}
307
-
308
- func test_CGRect_ExtendedConstruction( ) {
309
- let r1 = CGRect . zero
310
- XCTAssertEqual ( r1. origin. x, CGFloat ( 0.0 ) )
311
- XCTAssertEqual ( r1. origin. y, CGFloat ( 0.0 ) )
312
- XCTAssertEqual ( r1. size. width, CGFloat ( 0.0 ) )
313
- XCTAssertEqual ( r1. size. height, CGFloat ( 0.0 ) )
314
-
315
- let r2 = CGRect ( x: CGFloat ( 1.2 ) , y: CGFloat ( 2.3 ) , width: CGFloat ( 3.4 ) , height: CGFloat ( 4.5 ) )
316
- XCTAssertEqual ( r2. origin. x, CGFloat ( 1.2 ) )
317
- XCTAssertEqual ( r2. origin. y, CGFloat ( 2.3 ) )
318
- XCTAssertEqual ( r2. size. width, CGFloat ( 3.4 ) )
319
- XCTAssertEqual ( r2. size. height, CGFloat ( 4.5 ) )
320
-
321
- let r3 = CGRect ( x: Double ( 1.2 ) , y: Double ( 2.3 ) , width: Double ( 3.4 ) , height: Double ( 4.5 ) )
322
- XCTAssertEqual ( r3. origin. x, CGFloat ( 1.2 ) )
323
- XCTAssertEqual ( r3. origin. y, CGFloat ( 2.3 ) )
324
- XCTAssertEqual ( r3. size. width, CGFloat ( 3.4 ) )
325
- XCTAssertEqual ( r3. size. height, CGFloat ( 4.5 ) )
326
-
327
- let r4 = CGRect ( x: Int ( 1 ) , y: Int ( 2 ) , width: Int ( 3 ) , height: Int ( 4 ) )
328
- XCTAssertEqual ( r4. origin. x, CGFloat ( 1 ) )
329
- XCTAssertEqual ( r4. origin. y, CGFloat ( 2 ) )
330
- XCTAssertEqual ( r4. size. width, CGFloat ( 3 ) )
331
- XCTAssertEqual ( r4. size. height, CGFloat ( 4 ) )
332
- }
333
341
334
342
func test_CGRect_CalculatedGeometricProperties( ) {
335
343
let ε = CGFloat ( 0.00001 )
@@ -385,76 +393,50 @@ class TestNSGeometry : XCTestCase {
385
393
386
394
func test_CGRect_Standardized( ) {
387
395
let ε = CGFloat ( 0.00001 )
396
+ let nullX = CGRect . null. origin. x
397
+ let nullY = CGRect . null. origin. y
398
+ let nullWidth = CGRect . null. size. width
399
+ let nullHeight = CGRect . null. size. height
388
400
389
401
let r1 = CGRect ( x: 1.9 , y: 1.9 , width: 10.1 , height: 10.2 ) . standardized
390
- XCTAssertEqual ( r1. origin. x, 1.9 , accuracy: ε)
391
- XCTAssertEqual ( r1. origin. y, 1.9 , accuracy: ε)
392
- XCTAssertEqual ( r1. size. width, 10.1 , accuracy: ε)
393
- XCTAssertEqual ( r1. size. height, 10.2 , accuracy: ε)
402
+ assertEqual ( r1, x: 1.9 , y: 1.9 , width: 10.1 , height: 10.2 , accuracy: ε)
394
403
395
404
let r2 = CGRect ( x: 1.9 , y: 1.9 , width: - 10.1 , height: - 10.2 ) . standardized
396
- XCTAssertEqual ( r2. origin. x, - 8.2 , accuracy: ε)
397
- XCTAssertEqual ( r2. origin. y, - 8.3 , accuracy: ε)
398
- XCTAssertEqual ( r2. size. width, 10.1 , accuracy: ε)
399
- XCTAssertEqual ( r2. size. height, 10.2 , accuracy: ε)
405
+ assertEqual ( r2, x: - 8.2 , y: - 8.3 , width: 10.1 , height: 10.2 , accuracy: ε)
400
406
401
407
let r3 = CGRect ( x: - 1.9 , y: - 1.9 , width: 10.1 , height: 10.2 ) . standardized
402
- XCTAssertEqual ( r3. origin. x, - 1.9 , accuracy: ε)
403
- XCTAssertEqual ( r3. origin. y, - 1.9 , accuracy: ε)
404
- XCTAssertEqual ( r3. size. width, 10.1 , accuracy: ε)
405
- XCTAssertEqual ( r3. size. height, 10.2 , accuracy: ε)
408
+ assertEqual ( r3, x: - 1.9 , y: - 1.9 , width: 10.1 , height: 10.2 , accuracy: ε)
406
409
407
410
let r4 = CGRect ( x: - 1.9 , y: - 1.9 , width: - 10.1 , height: - 10.2 ) . standardized
408
- XCTAssertEqual ( r4. origin. x, - 12 , accuracy: ε)
409
- XCTAssertEqual ( r4. origin. y, - 12.1 , accuracy: ε)
410
- XCTAssertEqual ( r4. size. width, 10.1 , accuracy: ε)
411
- XCTAssertEqual ( r4. size. height, 10.2 , accuracy: ε)
411
+ assertEqual ( r4, x: - 12 , y: - 12.1 , width: 10.1 , height: 10.2 , accuracy: ε)
412
412
413
413
let r5 = CGRect . null. standardized
414
- XCTAssertEqual ( r5. origin. x, CGRect . null. origin. x)
415
- XCTAssertEqual ( r5. origin. y, CGRect . null. origin. y)
416
- XCTAssertEqual ( r5. size. width, CGRect . null. size. width)
417
- XCTAssertEqual ( r5. size. height, CGRect . null. size. height)
414
+ assertEqual ( r5, x: nullX, y: nullY, width: nullWidth, height: nullHeight)
418
415
419
416
var r6 = CGRect . null
420
417
r6. size = CGSize ( width: 10 , height: 20 )
421
418
r6 = r6. standardized
422
- XCTAssertEqual ( r6. origin. x, CGRect . null. origin. x)
423
- XCTAssertEqual ( r6. origin. y, CGRect . null. origin. y)
424
- XCTAssertEqual ( r6. size. width, CGRect . null. size. width)
425
- XCTAssertEqual ( r6. size. height, CGRect . null. size. height)
419
+ assertEqual ( r6, x: nullX, y: nullY, width: nullWidth, height: nullHeight)
426
420
427
421
var r7 = CGRect . null
428
422
r7. size = CGSize ( width: - 10 , height: - 20 )
429
423
r7 = r7. standardized
430
- XCTAssertEqual ( r7. origin. x, CGRect . null. origin. x)
431
- XCTAssertEqual ( r7. origin. y, CGRect . null. origin. y)
432
- XCTAssertEqual ( r7. size. width, CGRect . null. size. width)
433
- XCTAssertEqual ( r7. size. height, CGRect . null. size. height)
424
+ assertEqual ( r7, x: nullX, y: nullY, width: nullWidth, height: nullHeight)
434
425
435
426
var r8 = CGRect . null
436
427
r8. origin. x = 20
437
428
r8 = r8. standardized
438
- XCTAssertEqual ( r8. origin. x, CGRect . null. origin. x)
439
- XCTAssertEqual ( r8. origin. y, CGRect . null. origin. y)
440
- XCTAssertEqual ( r8. size. width, CGRect . null. size. width)
441
- XCTAssertEqual ( r8. size. height, CGRect . null. size. height)
429
+ assertEqual ( r8, x: nullX, y: nullY, width: nullWidth, height: nullHeight)
442
430
443
431
var r9 = CGRect . null
444
432
r9. origin. y = 20
445
433
r9 = r9. standardized
446
- XCTAssertEqual ( r9. origin. x, CGRect . null. origin. x)
447
- XCTAssertEqual ( r9. origin. y, CGRect . null. origin. y)
448
- XCTAssertEqual ( r9. size. width, CGRect . null. size. height)
449
- XCTAssertEqual ( r9. size. height, CGRect . null. size. height)
434
+ assertEqual ( r9, x: nullX, y: nullY, width: nullWidth, height: nullHeight)
450
435
451
436
var r10 = CGRect . null
452
437
r10. origin = CGPoint ( x: 10 , y: 20 )
453
438
r10 = r10. standardized
454
- XCTAssertEqual ( r10. origin. x, 10 )
455
- XCTAssertEqual ( r10. origin. y, 20 )
456
- XCTAssertEqual ( r10. size. width, 0 )
457
- XCTAssertEqual ( r10. size. height, 0 )
439
+ assertEqual ( r10, x: 10 , y: 20 , width: 0 , height: 0 )
458
440
}
459
441
460
442
func test_CGRect_Integral( ) {
@@ -581,7 +563,10 @@ class TestNSGeometry : XCTestCase {
581
563
let r1 = CGRect . null
582
564
let r2 = CGRect . null
583
565
let u1 = r1. union ( r2)
584
- XCTAssertEqual ( u1, . null)
566
+ XCTAssertEqual ( u1. origin. x, CGRect . null. origin. x)
567
+ XCTAssertEqual ( u1. origin. y, CGRect . null. origin. y)
568
+ XCTAssertEqual ( u1. size. width, CGRect . null. size. width)
569
+ XCTAssertEqual ( u1. size. height, CGRect . null. size. height)
585
570
586
571
let r3 = CGRect . null
587
572
var r4 = CGRect . null
@@ -861,38 +846,42 @@ class TestNSGeometry : XCTestCase {
861
846
862
847
func test_CGRect_InsetBy( ) {
863
848
let ε = CGFloat ( 0.00001 )
849
+ let nullX = CGRect . null. origin. x
850
+ let nullY = CGRect . null. origin. y
851
+ let nullWidth = CGRect . null. size. width
852
+ let nullHeight = CGRect . null. size. height
864
853
865
854
let r1 = CGRect ( x: 1.2 , y: 3.4 , width: 5.6 , height: 7.8 )
866
- XCTAssertEqual ( r1. insetBy ( dx: 2.8 , dy: 0 ) , CGRect ( x: 4 , y: 3.4 , width: 0 , height: 7.8 ) , accuracy: ε)
867
- XCTAssertEqual ( r1. insetBy ( dx: 0 , dy: 3.9 ) , CGRect ( x: 1.2 , y: 7.3 , width: 5.6 , height: 0 ) , accuracy: ε)
868
- XCTAssertEqual ( r1. insetBy ( dx: 10 , dy: 10 ) , . null )
869
- XCTAssertEqual ( r1. insetBy ( dx: 10 , dy: - 10 ) , . null )
870
- XCTAssertEqual ( r1. insetBy ( dx: - 10 , dy: 10 ) , . null )
871
- XCTAssertEqual ( r1. insetBy ( dx: - 10 , dy: - 10 ) , CGRect ( x: - 8.8 , y: - 6.6 , width: 25.6 , height: 27.8 ) , accuracy: ε)
855
+ assertEqual ( r1. insetBy ( dx: 2.8 , dy: 0 ) , x: 4 , y: 3.4 , width: 0 , height: 7.8 , accuracy: ε)
856
+ assertEqual ( r1. insetBy ( dx: 0 , dy: 3.9 ) , x: 1.2 , y: 7.3 , width: 5.6 , height: 0 , accuracy: ε)
857
+ assertEqual ( r1. insetBy ( dx: 10 , dy: 10 ) , x : nullX , y : nullY , width : nullWidth , height : nullHeight )
858
+ assertEqual ( r1. insetBy ( dx: 10 , dy: - 10 ) , x : nullX , y : nullY , width : nullWidth , height : nullHeight )
859
+ assertEqual ( r1. insetBy ( dx: - 10 , dy: 10 ) , x : nullX , y : nullY , width : nullWidth , height : nullHeight )
860
+ assertEqual ( r1. insetBy ( dx: - 10 , dy: - 10 ) , x: - 8.8 , y: - 6.6 , width: 25.6 , height: 27.8 , accuracy: ε)
872
861
873
862
let r2 = CGRect ( x: 1.2 , y: 3.4 , width: - 5.6 , height: - 7.8 )
874
- XCTAssertEqual ( r2. insetBy ( dx: 2.8 , dy: 0 ) , CGRect ( x: - 1.6 , y: - 4.4 , width: 0 , height: 7.8 ) , accuracy: ε)
875
- XCTAssertEqual ( r2. insetBy ( dx: 0 , dy: 3.9 ) , CGRect ( x: - 4.4 , y: - 0.5 , width: 5.6 , height: 0 ) , accuracy: ε)
876
- XCTAssertEqual ( r2. insetBy ( dx: 10 , dy: 10 ) , . null )
877
- XCTAssertEqual ( r2. insetBy ( dx: 10 , dy: - 10 ) , . null )
878
- XCTAssertEqual ( r2. insetBy ( dx: - 10 , dy: 10 ) , . null )
879
- XCTAssertEqual ( r2. insetBy ( dx: - 10 , dy: - 10 ) , CGRect ( x: - 14.4 , y: - 14.4 , width: 25.6 , height: 27.8 ) , accuracy: ε)
863
+ assertEqual ( r2. insetBy ( dx: 2.8 , dy: 0 ) , x: - 1.6 , y: - 4.4 , width: 0 , height: 7.8 , accuracy: ε)
864
+ assertEqual ( r2. insetBy ( dx: 0 , dy: 3.9 ) , x: - 4.4 , y: - 0.5 , width: 5.6 , height: 0 , accuracy: ε)
865
+ assertEqual ( r2. insetBy ( dx: 10 , dy: 10 ) , x : nullX , y : nullY , width : nullWidth , height : nullHeight )
866
+ assertEqual ( r2. insetBy ( dx: 10 , dy: - 10 ) , x : nullX , y : nullY , width : nullWidth , height : nullHeight )
867
+ assertEqual ( r2. insetBy ( dx: - 10 , dy: 10 ) , x : nullX , y : nullY , width : nullWidth , height : nullHeight )
868
+ assertEqual ( r2. insetBy ( dx: - 10 , dy: - 10 ) , x: - 14.4 , y: - 14.4 , width: 25.6 , height: 27.8 , accuracy: ε)
880
869
881
870
let r3 = CGRect ( x: - 1.2 , y: - 3.4 , width: 5.6 , height: 7.8 )
882
- XCTAssertEqual ( r3. insetBy ( dx: 2.8 , dy: 0 ) , CGRect ( x: 1.6 , y: - 3.4 , width: 0 , height: 7.8 ) , accuracy: ε)
883
- XCTAssertEqual ( r3. insetBy ( dx: 0 , dy: 3.9 ) , CGRect ( x: - 1.2 , y: 0.5 , width: 5.6 , height: 0 ) , accuracy: ε)
884
- XCTAssertEqual ( r3. insetBy ( dx: 10 , dy: 10 ) , . null )
885
- XCTAssertEqual ( r3. insetBy ( dx: 10 , dy: - 10 ) , . null )
886
- XCTAssertEqual ( r3. insetBy ( dx: - 10 , dy: 10 ) , . null )
887
- XCTAssertEqual ( r3. insetBy ( dx: - 10 , dy: - 10 ) , CGRect ( x: - 11.2 , y: - 13.4 , width: 25.6 , height: 27.8 ) , accuracy: ε)
871
+ assertEqual ( r3. insetBy ( dx: 2.8 , dy: 0 ) , x: 1.6 , y: - 3.4 , width: 0 , height: 7.8 , accuracy: ε)
872
+ assertEqual ( r3. insetBy ( dx: 0 , dy: 3.9 ) , x: - 1.2 , y: 0.5 , width: 5.6 , height: 0 , accuracy: ε)
873
+ assertEqual ( r3. insetBy ( dx: 10 , dy: 10 ) , x : nullX , y : nullY , width : nullWidth , height : nullHeight )
874
+ assertEqual ( r3. insetBy ( dx: 10 , dy: - 10 ) , x : nullX , y : nullY , width : nullWidth , height : nullHeight )
875
+ assertEqual ( r3. insetBy ( dx: - 10 , dy: 10 ) , x : nullX , y : nullY , width : nullWidth , height : nullHeight )
876
+ assertEqual ( r3. insetBy ( dx: - 10 , dy: - 10 ) , x: - 11.2 , y: - 13.4 , width: 25.6 , height: 27.8 , accuracy: ε)
888
877
889
878
let r4 = CGRect ( x: - 1.2 , y: - 3.4 , width: - 5.6 , height: - 7.8 )
890
- XCTAssertEqual ( r4. insetBy ( dx: 2.8 , dy: 0 ) , CGRect ( x: - 4 , y: - 11.2 , width: 0 , height: 7.8 ) , accuracy: ε)
891
- XCTAssertEqual ( r4. insetBy ( dx: 0 , dy: 3.9 ) , CGRect ( x: - 6.8 , y: - 7.3 , width: 5.6 , height: 0 ) , accuracy: ε)
892
- XCTAssertEqual ( r4. insetBy ( dx: 10 , dy: 10 ) , . null )
893
- XCTAssertEqual ( r4. insetBy ( dx: 10 , dy: - 10 ) , . null )
894
- XCTAssertEqual ( r4. insetBy ( dx: - 10 , dy: 10 ) , . null )
895
- XCTAssertEqual ( r4. insetBy ( dx: - 10 , dy: - 10 ) , CGRect ( x: - 16.8 , y: - 21.2 , width: 25.6 , height: 27.8 ) , accuracy: ε)
879
+ assertEqual ( r4. insetBy ( dx: 2.8 , dy: 0 ) , x: - 4 , y: - 11.2 , width: 0 , height: 7.8 , accuracy: ε)
880
+ assertEqual ( r4. insetBy ( dx: 0 , dy: 3.9 ) , x: - 6.8 , y: - 7.3 , width: 5.6 , height: 0 , accuracy: ε)
881
+ assertEqual ( r4. insetBy ( dx: 10 , dy: 10 ) , x : nullX , y : nullY , width : nullWidth , height : nullHeight )
882
+ assertEqual ( r4. insetBy ( dx: 10 , dy: - 10 ) , x : nullX , y : nullY , width : nullWidth , height : nullHeight )
883
+ assertEqual ( r4. insetBy ( dx: - 10 , dy: 10 ) , x : nullX , y : nullY , width : nullWidth , height : nullHeight )
884
+ assertEqual ( r4. insetBy ( dx: - 10 , dy: - 10 ) , x: - 16.8 , y: - 21.2 , width: 25.6 , height: 27.8 , accuracy: ε)
896
885
897
886
var r5 = CGRect . null
898
887
r5. size = CGSize ( width: 10 , height: 20 )
0 commit comments