@@ -31,6 +31,9 @@ class TestNSAffineTransform : XCTestCase {
31
31
( " test_BasicConstruction " , test_BasicConstruction) ,
32
32
( " test_IdentityTransformation " , test_IdentityTransformation) ,
33
33
( " test_Scale " , test_Scale) ,
34
+ ( " test_Scaling " , test_Scaling) ,
35
+ ( " test_TranslationScaling " , test_TranslationScaling) ,
36
+ ( " test_ScalingTranslation " , test_ScalingTranslation) ,
34
37
( " test_Rotation_Degrees " , test_Rotation_Degrees) ,
35
38
( " test_Rotation_Radians " , test_Rotation_Radians) ,
36
39
( " test_Inversion " , test_Inversion) ,
@@ -208,5 +211,37 @@ class TestNSAffineTransform : XCTestCase {
208
211
checkPointTransformation ( xyPlus5, point: NSMakePoint ( CGFloat ( - 2.0 ) , CGFloat ( - 3.0 ) ) ,
209
212
expectedPoint: NSMakePoint ( CGFloat ( 3.0 ) , CGFloat ( 2.0 ) ) )
210
213
}
214
+
215
+ func test_Scaling( ) {
216
+ let xyTimes5 = NSAffineTransform ( )
217
+ xyTimes5. scaleBy ( CGFloat ( 5.0 ) )
218
+
219
+ checkPointTransformation ( xyTimes5, point: NSMakePoint ( CGFloat ( - 2.0 ) , CGFloat ( 3.0 ) ) ,
220
+ expectedPoint: NSMakePoint ( CGFloat ( - 10.0 ) , CGFloat ( 15.0 ) ) )
221
+
222
+ let xTimes2YTimes3 = NSAffineTransform ( )
223
+ xTimes2YTimes3. scaleXBy ( CGFloat ( 2.0 ) , yBy: CGFloat ( - 3.0 ) )
224
+
225
+ checkPointTransformation ( xTimes2YTimes3, point: NSMakePoint ( CGFloat ( - 1.0 ) , CGFloat ( 3.5 ) ) ,
226
+ expectedPoint: NSMakePoint ( CGFloat ( - 2.0 ) , CGFloat ( - 10.5 ) ) )
227
+ }
228
+
229
+ func test_TranslationScaling( ) {
230
+ let xPlus2XYTimes5 = NSAffineTransform ( )
231
+ xPlus2XYTimes5. translateXBy ( CGFloat ( 2.0 ) , yBy: CGFloat ( ) )
232
+ xPlus2XYTimes5. scaleXBy ( CGFloat ( 5.0 ) , yBy: CGFloat ( - 5.0 ) )
233
+
234
+ checkPointTransformation ( xPlus2XYTimes5, point: NSMakePoint ( CGFloat ( 1.0 ) , CGFloat ( 2.0 ) ) ,
235
+ expectedPoint: NSMakePoint ( CGFloat ( 7.0 ) , CGFloat ( - 10.0 ) ) )
236
+ }
237
+
238
+ func test_ScalingTranslation( ) {
239
+ let xyTimes5XPlus3 = NSAffineTransform ( )
240
+ xyTimes5XPlus3. scaleBy ( CGFloat ( 5.0 ) )
241
+ xyTimes5XPlus3. translateXBy ( CGFloat ( 3.0 ) , yBy: CGFloat ( ) )
242
+
243
+ checkPointTransformation ( xyTimes5XPlus3, point: NSMakePoint ( CGFloat ( 1.0 ) , CGFloat ( 2.0 ) ) ,
244
+ expectedPoint: NSMakePoint ( CGFloat ( 20.0 ) , CGFloat ( 10.0 ) ) )
245
+ }
211
246
}
212
247
0 commit comments