1
1
mirror of https://github.com/qvacua/vimr.git synced 2024-12-24 22:33:52 +03:00

GH-274 Add test for PrefUtils

This commit is contained in:
Tae Won Ha 2016-09-11 15:22:56 +02:00
parent 912b92934b
commit 84045711ce
No known key found for this signature in database
GPG Key ID: E40743465B5B8B44
3 changed files with 42 additions and 2 deletions

View File

@ -110,6 +110,8 @@
4BF07EE41D51326A009BECEB /* Credits.rtf in Resources */ = {isa = PBXBuildFile; fileRef = 4BF07EE61D51326A009BECEB /* Credits.rtf */; };
4BF6E29C1D34153C0053FA76 /* KeyUtils.swift in Sources */ = {isa = PBXBuildFile; fileRef = 4BF6E29B1D34153C0053FA76 /* KeyUtils.swift */; };
4BF8EED81D85574800CAC08A /* PrefUtils.swift in Sources */ = {isa = PBXBuildFile; fileRef = 4BF8EED71D85574800CAC08A /* PrefUtils.swift */; };
4BF8EEDB1D85903000CAC08A /* PrefUtilsTest.swift in Sources */ = {isa = PBXBuildFile; fileRef = 4BF8EEDA1D85903000CAC08A /* PrefUtilsTest.swift */; };
4BF8EEDC1D85908400CAC08A /* PrefUtils.swift in Sources */ = {isa = PBXBuildFile; fileRef = 4BF8EED71D85574800CAC08A /* PrefUtils.swift */; };
/* End PBXBuildFile section */
/* Begin PBXContainerItemProxy section */
@ -299,6 +301,7 @@
4BF07EE51D51326A009BECEB /* Base */ = {isa = PBXFileReference; lastKnownFileType = text.rtf; name = Base; path = Base.lproj/Credits.rtf; sourceTree = "<group>"; };
4BF6E29B1D34153C0053FA76 /* KeyUtils.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = KeyUtils.swift; sourceTree = "<group>"; };
4BF8EED71D85574800CAC08A /* PrefUtils.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = PrefUtils.swift; sourceTree = "<group>"; };
4BF8EEDA1D85903000CAC08A /* PrefUtilsTest.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = PrefUtilsTest.swift; sourceTree = "<group>"; };
/* End PBXFileReference section */
/* Begin PBXFrameworksBuildPhase section */
@ -387,7 +390,6 @@
4B56CE2F1D5FC27100337673 /* GeneralPrefPane.swift */,
4B238BEB1D3ED54D00CBDD98 /* AppearancePrefPane.swift */,
4B37ADBA1D6EC11600970D55 /* TestPane.swift */,
4BF8EED71D85574800CAC08A /* PrefUtils.swift */,
);
name = Preferences;
sourceTree = "<group>";
@ -576,6 +578,7 @@
1929B5D977261F1EBFA9E8F1 /* FileUtilsTest.swift */,
1929BC19C1BC19246AFF1621 /* MatcherTests.swift */,
4B22F7EF1D7C029400929B0E /* ScorerTest.swift */,
4BF8EEDA1D85903000CAC08A /* PrefUtilsTest.swift */,
1929B41F745CDCDFE09ACDCF /* resources */,
);
path = VimRTests;
@ -597,6 +600,7 @@
4BF8EED91D858C4400CAC08A /* Utils */ = {
isa = PBXGroup;
children = (
4BF8EED71D85574800CAC08A /* PrefUtils.swift */,
1929BA8AC40B901B20F20B71 /* FileUtils.swift */,
1929BEEB33113B0E33C3830F /* Matcher.swift */,
1929B9D510177918080BE39B /* Scorer.swift */,
@ -905,11 +909,13 @@
isa = PBXSourcesBuildPhase;
buildActionMask = 2147483647;
files = (
4BF8EEDC1D85908400CAC08A /* PrefUtils.swift in Sources */,
1929B43FBA7A31F39D294CD0 /* FileItem.swift in Sources */,
1929B741C4E58EEDAF901353 /* FileItemIgnorePattern.swift in Sources */,
1929B7C981A0EFCC8D631E3F /* FileItemService.swift in Sources */,
1929B2E1A64297B8E05BB64A /* FileUtils.swift in Sources */,
1929B3BF1DB87B57559DC27D /* Matcher.swift in Sources */,
4BF8EEDB1D85903000CAC08A /* PrefUtilsTest.swift in Sources */,
1929B63CD9CBB9C122BD99A5 /* ScoredFileItem.swift in Sources */,
1929B10DD8CD7EE0B8BE529F /* Scorer.swift in Sources */,
4B22F7F01D7C029400929B0E /* ScorerTest.swift in Sources */,

View File

@ -29,8 +29,9 @@ class PrefUtils {
}
static func ignorePatternString(fromSet set: Set<FileItemIgnorePattern>) -> String {
return set
return Array(set)
.map { $0.pattern }
.sort()
.joinWithSeparator(", ")
}
}

View File

@ -0,0 +1,33 @@
/**
* Tae Won Ha - http://taewon.de - @hataewon
* See LICENSE
*/
import XCTest
import Nimble
class PrefUtilsTest: XCTestCase {
func testIgnorePatternsFromString() {
expect(PrefUtils.ignorePatterns(fromString: "a, b,c,,d")).to(equal(
Set(["a", "b", "c", "d"].map(FileItemIgnorePattern.init))
))
}
func testIgnorePatternsFromEmptyString() {
expect(PrefUtils.ignorePatterns(fromString: "")).to(equal(Set()))
}
func testIgnorePatternsFromEffectivelyEmptyString() {
expect(PrefUtils.ignorePatterns(fromString: ", , , ")).to(equal(Set()))
}
func testIgnorePatternStringFromSet() {
let set = Set(["c", "a", "d", "b"].map(FileItemIgnorePattern.init))
expect(PrefUtils.ignorePatternString(fromSet: set)).to(equal("a, b, c, d"))
}
func testIgnorePatternStringFromEmptySet() {
expect(PrefUtils.ignorePatternString(fromSet: Set())).to(equal(""))
}
}