-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathSC2DScaleUnitTest.m
61 lines (42 loc) · 1.75 KB
/
SC2DScaleUnitTest.m
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
//
// SC2DScaleUnitTest.m
// Alarm-Clock
//
// Created by Robert Palmer on 30.01.10.
// Copyright 2010 Robert. All rights reserved.
//
#import "SC2DScaleUnitTest.h"
#import "SC2DScale.h"
@implementation SC2DScaleUnitTest
- (void)test2DScaleCreation {
SC2DScale *scale = [[SC2DScale alloc] init];
STAssertNotNil(scale, @"scale should be cerated");
scale.fromRect = NSMakeRect(0, 0, 100, 100);
STAssertTrue(NSEqualRects(scale.fromRect, NSMakeRect(0, 0, 100, 100)), @"rects should be equal");
scale.toRect = NSMakeRect(0, 100, 100, 100);
STAssertTrue(NSEqualRects(scale.toRect, NSMakeRect(0, 100, 100, 100)), @"rects should be equal");
[scale release];
}
- (void)testScaleXAxis {
SC2DScale *scale = [[SC2DScale alloc] init];
scale.fromRect = NSMakeRect(0, 0, 10, 100);
scale.toRect = NSMakeRect(0, 0, 100, 100);
NSPoint value = NSMakePoint(0, 0);
STAssertTrue(NSEqualPoints([scale scaleValue: value], NSMakePoint(0, 0)), @"should be equal");
value = NSMakePoint(5, 5);
STAssertTrue(NSEqualPoints([scale scaleValue: value], NSMakePoint(50, 5)), @"should be equal");
value = NSMakePoint(10, 100);
STAssertTrue(NSEqualPoints([scale scaleValue: value], NSMakePoint(100, 100)), @"should be equal");
}
- (void)testScaleYAxis {
SC2DScale *scale = [[SC2DScale alloc] init];
scale.fromRect = NSMakeRect(0, 0, 100, 10);
scale.toRect = NSMakeRect(0, 0, 100, 100);
NSPoint value = NSMakePoint(0, 0);
STAssertTrue(NSEqualPoints([scale scaleValue: value], NSMakePoint(0, 0)), @"should be equal");
value = NSMakePoint(0, 5);
STAssertTrue(NSEqualPoints([scale scaleValue: value], NSMakePoint(0, 50)), @"should be equal");
value = NSMakePoint(0, 10);
STAssertTrue(NSEqualPoints([scale scaleValue: value], NSMakePoint(0, 100)), @"should be equal");
}
@end