mirror of
https://github.com/gnustep/libs-base.git
synced 2025-05-31 00:30:53 +00:00
import testsuite
git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/base/trunk@32187 72102866-910b-0410-8b05-ffd578937521
This commit is contained in:
parent
734c214892
commit
0e02133729
374 changed files with 20864 additions and 0 deletions
70
Tests/base/NSAffineTransform/basic.m
Normal file
70
Tests/base/NSAffineTransform/basic.m
Normal file
|
@ -0,0 +1,70 @@
|
|||
#import "ObjectTesting.h"
|
||||
#import <Foundation/NSAutoreleasePool.h>
|
||||
#import <Foundation/NSAffineTransform.h>
|
||||
|
||||
#include <math.h>
|
||||
static BOOL eq(double d1, double d2)
|
||||
{
|
||||
if (abs(d1 - d2) < 0.000001)
|
||||
return YES;
|
||||
return NO;
|
||||
}
|
||||
|
||||
int main()
|
||||
{
|
||||
NSAutoreleasePool *arp = [NSAutoreleasePool new];
|
||||
NSAffineTransform *testObj;
|
||||
NSAffineTransformStruct flip = {1.0,0.0,0.0,-1.0,0.0,0.0};
|
||||
NSMutableArray *testObjs = [NSMutableArray new];
|
||||
NSPoint p;
|
||||
NSSize s;
|
||||
|
||||
testObj = [NSAffineTransform new];
|
||||
[testObjs addObject:testObj];
|
||||
PASS(testObj != nil, "can create a new transfor");
|
||||
|
||||
test_NSObject(@"NSAffineTransform", testObjs);
|
||||
test_NSCoding(testObjs);
|
||||
test_NSCopying(@"NSAffineTransform", @"NSAffineTransform", testObjs, NO, YES);
|
||||
|
||||
testObj = [NSAffineTransform transform];
|
||||
PASS(testObj != nil, "can create an autoreleased transform");
|
||||
|
||||
[testObj setTransformStruct: flip];
|
||||
p = [testObj transformPoint: NSMakePoint(10,10)];
|
||||
PASS(eq(p.x, 10) && eq(p.y, -10), "flip transform inverts point y");
|
||||
|
||||
s = [testObj transformSize: NSMakeSize(10,10)];
|
||||
PASS(s.width == 10 && s.height == -10, "flip transform inverts size height");
|
||||
|
||||
p = [testObj transformPoint: p];
|
||||
s = [testObj transformSize: s];
|
||||
PASS(eq(p.x, 10) && eq(p.y, 10) && s.width == 10 && s.height == 10,
|
||||
"flip is reversible");
|
||||
|
||||
testObj = [NSAffineTransform transform];
|
||||
[testObj translateXBy: 5.0 yBy: 6.0];
|
||||
p = [testObj transformPoint: NSMakePoint(10,10)];
|
||||
PASS(eq(p.x, 15.0) && eq(p.y, 16.0), "simple translate works");
|
||||
|
||||
[testObj translateXBy: 5.0 yBy: 4.0];
|
||||
p = [testObj transformPoint: NSMakePoint(10,10)];
|
||||
PASS(eq(p.x, 20.0) && eq(p.y, 20.0), "two simple translates work");
|
||||
|
||||
[testObj rotateByDegrees: 90.0];
|
||||
p = [testObj transformPoint: NSMakePoint(10,10)];
|
||||
PASS(eq(p.x, 0.0) && eq(p.y, 20.0), "translate and rotate works");
|
||||
|
||||
testObj = [NSAffineTransform transform];
|
||||
|
||||
[testObj rotateByDegrees: 90.0];
|
||||
p = [testObj transformPoint: NSMakePoint(10,10)];
|
||||
PASS(eq(p.x, -10.0) && eq(p.y, 10.0), "simple rotate works");
|
||||
|
||||
[testObj translateXBy: 5.0 yBy: 6.0];
|
||||
p = [testObj transformPoint: NSMakePoint(10,10)];
|
||||
PASS(eq(p.x, -16.0) && eq(p.y, 15.0), "rotate and translate works");
|
||||
|
||||
[arp release]; arp = nil;
|
||||
return 0;
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue