aboutsummaryrefslogtreecommitdiff
path: root/AppKit/GTMLinearRGBShadingTest.m
diff options
context:
space:
mode:
authorGravatar thomasvl <thomasvl@7dc7ac4e-7543-0410-b95c-c1676fc8e2a3>2008-06-13 19:21:50 +0000
committerGravatar thomasvl <thomasvl@7dc7ac4e-7543-0410-b95c-c1676fc8e2a3>2008-06-13 19:21:50 +0000
commitc53ec5520e39096e0804ce8d89a21378c0904481 (patch)
treed36a0055b59b1376d86c4ba4a01f9c479c2101a7 /AppKit/GTMLinearRGBShadingTest.m
parent80d493da05c8d461d74bfaa919ffc487be03ffe6 (diff)
Landing a log of AppleScript/AppleEvent support code.
Landing GTMHTTPServer as a simple server but mainly for use in unittesting. _GTMCompileAssert for doing compile time assertions to GTMDefines.h Lots of improvments for UnitTesting, Dave's gonna put up a wiki page shortly with the full details of what can be done.
Diffstat (limited to 'AppKit/GTMLinearRGBShadingTest.m')
-rw-r--r--AppKit/GTMLinearRGBShadingTest.m32
1 files changed, 17 insertions, 15 deletions
diff --git a/AppKit/GTMLinearRGBShadingTest.m b/AppKit/GTMLinearRGBShadingTest.m
index 119fa79..cb65572 100644
--- a/AppKit/GTMLinearRGBShadingTest.m
+++ b/AppKit/GTMLinearRGBShadingTest.m
@@ -20,7 +20,7 @@
#import "GTMSenTestCase.h"
#import "GTMLinearRGBShading.h"
-@interface GTMLinearRGBShadingTest : SenTestCase
+@interface GTMLinearRGBShadingTest : GTMTestCase
@end
@implementation GTMLinearRGBShadingTest
@@ -36,10 +36,10 @@
STAssertNotNil(theShading,nil);
STAssertEquals([theShading stopCount], (NSUInteger)2, nil);
CGFloat *theColor = (CGFloat*)[theShading valueAtPosition: 0.5];
- STAssertTrue(theColor[0] == [purple redComponent] &&
- theColor[1] == [purple greenComponent] &&
- theColor[2] == [purple blueComponent] &&
- theColor[3] == [purple alphaComponent], nil);
+ STAssertEqualsWithAccuracy(theColor[0], [purple redComponent], 0.001, nil);
+ STAssertEqualsWithAccuracy(theColor[1], [purple greenComponent], 0.001, nil);
+ STAssertEqualsWithAccuracy(theColor[2], [purple blueComponent], 0.001, nil);
+ STAssertEqualsWithAccuracy(theColor[3], [purple alphaComponent], 0.001, nil);
}
- (void)testShadingWith {
@@ -49,11 +49,12 @@
CGFloat thePositions[kColorCount];
const CGFloat kColorIncrement = 1.0 / kColorCount;
for (NSUInteger i = 0; i < kColorCount; i++) {
- thePositions[i] = kColorIncrement * i;
- theColors[i] = [NSColor colorWithCalibratedRed:kColorIncrement * i
- green:kColorIncrement * i
- blue:kColorIncrement * i
- alpha:kColorIncrement * i];
+ CGFloat newValue = kColorIncrement * i;
+ thePositions[i] = newValue;
+ theColors[i] = [NSColor colorWithCalibratedRed:newValue
+ green:newValue
+ blue:newValue
+ alpha:newValue];
}
GTMLinearRGBShading *theShading =
[GTMLinearRGBShading shadingWithColors:theColors
@@ -61,11 +62,12 @@
atPositions:thePositions
count:kColorCount];
for (NSUInteger i = 0; i < kColorCount; i++) {
- CGFloat *theColor = (CGFloat*)[theShading valueAtPosition: kColorIncrement * i];
- STAssertTrue(theColor[0] == kColorIncrement * i &&
- theColor[1] == kColorIncrement * i &&
- theColor[2] == kColorIncrement * i &&
- theColor[3] == kColorIncrement * i, nil);
+ CGFloat newValue = kColorIncrement * i;
+ CGFloat *theColor = (CGFloat*)[theShading valueAtPosition:newValue];
+ STAssertEqualsWithAccuracy(theColor[0], newValue, 0.001, nil);
+ STAssertEqualsWithAccuracy(theColor[1], newValue, 0.001, nil);
+ STAssertEqualsWithAccuracy(theColor[2], newValue, 0.001, nil);
+ STAssertEqualsWithAccuracy(theColor[3], newValue, 0.001, nil);
}
}