-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
chore(ResourcePathTest.swift) add the ResourcePath test cases
- Loading branch information
Showing
4 changed files
with
191 additions
and
1 deletion.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd"> | ||
<plist version="1.0"> | ||
<dict> | ||
<key>CFBundleDevelopmentRegion</key> | ||
<string>$(DEVELOPMENT_LANGUAGE)</string> | ||
<key>CFBundleExecutable</key> | ||
<string>$(EXECUTABLE_NAME)</string> | ||
<key>CFBundleIdentifier</key> | ||
<string>$(PRODUCT_BUNDLE_IDENTIFIER)</string> | ||
<key>CFBundleInfoDictionaryVersion</key> | ||
<string>6.0</string> | ||
<key>CFBundleName</key> | ||
<string>$(PRODUCT_NAME)</string> | ||
<key>CFBundlePackageType</key> | ||
<string>BNDL</string> | ||
<key>CFBundleShortVersionString</key> | ||
<string>1.0</string> | ||
<key>CFBundleVersion</key> | ||
<string>1</string> | ||
</dict> | ||
</plist> |
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,49 @@ | ||
// | ||
// ResourcePathTest.swift | ||
// quick-symlink-tests | ||
// | ||
// Created by Alexander A. Kropotin on 22/08/2021. | ||
// Copyright © 2021 Alexander A. Kropotin. All rights reserved. | ||
// | ||
|
||
import XCTest | ||
|
||
class ResourcePathTest: XCTestCase { | ||
|
||
func test_toURL_methodExecution_returnedURLIsEqualToInitialURL() { | ||
let uri: URL = URL.init(string: "/a/b/c/d")!; | ||
let path: Path = ResourcePath.of(url: uri); | ||
|
||
XCTAssert(path.toUrl() == uri, "The Path URL is not equal to URL"); | ||
} | ||
|
||
func test_relativize_whenCurrentDirectoryIsNestedToOtherDirectory_thenReturnPathStartingFromOtherDirectory() { | ||
let currentUri: URL = URL.init(string: "/a/b/c/d")!; | ||
let otherUri: URL = URL.init(string: "/a/b")!; | ||
|
||
let relativePath: Path = ResourcePath.of(url: currentUri) | ||
.relativize(to: ResourcePath.of(url: otherUri)); | ||
|
||
XCTAssert(relativePath.toUriString() == "./c/d", "The relative path is wrong"); | ||
} | ||
|
||
func test_relativize_whenOtherDirectoryIsNestedToCurrentDirectory_thenReturnPathWithOnlyJumpsAboveOtherDirectory() { | ||
let currentUri: URL = URL.init(string: "/a/b")!; | ||
let otherUri: URL = URL.init(string: "/a/b/c/d")!; | ||
|
||
let relativePath: Path = ResourcePath.of(url: currentUri) | ||
.relativize(to: ResourcePath.of(url: otherUri)); | ||
|
||
XCTAssert(relativePath.toUriString() == "./../..", "The relative path is wrong"); | ||
} | ||
|
||
func test_relativize_whenCurrentDirectoryAndOtherDirectoryAreNestedToGeneralDirectoryy_thenReturnPathWithJumpsAboveOtherDirectoryAndPartOfCurrentDirectory() { | ||
let currentUri: URL = URL.init(string: "/a/b/c1/d1")!; | ||
let otherUri: URL = URL.init(string: "/a/b/c2/d2")!; | ||
|
||
let relativePath: Path = ResourcePath.of(url: currentUri) | ||
.relativize(to: ResourcePath.of(url: otherUri)); | ||
|
||
XCTAssert(relativePath.toUriString() == "./../../c1/d1", "The relative path is wrong"); | ||
} | ||
} |
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