mirror of
https://github.com/qvacua/vimr.git
synced 2024-11-24 03:25:03 +03:00
GH-433 Add UrlCommonsTest
This commit is contained in:
parent
46286d36db
commit
d6018fd849
@ -7,6 +7,7 @@
|
|||||||
objects = {
|
objects = {
|
||||||
|
|
||||||
/* Begin PBXBuildFile section */
|
/* Begin PBXBuildFile section */
|
||||||
|
1929B0032058D7A00000234A /* UrlCommonsTest.swift in Sources */ = {isa = PBXBuildFile; fileRef = 1929BB6C37013C2F120279B6 /* UrlCommonsTest.swift */; };
|
||||||
1929B00BA624DA8DC75F7E02 /* SerializableStates.swift in Sources */ = {isa = PBXBuildFile; fileRef = 1929BA42AB6F1BF631B57399 /* SerializableStates.swift */; };
|
1929B00BA624DA8DC75F7E02 /* SerializableStates.swift in Sources */ = {isa = PBXBuildFile; fileRef = 1929BA42AB6F1BF631B57399 /* SerializableStates.swift */; };
|
||||||
1929B05B9D664052EC2D23EF /* FileOutlineView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 1929BCE3E156C06EDF1F2806 /* FileOutlineView.swift */; };
|
1929B05B9D664052EC2D23EF /* FileOutlineView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 1929BCE3E156C06EDF1F2806 /* FileOutlineView.swift */; };
|
||||||
1929B08C6230B9C5AB72DAF1 /* Pref128ToCurrentConverter.swift in Sources */ = {isa = PBXBuildFile; fileRef = 1929B5046239709E33516F5C /* Pref128ToCurrentConverter.swift */; };
|
1929B08C6230B9C5AB72DAF1 /* Pref128ToCurrentConverter.swift in Sources */ = {isa = PBXBuildFile; fileRef = 1929B5046239709E33516F5C /* Pref128ToCurrentConverter.swift */; };
|
||||||
@ -106,6 +107,7 @@
|
|||||||
4B4192181D0C52D700A0BEB2 /* Grid.swift in Sources */ = {isa = PBXBuildFile; fileRef = 4B4192171D0C52D700A0BEB2 /* Grid.swift */; };
|
4B4192181D0C52D700A0BEB2 /* Grid.swift in Sources */ = {isa = PBXBuildFile; fileRef = 4B4192171D0C52D700A0BEB2 /* Grid.swift */; };
|
||||||
4B5011F81EBA67EB00F76C46 /* RxTest.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 4B5011F71EBA67EB00F76C46 /* RxTest.framework */; };
|
4B5011F81EBA67EB00F76C46 /* RxTest.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 4B5011F71EBA67EB00F76C46 /* RxTest.framework */; };
|
||||||
4B5011F91EBA69E200F76C46 /* RxTest.framework in CopyFiles */ = {isa = PBXBuildFile; fileRef = 4B5011F71EBA67EB00F76C46 /* RxTest.framework */; settings = {ATTRIBUTES = (CodeSignOnCopy, RemoveHeadersOnCopy, ); }; };
|
4B5011F91EBA69E200F76C46 /* RxTest.framework in CopyFiles */ = {isa = PBXBuildFile; fileRef = 4B5011F71EBA67EB00F76C46 /* RxTest.framework */; settings = {ATTRIBUTES = (CodeSignOnCopy, RemoveHeadersOnCopy, ); }; };
|
||||||
|
4B5011FB1EBA6FD700F76C46 /* UrlCommonsTest in Resources */ = {isa = PBXBuildFile; fileRef = 4B5011FA1EBA6FD700F76C46 /* UrlCommonsTest */; };
|
||||||
4B56F2931D29903F00C1F92E /* SwiftNeoVimTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 4B56F2921D29903F00C1F92E /* SwiftNeoVimTests.swift */; };
|
4B56F2931D29903F00C1F92E /* SwiftNeoVimTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 4B56F2921D29903F00C1F92E /* SwiftNeoVimTests.swift */; };
|
||||||
4B56F2951D29903F00C1F92E /* SwiftNeoVim.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 4B2A2BF71D0351810074CE9A /* SwiftNeoVim.framework */; };
|
4B56F2951D29903F00C1F92E /* SwiftNeoVim.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 4B2A2BF71D0351810074CE9A /* SwiftNeoVim.framework */; };
|
||||||
4B56F29D1D29926600C1F92E /* Nimble.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 4B56F29B1D29926600C1F92E /* Nimble.framework */; };
|
4B56F29D1D29926600C1F92E /* Nimble.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 4B56F29B1D29926600C1F92E /* Nimble.framework */; };
|
||||||
@ -384,6 +386,7 @@
|
|||||||
1929BB2AD21A10A0ECA66A5E /* ToolsPref.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = ToolsPref.swift; sourceTree = "<group>"; };
|
1929BB2AD21A10A0ECA66A5E /* ToolsPref.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = ToolsPref.swift; sourceTree = "<group>"; };
|
||||||
1929BB55946DAEBF55D24048 /* GeneralPref.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = GeneralPref.swift; sourceTree = "<group>"; };
|
1929BB55946DAEBF55D24048 /* GeneralPref.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = GeneralPref.swift; sourceTree = "<group>"; };
|
||||||
1929BB6608B4F0E037CA0F4C /* States.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = States.swift; sourceTree = "<group>"; };
|
1929BB6608B4F0E037CA0F4C /* States.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = States.swift; sourceTree = "<group>"; };
|
||||||
|
1929BB6C37013C2F120279B6 /* UrlCommonsTest.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = UrlCommonsTest.swift; sourceTree = "<group>"; };
|
||||||
1929BB6CFF4CC0B5E8B00C62 /* DataWrapper.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = DataWrapper.m; sourceTree = "<group>"; };
|
1929BB6CFF4CC0B5E8B00C62 /* DataWrapper.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = DataWrapper.m; sourceTree = "<group>"; };
|
||||||
1929BB6EB0EC313E228EBC9C /* DictionaryCommonsTest.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = DictionaryCommonsTest.swift; sourceTree = "<group>"; };
|
1929BB6EB0EC313E228EBC9C /* DictionaryCommonsTest.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = DictionaryCommonsTest.swift; sourceTree = "<group>"; };
|
||||||
1929BBC84557C8351EC6183E /* FileItemIgnorePatternTest.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = FileItemIgnorePatternTest.swift; sourceTree = "<group>"; };
|
1929BBC84557C8351EC6183E /* FileItemIgnorePatternTest.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = FileItemIgnorePatternTest.swift; sourceTree = "<group>"; };
|
||||||
@ -431,6 +434,7 @@
|
|||||||
4B401B191D046E0600D99EDC /* NeoVimViewDelegate.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = NeoVimViewDelegate.swift; sourceTree = "<group>"; };
|
4B401B191D046E0600D99EDC /* NeoVimViewDelegate.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = NeoVimViewDelegate.swift; sourceTree = "<group>"; };
|
||||||
4B4192171D0C52D700A0BEB2 /* Grid.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = Grid.swift; sourceTree = "<group>"; };
|
4B4192171D0C52D700A0BEB2 /* Grid.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = Grid.swift; sourceTree = "<group>"; };
|
||||||
4B5011F71EBA67EB00F76C46 /* RxTest.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = RxTest.framework; path = Carthage/Build/Mac/RxTest.framework; sourceTree = SOURCE_ROOT; };
|
4B5011F71EBA67EB00F76C46 /* RxTest.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = RxTest.framework; path = Carthage/Build/Mac/RxTest.framework; sourceTree = SOURCE_ROOT; };
|
||||||
|
4B5011FA1EBA6FD700F76C46 /* UrlCommonsTest */ = {isa = PBXFileReference; lastKnownFileType = folder; path = UrlCommonsTest; sourceTree = "<group>"; };
|
||||||
4B56F2901D29903F00C1F92E /* SwiftNeoVimTests.xctest */ = {isa = PBXFileReference; explicitFileType = wrapper.cfbundle; includeInIndex = 0; path = SwiftNeoVimTests.xctest; sourceTree = BUILT_PRODUCTS_DIR; };
|
4B56F2901D29903F00C1F92E /* SwiftNeoVimTests.xctest */ = {isa = PBXFileReference; explicitFileType = wrapper.cfbundle; includeInIndex = 0; path = SwiftNeoVimTests.xctest; sourceTree = BUILT_PRODUCTS_DIR; };
|
||||||
4B56F2921D29903F00C1F92E /* SwiftNeoVimTests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SwiftNeoVimTests.swift; sourceTree = "<group>"; };
|
4B56F2921D29903F00C1F92E /* SwiftNeoVimTests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SwiftNeoVimTests.swift; sourceTree = "<group>"; };
|
||||||
4B56F2941D29903F00C1F92E /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = "<group>"; };
|
4B56F2941D29903F00C1F92E /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = "<group>"; };
|
||||||
@ -623,6 +627,7 @@
|
|||||||
1929B41F745CDCDFE09ACDCF /* resources */ = {
|
1929B41F745CDCDFE09ACDCF /* resources */ = {
|
||||||
isa = PBXGroup;
|
isa = PBXGroup;
|
||||||
children = (
|
children = (
|
||||||
|
4B5011FA1EBA6FD700F76C46 /* UrlCommonsTest */,
|
||||||
4BDF500B1D760A3500D8FBC3 /* FileUtilsTest */,
|
4BDF500B1D760A3500D8FBC3 /* FileUtilsTest */,
|
||||||
);
|
);
|
||||||
path = resources;
|
path = resources;
|
||||||
@ -963,6 +968,7 @@
|
|||||||
1929BB6EB0EC313E228EBC9C /* DictionaryCommonsTest.swift */,
|
1929BB6EB0EC313E228EBC9C /* DictionaryCommonsTest.swift */,
|
||||||
1929BE20FFBB2D828DB30D81 /* StringCommonsTest.swift */,
|
1929BE20FFBB2D828DB30D81 /* StringCommonsTest.swift */,
|
||||||
1929BCB25C82D93EA66C5FA5 /* RxSwiftCommonsTest.swift */,
|
1929BCB25C82D93EA66C5FA5 /* RxSwiftCommonsTest.swift */,
|
||||||
|
1929BB6C37013C2F120279B6 /* UrlCommonsTest.swift */,
|
||||||
);
|
);
|
||||||
path = VimRTests;
|
path = VimRTests;
|
||||||
sourceTree = "<group>";
|
sourceTree = "<group>";
|
||||||
@ -1311,6 +1317,7 @@
|
|||||||
buildActionMask = 2147483647;
|
buildActionMask = 2147483647;
|
||||||
files = (
|
files = (
|
||||||
4BDF500C1D760A3500D8FBC3 /* FileUtilsTest in Resources */,
|
4BDF500C1D760A3500D8FBC3 /* FileUtilsTest in Resources */,
|
||||||
|
4B5011FB1EBA6FD700F76C46 /* UrlCommonsTest in Resources */,
|
||||||
);
|
);
|
||||||
runOnlyForDeploymentPostprocessing = 0;
|
runOnlyForDeploymentPostprocessing = 0;
|
||||||
};
|
};
|
||||||
@ -1522,6 +1529,7 @@
|
|||||||
1929B9FDD1FFCC81C83EFA69 /* DictionaryCommonsTest.swift in Sources */,
|
1929B9FDD1FFCC81C83EFA69 /* DictionaryCommonsTest.swift in Sources */,
|
||||||
1929B87BEB0B00619DEC2A7F /* StringCommonsTest.swift in Sources */,
|
1929B87BEB0B00619DEC2A7F /* StringCommonsTest.swift in Sources */,
|
||||||
1929B7BDD88EEE171D452595 /* RxSwiftCommonsTest.swift in Sources */,
|
1929B7BDD88EEE171D452595 /* RxSwiftCommonsTest.swift in Sources */,
|
||||||
|
1929B0032058D7A00000234A /* UrlCommonsTest.swift in Sources */,
|
||||||
);
|
);
|
||||||
runOnlyForDeploymentPostprocessing = 0;
|
runOnlyForDeploymentPostprocessing = 0;
|
||||||
};
|
};
|
||||||
|
@ -64,6 +64,18 @@ extension URL {
|
|||||||
return self.deletingLastPathComponent()
|
return self.deletingLastPathComponent()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
var isDir: Bool {
|
||||||
|
return self.resourceValue(URLResourceKey.isDirectoryKey.rawValue)
|
||||||
|
}
|
||||||
|
|
||||||
|
var isHidden: Bool {
|
||||||
|
return self.resourceValue(URLResourceKey.isHiddenKey.rawValue)
|
||||||
|
}
|
||||||
|
|
||||||
|
var isPackage: Bool {
|
||||||
|
return self.resourceValue(URLResourceKey.isPackageKey.rawValue)
|
||||||
|
}
|
||||||
|
|
||||||
/// Wrapper function for NSURL.getResourceValue for Bool values.
|
/// Wrapper function for NSURL.getResourceValue for Bool values.
|
||||||
/// Returns also `false` when
|
/// Returns also `false` when
|
||||||
/// - there is no value for the given `key` or
|
/// - there is no value for the given `key` or
|
||||||
@ -71,7 +83,7 @@ extension URL {
|
|||||||
///
|
///
|
||||||
/// - parameters:
|
/// - parameters:
|
||||||
/// - key: The `key`-parameter of `NSURL.getResourceValue`.
|
/// - key: The `key`-parameter of `NSURL.getResourceValue`.
|
||||||
func resourceValue(_ key: String) -> Bool {
|
fileprivate func resourceValue(_ key: String) -> Bool {
|
||||||
var rsrc: AnyObject?
|
var rsrc: AnyObject?
|
||||||
|
|
||||||
do {
|
do {
|
||||||
@ -88,16 +100,4 @@ extension URL {
|
|||||||
|
|
||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
|
|
||||||
var isDir: Bool {
|
|
||||||
return self.resourceValue(URLResourceKey.isDirectoryKey.rawValue)
|
|
||||||
}
|
|
||||||
|
|
||||||
var isHidden: Bool {
|
|
||||||
return self.resourceValue(URLResourceKey.isHiddenKey.rawValue)
|
|
||||||
}
|
|
||||||
|
|
||||||
var isPackage: Bool {
|
|
||||||
return self.resourceValue(URLResourceKey.isPackageKey.rawValue)
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
78
VimRTests/UrlCommonsTest.swift
Normal file
78
VimRTests/UrlCommonsTest.swift
Normal file
@ -0,0 +1,78 @@
|
|||||||
|
/**
|
||||||
|
* Tae Won Ha - http://taewon.de - @hataewon
|
||||||
|
* See LICENSE
|
||||||
|
*/
|
||||||
|
|
||||||
|
import XCTest
|
||||||
|
import Nimble
|
||||||
|
@testable import VimR
|
||||||
|
|
||||||
|
class UrlCommonsTest: XCTestCase {
|
||||||
|
|
||||||
|
func testIsDirectParent() {
|
||||||
|
let parent = URL(fileURLWithPath: "/some/path")
|
||||||
|
let child = URL(fileURLWithPath: "/some/path/text.txt")
|
||||||
|
let noChild1 = URL(fileURLWithPath: "/some/where/else/text.txt")
|
||||||
|
let noChild2 = URL(fileURLWithPath: "/some/text.txt")
|
||||||
|
|
||||||
|
expect(parent.isDirectParent(of: child)).to(beTrue())
|
||||||
|
expect(parent.isDirectParent(of: noChild1)).to(beFalse())
|
||||||
|
expect(parent.isDirectParent(of: noChild2)).to(beFalse())
|
||||||
|
}
|
||||||
|
|
||||||
|
func testIsParent() {
|
||||||
|
let parent = URL(fileURLWithPath: "/some/path")
|
||||||
|
let child1 = URL(fileURLWithPath: "/some/path/text.txt")
|
||||||
|
let child2 = URL(fileURLWithPath: "/some/path/deep/text.txt")
|
||||||
|
let noChild1 = URL(fileURLWithPath: "/some/where/else/text.txt")
|
||||||
|
let noChild2 = URL(fileURLWithPath: "/some/text.txt")
|
||||||
|
|
||||||
|
expect(parent.isParent(of: child1)).to(beTrue())
|
||||||
|
expect(parent.isParent(of: child2)).to(beTrue())
|
||||||
|
expect(parent.isParent(of: noChild1)).to(beFalse())
|
||||||
|
expect(parent.isParent(of: noChild2)).to(beFalse())
|
||||||
|
}
|
||||||
|
|
||||||
|
func testIsContained() {
|
||||||
|
let parent = URL(fileURLWithPath: "/some/path")
|
||||||
|
let child1 = URL(fileURLWithPath: "/some/path/text.txt")
|
||||||
|
let child2 = URL(fileURLWithPath: "/some/path/deep/text.txt")
|
||||||
|
let noChild1 = URL(fileURLWithPath: "/some/where/else/text.txt")
|
||||||
|
let noChild2 = URL(fileURLWithPath: "/some/text.txt")
|
||||||
|
|
||||||
|
expect(child1.isContained(in: parent)).to(beTrue())
|
||||||
|
expect(child2.isContained(in: parent)).to(beTrue())
|
||||||
|
expect(noChild1.isContained(in: parent)).to(beFalse())
|
||||||
|
expect(noChild2.isContained(in: parent)).to(beFalse())
|
||||||
|
}
|
||||||
|
|
||||||
|
func testParent() {
|
||||||
|
expect(URL(fileURLWithPath: "/some/path/").parent).to(equal(URL(fileURLWithPath: "/some/")))
|
||||||
|
expect(URL(fileURLWithPath: "/some/path/text.txt").parent).to(equal(URL(fileURLWithPath: "/some/path/")))
|
||||||
|
expect(URL(fileURLWithPath: "/").parent).to(equal(URL(fileURLWithPath: "/")))
|
||||||
|
}
|
||||||
|
|
||||||
|
func testIsDir() {
|
||||||
|
let resourceUrl = Bundle.init(for: type(of: self)).url(forResource: "UrlCommonsTest", withExtension: "")!
|
||||||
|
let hidden = resourceUrl.appendingPathComponent(".dot-hidden-file")
|
||||||
|
|
||||||
|
expect(resourceUrl.isDir).to(beTrue())
|
||||||
|
expect(hidden.isDir).to(beFalse())
|
||||||
|
}
|
||||||
|
|
||||||
|
func testIsHidden() {
|
||||||
|
let resourceUrl = Bundle.init(for: type(of: self)).url(forResource: "UrlCommonsTest", withExtension: "")!
|
||||||
|
let hidden = resourceUrl.appendingPathComponent(".dot-hidden-file")
|
||||||
|
|
||||||
|
expect(hidden.isHidden).to(beTrue())
|
||||||
|
expect(resourceUrl.isHidden).to(beFalse())
|
||||||
|
}
|
||||||
|
|
||||||
|
func testIsPackage() {
|
||||||
|
let resourceUrl = Bundle.init(for: type(of: self)).url(forResource: "UrlCommonsTest", withExtension: "")!
|
||||||
|
let package = resourceUrl.appendingPathComponent("dummy.rtfd")
|
||||||
|
|
||||||
|
expect(package.isPackage).to(beTrue())
|
||||||
|
expect(resourceUrl.isPackage).to(beFalse())
|
||||||
|
}
|
||||||
|
}
|
0
VimRTests/resources/UrlCommonsTest/.dot-hidden-file
Normal file
0
VimRTests/resources/UrlCommonsTest/.dot-hidden-file
Normal file
8
VimRTests/resources/UrlCommonsTest/dummy.rtfd/TXT.rtf
Normal file
8
VimRTests/resources/UrlCommonsTest/dummy.rtfd/TXT.rtf
Normal file
@ -0,0 +1,8 @@
|
|||||||
|
{\rtf1\ansi\ansicpg1252\cocoartf1504\cocoasubrtf820
|
||||||
|
{\fonttbl\f0\fswiss\fcharset0 Helvetica;}
|
||||||
|
{\colortbl;\red255\green255\blue255;}
|
||||||
|
{\*\expandedcolortbl;;}
|
||||||
|
\paperw11900\paperh16840\margl1440\margr1440\vieww10800\viewh8400\viewkind0
|
||||||
|
\pard\tx566\tx1133\tx1700\tx2267\tx2834\tx3401\tx3968\tx4535\tx5102\tx5669\tx6236\tx6803\pardirnatural\partightenfactor0
|
||||||
|
|
||||||
|
\f0\fs24 \cf0 Dummy RTFD}
|
Loading…
Reference in New Issue
Block a user