mirror of
https://github.com/exyte/Macaw.git
synced 2024-11-12 18:18:35 +03:00
362d2a6f12
* Updated SVGParserError to conform to Equatable so we can throwing functions
44 lines
1.5 KiB
Swift
44 lines
1.5 KiB
Swift
//
|
|
// SVGParserTest.swift
|
|
// MacawTests
|
|
//
|
|
// Created by Julius Lundang on 19/08/2018.
|
|
// Copyright © 2018 Exyte. All rights reserved.
|
|
//
|
|
|
|
import XCTest
|
|
@testable import Macaw
|
|
|
|
class SVGParserTest: XCTestCase {
|
|
func testParseFromOtherBundle() {
|
|
let bundle = Bundle(for: type(of: TestUtils()))
|
|
let bundleMacawTestsURL = bundle.resourceURL?.appendingPathComponent("MacawTests.bundle")
|
|
let macawTestsBundle = Bundle(url: bundleMacawTestsURL!)!
|
|
do {
|
|
let node = try SVGParser.parse(resource: "circle", fromBundle: macawTestsBundle)
|
|
XCTAssertNotNil(node)
|
|
if let fullPath = macawTestsBundle.path(forResource: "circle", ofType: "svg") {
|
|
let node2 = try SVGParser.parse(fullPath: fullPath)
|
|
XCTAssertNotNil(node2)
|
|
} else {
|
|
XCTFail("No circle.svg found")
|
|
}
|
|
} catch {
|
|
XCTFail(error.localizedDescription)
|
|
}
|
|
}
|
|
|
|
func testParseGivenInvalidPath() {
|
|
let fullPath = "invalid fullPath"
|
|
XCTAssertThrowsError(try SVGParser.parse(fullPath: fullPath)) { error in
|
|
XCTAssertEqual(error as! SVGParserError, SVGParserError.noSuchFile(path: "invalid fullPath"))
|
|
}
|
|
}
|
|
|
|
func testParseGiventEmptyPath() {
|
|
XCTAssertThrowsError(try SVGParser.parse(fullPath: "")) { error in
|
|
XCTAssertEqual(error as! SVGParserError, SVGParserError.noSuchFile(path: ""))
|
|
}
|
|
}
|
|
}
|