Add test for Document.parseChunkFilename
This commit is contained in:
parent
6aad7b912d
commit
a71699c15d
2 changed files with 6 additions and 2 deletions
|
@ -26,6 +26,10 @@ class Silica_ViewerTests: XCTestCase {
|
|||
XCTAssert(document.parsePairString("{-1, -1}")! == (-1, -1))
|
||||
XCTAssert(document.parsePairString("{255, 255}")! == (255, 255))
|
||||
XCTAssert(document.parsePairString("{255}") == nil)
|
||||
|
||||
XCTAssert(document.parseChunkFilename("1~1.chunk")! == (1, 2))
|
||||
XCTAssert(document.parseChunkFilename("10~2.chunk")! == (10, 3))
|
||||
XCTAssert(document.parseChunkFilename("~1.chunk") == nil)
|
||||
}
|
||||
|
||||
func testPerformanceExample() throws {
|
||||
|
|
|
@ -135,7 +135,7 @@ class Document: NSDocument {
|
|||
/*
|
||||
Parses the chunk filename, ex. 1~1 to integer coordinates.
|
||||
*/
|
||||
func parseChunkFilename(filename: String) -> (Int, Int)? {
|
||||
func parseChunkFilename(_ filename: String) -> (Int, Int)? {
|
||||
let pathURL = URL(fileURLWithPath: filename)
|
||||
let pathComponents = pathURL.lastPathComponent.replacingOccurrences(of: ".chunk", with: "").components(separatedBy: "~")
|
||||
|
||||
|
@ -301,7 +301,7 @@ class Document: NSDocument {
|
|||
|
||||
let threadEntry = threadArchive[chunkPaths[i]]
|
||||
|
||||
guard let (x, y) = parseChunkFilename(filename: threadEntry!.path) else {
|
||||
guard let (x, y) = parseChunkFilename(threadEntry!.path) else {
|
||||
return
|
||||
}
|
||||
|
||||
|
|
Reference in a new issue