-
Notifications
You must be signed in to change notification settings - Fork 561
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #460 from cHaLkdusT/master
Improving API structure for readability
- Loading branch information
Showing
8 changed files
with
118 additions
and
18 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
<svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" version="1.1" ><g><g><circle r="40" cy="50" cx="50" fill="red" stroke="black" stroke-width="3.0"/><circle r="40" cy="50" cx="140" fill="#F0F0AA" stroke="black" stroke-width="3.0"/></g></g></svg> |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
// | ||
// 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: "")) | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -6,6 +6,6 @@ | |
// | ||
// | ||
|
||
enum SVGParserError: Error { | ||
enum SVGParserError: Error, Equatable { | ||
case noSuchFile(path: String) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters