File tree Expand file tree Collapse file tree 2 files changed +18
-4
lines changed Expand file tree Collapse file tree 2 files changed +18
-4
lines changed Original file line number Diff line number Diff line change 3333import XCTest
3434@testable import SwiftDraw
3535
36- final class SVGTests : XCTestCase {
37-
36+ final class ParserSVGTests : XCTestCase {
37+
3838 func testSVG( ) throws {
3939 let node = XML . Element ( name: " svg " , attributes: [ " width " : " 100 " , " height " : " 200 " ] )
4040 let parser = XMLParser ( )
Original file line number Diff line number Diff line change 11//
2- // ScannerTests .swift
2+ // SVGTests .swift
33// SwiftDraw
44//
55// Created by Simon Whitty on 19/11/18.
3232import XCTest
3333@testable import SwiftDraw
3434
35- final class ImageTests : XCTestCase {
35+ final class SVGTests : XCTestCase {
3636
3737 func testValidSVGLoads( ) {
3838 XCTAssertNotNil ( SVG ( named: " lines.svg " , in: . test) )
@@ -73,6 +73,20 @@ final class ImageTests: XCTestCase {
7373 }
7474#endif
7575
76+ #if canImport(UIKit)
77+ func testRasterize( ) {
78+ let svg = SVG ( named: " gradient-apple.svg " , in: . test) !
79+ let image = svg. rasterize ( with: CGSize ( width: 100 , height: 100 ) , scale: 3 )
80+ XCTAssertEqual ( image. size, CGSize ( width: 100 , height: 100 ) )
81+ XCTAssertEqual ( image. scale, 3 )
82+
83+ let data = image. pngData ( ) !
84+ let reloaded = UIImage ( data: data) !
85+ XCTAssertEqual ( reloaded. size, CGSize ( width: 300 , height: 300 ) )
86+ XCTAssertEqual ( reloaded. scale, 1 )
87+ }
88+ #endif
89+
7690}
7791
7892private extension SVG {
You can’t perform that action at this time.
0 commit comments