Skip to content
This repository has been archived by the owner on Sep 6, 2018. It is now read-only.

Commit

Permalink
test the relative(to:) method
Browse files Browse the repository at this point in the history
  • Loading branch information
djbe committed Aug 20, 2017
1 parent b381d39 commit 51dec9a
Showing 1 changed file with 30 additions and 1 deletion.
31 changes: 30 additions & 1 deletion Tests/SwiftGenKitTests/FontsTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,8 @@
//

import XCTest
import SwiftGenKit
@testable import SwiftGenKit
import PathKit
import AppKit.NSFont

class FontsTests: XCTestCase {
Expand All @@ -25,4 +26,32 @@ class FontsTests: XCTestCase {
let result = parser.stencilContext()
XCTDiffContexts(result, expected: "defaults.plist", sub: .fonts)
}

// MARK: - Path relative(to:)

func testPathRelativeTo_UnrelatedIsNil() throws {
let parent = Path("/a/b/c")
let file = Path("/d/e/f")

XCTAssertNil(file.relative(to: parent))
}

func testPathRelativeTo_RelatedIsNotNil() throws {
let parent = Path("/a/b/c")
let file = Path("/a/b/c/d/e")

XCTAssertNotNil(file.relative(to: parent))
}

func testPathRelativeTo_ResultIsNotFullPath() throws {
let parent = Path("a/b/c")
let absoluteParent = parent.absolute()
let file = Path("a/b/c/d/e")
let absoluteFile = file.absolute()

XCTAssertEqual(file.relative(to: parent), "d/e")
XCTAssertEqual(file.relative(to: absoluteParent), "d/e")
XCTAssertEqual(absoluteFile.relative(to: parent), "d/e")
XCTAssertEqual(absoluteFile.relative(to: absoluteParent), "d/e")
}
}

0 comments on commit 51dec9a

Please sign in to comment.