Skip to content

Commit

Permalink
Add a test case for svg on macOS
Browse files Browse the repository at this point in the history
  • Loading branch information
onevcat committed Dec 15, 2024
1 parent 5e53d59 commit 00a5645
Showing 1 changed file with 22 additions and 0 deletions.
22 changes: 22 additions & 0 deletions Tests/KingfisherTests/ImageExtensionTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -344,4 +344,26 @@ class ImageExtensionTests: XCTestCase {
// You can not "downsample" an image to a larger size.
XCTAssertEqual(largerImage?.size, CGSize(width: 64, height: 64))
}

#if os(macOS)
func testSVGImageSize() {
let svgString = """
<?xml version="1.0" encoding="UTF-8"?>
<svg width="100px" height="200px" viewBox="0 0 100 200" version="1.1" xmlns="http://www.w3.org/2000/svg">
<rect width="100" height="200" fill="red"/>
</svg>
"""

guard let data = svgString.data(using: .utf8),
let image = NSImage(data: data)
else {
XCTFail("Failed to create image from SVG data")
return
}

let size = image.kf.size
XCTAssertEqual(size.width, 100)
XCTAssertEqual(size.height, 200)
}
#endif
}

0 comments on commit 00a5645

Please sign in to comment.