From bfaf8705cccb15c0c2a7704b17ba011ddba8242f Mon Sep 17 00:00:00 2001 From: "thomasvl@gmail.com" Date: Wed, 10 Sep 2008 21:04:47 +0000 Subject: - Added GTMExceptionalInlines for dealing with cases where you get warning: variable 'r' might be clobbered by 'longjmp' or 'vfork' when using certain Apple inlined functions in @synchronized/@try blocks. - Updated to Xcode 3.1 so the GTM and iPhone project have the same baseline. The code should work in other version of xcode, but the projects and xcconfig files now use 3.1 features. - Added GTMABAddressBook which is a cocoa wrapper for the 'C' AddressBook APIs on the iPhone. - Added several set environment variable statements to RunIPhoneUnitTest.sh to encourage bugs to come out of the woodwork. --- Foundation/GTMGeometryUtilsTest.m | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) (limited to 'Foundation/GTMGeometryUtilsTest.m') diff --git a/Foundation/GTMGeometryUtilsTest.m b/Foundation/GTMGeometryUtilsTest.m index 5a59c8b..38b86fb 100644 --- a/Foundation/GTMGeometryUtilsTest.m +++ b/Foundation/GTMGeometryUtilsTest.m @@ -164,6 +164,31 @@ STAssertEquals(result, rect, nil); } + +- (void)testGTMNSScaleRectToRect { + typedef struct { + NSRect expectedRect; + GTMScaling scaling; + GTMRectAlignment alignment; + } TestData; + + NSRect rect1 = NSMakeRect(0, 0, 4, 4); + NSRect rect2 = NSMakeRect(0, 0, 2, 1); + + TestData data[] = { + { NSMakeRect(2, 3, 2, 1), GTMScaleToFillProportionally, GTMRectAlignTopRight }, + { NSMakeRect(0, 0, 4, 4), GTMScaleToFit, GTMRectAlignCenter }, + { NSMakeRect(1, 1.5, 2, 1), GTMScaleNone, GTMRectAlignCenter }, + { NSMakeRect(1, 0, 2, 1), GTMScaleProportionally, GTMRectAlignBottom }, + }; + + for (size_t i = 0; i < sizeof(data) / sizeof(TestData); i++) { + NSRect outRect = GTMNSScaleRectToRect(rect2, rect1, data[i].scaling, data[i].alignment); + STAssertEquals(outRect, data[i].expectedRect, nil); + } +} + + - (void)testGTMNSDistanceBetweenPoints { NSPoint pt1 = NSMakePoint(0, 0); NSPoint pt2 = NSMakePoint(3, 4); -- cgit v1.2.3