diff --git a/Silica ViewerTests/Silica_ViewerTests.swift b/Silica ViewerTests/Silica_ViewerTests.swift index e59b2a0..243051d 100644 --- a/Silica ViewerTests/Silica_ViewerTests.swift +++ b/Silica ViewerTests/Silica_ViewerTests.swift @@ -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 { diff --git a/SilicaViewer/Document.swift b/SilicaViewer/Document.swift index 93ea89d..95a12b8 100644 --- a/SilicaViewer/Document.swift +++ b/SilicaViewer/Document.swift @@ -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 }