From 99fb19640785787471630763d8fd84d902166d91 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Rapha=C3=ABl=20Mor?= Date: Wed, 3 Sep 2014 08:12:36 +0200 Subject: [PATCH 1/2] Fix unit tests in ASTextNodeWordKernerTests Tests were comparing CGFloats with ==. XCTAssertTrue has been replaced by XCTAssertEqualWithAccuracy --- AsyncDisplayKitTests/ASTextNodeWordKernerTests.mm | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/AsyncDisplayKitTests/ASTextNodeWordKernerTests.mm b/AsyncDisplayKitTests/ASTextNodeWordKernerTests.mm index c59560340f..92baa05744 100644 --- a/AsyncDisplayKitTests/ASTextNodeWordKernerTests.mm +++ b/AsyncDisplayKitTests/ASTextNodeWordKernerTests.mm @@ -80,7 +80,8 @@ CGFloat expectedWidth = [@" " sizeWithAttributes:@{ NSFontAttributeName : font }].width; CGRect boundingBox = [_layoutManagerDelegate layoutManager:_components.layoutManager boundingBoxForControlGlyphAtIndex:0 forTextContainer:_components.textContainer proposedLineFragment:CGRectZero glyphPosition:CGPointZero characterIndex:0]; - XCTAssertTrue(boundingBox.size.width == expectedWidth, @"Word kerning shouldn't alter the default width of %f. Encountered space width was %f", expectedWidth, boundingBox.size.width); + + XCTAssertEqualWithAccuracy(boundingBox.size.width, expectedWidth, 0.000001, @"Word kerning shouldn't alter the default width of %f. Encountered space width was %f", expectedWidth, boundingBox.size.width); } - (void)testSpaceBoundingBoxForWordKerning @@ -96,7 +97,7 @@ CGFloat expectedWidth = [@" " sizeWithAttributes:@{ NSFontAttributeName : font }].width + kernValue; CGRect boundingBox = [_layoutManagerDelegate layoutManager:_components.layoutManager boundingBoxForControlGlyphAtIndex:0 forTextContainer:_components.textContainer proposedLineFragment:CGRectZero glyphPosition:CGPointZero characterIndex:0]; - XCTAssertTrue(boundingBox.size.width == expectedWidth, @"Word kerning shouldn't alter the default width of %f. Encountered space width was %f", expectedWidth, boundingBox.size.width); + XCTAssertEqualWithAccuracy(boundingBox.size.width, expectedWidth, 0.000001, @"Word kerning shouldn't alter the default width of %f. Encountered space width was %f", expectedWidth, boundingBox.size.width); } - (NSInteger)_layoutManagerShouldGenerateGlyphs From 06e3f1e0624c09b5ab94cbc9aa8db40dd463aeb4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Rapha=C3=ABl=20Mor?= Date: Fri, 5 Sep 2014 07:55:22 +0200 Subject: [PATCH 2/2] Replaced magic number by FLT_EPSILON --- AsyncDisplayKitTests/ASTextNodeWordKernerTests.mm | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/AsyncDisplayKitTests/ASTextNodeWordKernerTests.mm b/AsyncDisplayKitTests/ASTextNodeWordKernerTests.mm index 92baa05744..ad53664620 100644 --- a/AsyncDisplayKitTests/ASTextNodeWordKernerTests.mm +++ b/AsyncDisplayKitTests/ASTextNodeWordKernerTests.mm @@ -81,7 +81,7 @@ CGRect boundingBox = [_layoutManagerDelegate layoutManager:_components.layoutManager boundingBoxForControlGlyphAtIndex:0 forTextContainer:_components.textContainer proposedLineFragment:CGRectZero glyphPosition:CGPointZero characterIndex:0]; - XCTAssertEqualWithAccuracy(boundingBox.size.width, expectedWidth, 0.000001, @"Word kerning shouldn't alter the default width of %f. Encountered space width was %f", expectedWidth, boundingBox.size.width); + XCTAssertEqualWithAccuracy(boundingBox.size.width, expectedWidth, FLT_EPSILON, @"Word kerning shouldn't alter the default width of %f. Encountered space width was %f", expectedWidth, boundingBox.size.width); } - (void)testSpaceBoundingBoxForWordKerning @@ -97,7 +97,7 @@ CGFloat expectedWidth = [@" " sizeWithAttributes:@{ NSFontAttributeName : font }].width + kernValue; CGRect boundingBox = [_layoutManagerDelegate layoutManager:_components.layoutManager boundingBoxForControlGlyphAtIndex:0 forTextContainer:_components.textContainer proposedLineFragment:CGRectZero glyphPosition:CGPointZero characterIndex:0]; - XCTAssertEqualWithAccuracy(boundingBox.size.width, expectedWidth, 0.000001, @"Word kerning shouldn't alter the default width of %f. Encountered space width was %f", expectedWidth, boundingBox.size.width); + XCTAssertEqualWithAccuracy(boundingBox.size.width, expectedWidth, FLT_EPSILON, @"Word kerning shouldn't alter the default width of %f. Encountered space width was %f", expectedWidth, boundingBox.size.width); } - (NSInteger)_layoutManagerShouldGenerateGlyphs