Skip to content

Commit ebe89d7

Browse files
committed
Add unit test for
1 parent 2d81316 commit ebe89d7

File tree

1 file changed

+20
-0
lines changed

1 file changed

+20
-0
lines changed
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
import XCTest
2+
import WordPressUI
3+
4+
final class UIImage_CropTests: XCTestCase {
5+
6+
func testSquared() throws {
7+
let image = try XCTUnwrap(createImage(size: .init(width: 96.0, height: 96.1)))
8+
let squareImage = image.squared()
9+
XCTAssertEqual(squareImage.size.width, squareImage.size.height)
10+
}
11+
12+
private func createImage(color: UIColor = .blue, size: CGSize) -> UIImage? {
13+
UIGraphicsBeginImageContextWithOptions(size, false, 0)
14+
color.setFill()
15+
UIRectFill(CGRectMake(0, 0, size.width, size.height))
16+
let image = UIGraphicsGetImageFromCurrentImageContext()
17+
UIGraphicsEndImageContext()
18+
return image
19+
}
20+
}

0 commit comments

Comments
 (0)