From f9e6cc288cf6e35b7de2404a1c2c5daf7afb50f1 Mon Sep 17 00:00:00 2001 From: yang Date: Sat, 15 Jul 2023 00:33:58 +0800 Subject: [PATCH] Add test cases for bug #3564 --- Tests/Tests/SDImageCoderTests.m | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/Tests/Tests/SDImageCoderTests.m b/Tests/Tests/SDImageCoderTests.m index 55364cdc..167d1c4a 100644 --- a/Tests/Tests/SDImageCoderTests.m +++ b/Tests/Tests/SDImageCoderTests.m @@ -96,11 +96,13 @@ expect(decodedImage.size.height).to.equal(1); } -- (void)test07ThatDecodeAndScaleDownAlwaysCompleteRendering { +-(void)test07ThatDecodeAndScaleDownAlwaysCompleteRendering { // Check that when the height of the image used is not evenly divisible by the height of the tile, the output image can also be rendered completely. + // Check that when the height of the image used will led to loss of precision. the output image can also be rendered completely, + UIColor *imageColor = UIColor.blackColor; - CGSize imageSize = CGSizeMake(3024, 4032); + CGSize imageSize = CGSizeMake(1029, 1029); CGRect imageRect = CGRectMake(0, 0, imageSize.width, imageSize.height); SDGraphicsImageRendererFormat *format = [[SDGraphicsImageRendererFormat alloc] init]; format.scale = 1; @@ -110,9 +112,11 @@ CGContextFillRect(context, imageRect); }]; - UIImage *decodedImage = [UIImage sd_decodedAndScaledDownImageWithImage:image limitBytes:20 * 1024 * 1024]; - UIColor *testColor = [decodedImage sd_colorAtPoint:CGPointMake(0, decodedImage.size.height - 1)]; - expect(testColor.sd_hexString).equal(imageColor.sd_hexString); + UIImage *decodedImage = [UIImage sd_decodedAndScaledDownImageWithImage:image limitBytes:1 * 1024 * 1024]; + UIColor *testColor1 = [decodedImage sd_colorAtPoint:CGPointMake(0, decodedImage.size.height - 1)]; + UIColor *testColor2 = [decodedImage sd_colorAtPoint:CGPointMake(0, decodedImage.size.height - 9)]; + expect(testColor1.sd_hexString).equal(imageColor.sd_hexString); + expect(testColor2.sd_hexString).equal(imageColor.sd_hexString); } - (void)test08ThatEncodeAlphaImageToJPGWithBackgroundColor {