Skip to content

Commit

Permalink
Fixed to actually work for HSBA
Browse files Browse the repository at this point in the history
bennyguitar committed Feb 27, 2014
1 parent 828558d commit 77c9da8
Showing 2 changed files with 13 additions and 13 deletions.
6 changes: 3 additions & 3 deletions Colours.m
Original file line number Diff line number Diff line change
@@ -1287,10 +1287,10 @@ - (BOOL)colours_getHue:(CGFloat *)hue saturation:(CGFloat *)saturation brightnes
CGFloat white = 0;
CGFloat a = 0;
if ([self getWhite:&white alpha:&a]) {
*hue = white * 1.0;
*saturation = white * 1.0;
*hue = 0;
*saturation = 0;
*brightness = white * 1.0;
*alpha = a;
*alpha = a * 1.0;

return YES;
}
20 changes: 10 additions & 10 deletions ColoursDemo/ColoursDemo Tests/ColoursDemo_Tests.m
Original file line number Diff line number Diff line change
@@ -158,19 +158,19 @@ - (void)testContrastingColors {

#pragma mark - Swizzle Tests
- (void)testSwizzleRGBA {
NSArray *colors = [[UIColor whiteColor] rgbaArray];
XCTAssertEqualObjects(colors[0], @1.0, @"Serializing from UIWhiteColorSpace to RGBA does not work with swizzled method.");
XCTAssertEqualObjects(colors[1], @1.0, @"Serializing from UIWhiteColorSpace to RGBA does not work works with swizzled method.");
XCTAssertEqualObjects(colors[2], @1.0, @"Serializing from UIWhiteColorSpace to RGBA does not works with swizzled method.");
XCTAssertEqualObjects(colors[3], @1.0, @"Serializing from UIWhiteColorSpace to RGBA not works with swizzled method.");
NSArray *colors = [[UIColor black25PercentColor] rgbaArray];
XCTAssertEqualObjects(colors[0], @0.25, @"Serializing from UIWhiteColorSpace to RGBA does not work with swizzled method.");
XCTAssertEqualObjects(colors[1], @0.25, @"Serializing from UIWhiteColorSpace to RGBA does not work works with swizzled method.");
XCTAssertEqualObjects(colors[2], @0.25, @"Serializing from UIWhiteColorSpace to RGBA does not works with swizzled method.");
XCTAssertEqualObjects(colors[3], @1, @"Serializing from UIWhiteColorSpace to RGBA not works with swizzled method.");
}

- (void)testSwizzleHSBA {
NSArray *colors = [[UIColor whiteColor] hsbaArray];
XCTAssertEqualObjects(colors[0], @1.0, @"Serializing from UIWhiteColorSpace to HSBA does not work with swizzled method.");
XCTAssertEqualObjects(colors[1], @1.0, @"Serializing from UIWhiteColorSpace to HSBA does not work works with swizzled method.");
XCTAssertEqualObjects(colors[2], @1.0, @"Serializing from UIWhiteColorSpace to HSBA does not works with swizzled method.");
XCTAssertEqualObjects(colors[3], @1.0, @"Serializing from UIWhiteColorSpace to HSBA not works with swizzled method.");
NSArray *colors = [[UIColor black25PercentColor] hsbaArray];
XCTAssertEqualObjects(colors[0], @0, @"Serializing from UIWhiteColorSpace to HSBA does not work with swizzled method.");
XCTAssertEqualObjects(colors[1], @0, @"Serializing from UIWhiteColorSpace to HSBA does not work works with swizzled method.");
XCTAssertEqualObjects(colors[2], @0.25, @"Serializing from UIWhiteColorSpace to HSBA does not works with swizzled method.");
XCTAssertEqualObjects(colors[3], @1, @"Serializing from UIWhiteColorSpace to HSBA not works with swizzled method.");
}


0 comments on commit 77c9da8

Please sign in to comment.