Skip to content

Commit

Permalink
Merge pull request #7 from NextFaze/feature/swift4
Browse files Browse the repository at this point in the history
Feature/swift4
  • Loading branch information
swoolcock authored Jan 10, 2018
2 parents 24da734 + 540310a commit 3039139
Show file tree
Hide file tree
Showing 8 changed files with 109 additions and 45 deletions.
2 changes: 1 addition & 1 deletion .swift-version
Original file line number Diff line number Diff line change
@@ -1 +1 @@
3.0
4.0
4 changes: 2 additions & 2 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
# * https://github.com/supermarin/xcpretty#usage

language: objective-c # still specify this even though we are using swift - appears to tell travis which Xcode version to use
osx_image: xcode8
osx_image: xcode9.1
#cache: cocoapods
podfile: Example/Podfile
before_install:
Expand All @@ -15,7 +15,7 @@ script:
- set -o pipefail
- xcodebuild -version
- xcodebuild -showsdks
- xcodebuild build test -workspace Example/FazeKit.xcworkspace -scheme FazeKit-Example -sdk iphonesimulator10.0 -destination 'platform=iOS Simulator,name=iPhone 6,OS=10.0' ONLY_ACTIVE_ARCH=NO | xcpretty
- xcodebuild build test -workspace Example/FazeKit.xcworkspace -scheme FazeKit-Example -destination 'platform=iOS Simulator,name=iPhone SE' ONLY_ACTIVE_ARCH=NO | xcpretty
- pod lib lint
notifications:
slack:
Expand Down
4 changes: 4 additions & 0 deletions Example/FazeKit.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
607FACE01AFB9204008FA782 /* LaunchScreen.xib in Resources */ = {isa = PBXBuildFile; fileRef = 607FACDE1AFB9204008FA782 /* LaunchScreen.xib */; };
607FACEC1AFB9204008FA782 /* UIViewAdditionsTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 607FACEB1AFB9204008FA782 /* UIViewAdditionsTests.swift */; };
78B6DD4BAF21BA4B263F3EF4 /* Pods_FazeKit_Tests.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 1DB0AD919FBE4556CA363D8B /* Pods_FazeKit_Tests.framework */; };
7CDA2BCA1FE872FE00CBA532 /* StringAdditionsTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 7CDA2BC91FE872FE00CBA532 /* StringAdditionsTests.swift */; };
C20FAFE21DD42EAA009E5C3F /* MulticastTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = C20FAFE01DD42E7D009E5C3F /* MulticastTests.swift */; };
C2B9A0321DD29F9100AF4E04 /* DateAdditionsTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = C2B9A0301DD2941C00AF4E04 /* DateAdditionsTests.swift */; };
C2B9A0381DD2DAE500AF4E04 /* CollectionAdditionsTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = C2B9A0361DD2DAB500AF4E04 /* CollectionAdditionsTests.swift */; };
Expand Down Expand Up @@ -45,6 +46,7 @@
607FACEA1AFB9204008FA782 /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = "<group>"; };
607FACEB1AFB9204008FA782 /* UIViewAdditionsTests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = UIViewAdditionsTests.swift; sourceTree = "<group>"; };
739B56FA57C1D0E13427B629 /* Pods-FazeKit_Tests.release.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-FazeKit_Tests.release.xcconfig"; path = "Pods/Target Support Files/Pods-FazeKit_Tests/Pods-FazeKit_Tests.release.xcconfig"; sourceTree = "<group>"; };
7CDA2BC91FE872FE00CBA532 /* StringAdditionsTests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = StringAdditionsTests.swift; sourceTree = "<group>"; };
AE54F13DF076B827802B2E27 /* Pods-FazeKit_Example.debug.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-FazeKit_Example.debug.xcconfig"; path = "Pods/Target Support Files/Pods-FazeKit_Example/Pods-FazeKit_Example.debug.xcconfig"; sourceTree = "<group>"; };
C20FAFE01DD42E7D009E5C3F /* MulticastTests.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = MulticastTests.swift; sourceTree = "<group>"; };
C2B9A0301DD2941C00AF4E04 /* DateAdditionsTests.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = DateAdditionsTests.swift; sourceTree = "<group>"; };
Expand Down Expand Up @@ -133,6 +135,7 @@
C2B9A0301DD2941C00AF4E04 /* DateAdditionsTests.swift */,
C20FAFE01DD42E7D009E5C3F /* MulticastTests.swift */,
C2E94BAD1D62CDD5007A7A4C /* ProcessInfoAdditionsTests.swift */,
7CDA2BC91FE872FE00CBA532 /* StringAdditionsTests.swift */,
607FACEB1AFB9204008FA782 /* UIViewAdditionsTests.swift */,
607FACE91AFB9204008FA782 /* Supporting Files */,
);
Expand Down Expand Up @@ -384,6 +387,7 @@
607FACEC1AFB9204008FA782 /* UIViewAdditionsTests.swift in Sources */,
C2B9A0321DD29F9100AF4E04 /* DateAdditionsTests.swift in Sources */,
C20FAFE21DD42EAA009E5C3F /* MulticastTests.swift in Sources */,
7CDA2BCA1FE872FE00CBA532 /* StringAdditionsTests.swift in Sources */,
C2B9A0381DD2DAE500AF4E04 /* CollectionAdditionsTests.swift in Sources */,
);
runOnlyForDeploymentPostprocessing = 0;
Expand Down
27 changes: 16 additions & 11 deletions Example/Pods/Pods.xcodeproj/project.pbxproj

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

67 changes: 67 additions & 0 deletions Example/Tests/StringAdditionsTests.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@
//
// Copyright 2017 NextFaze
//
// Licensed under the Apache License, Version 2.0 (the "License"); you may not
// use this file except in compliance with the License. You may obtain a copy
// of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
// WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
// License for the specific language governing permissions and limitations
// under the License.
//
// StringAdditionsTests.swift
// FazeKit_Tests
//
// Created by Ricardo Santos on 19/12/17.
//

import Foundation
import XCTest
import FazeKit

class StringAdditionsTests: XCTestCase {

override func setUp() {
super.setUp()
}

override func tearDown() {
super.tearDown()
}

func testContains() {
let string = "Abcdefgh"
XCTAssertTrue(string.contains("A"), "String.contains: should have found a match")
XCTAssertFalse(string.contains("a"), "String.contains: should not have found a match")
XCTAssertFalse(string.contains("z"), "String.contains: should not have found a match")
}

func testReplace() {
var string = "The cat jumped over the hat"
string = string.replace("cat", withString: "dog")
XCTAssertTrue(string.contains("dog"), "String.replace: should contain the replacement substring")
XCTAssertFalse(string.contains("cat"), "String.replace: should not still contain the original substring")
}

func testSubscript() {
let string = "OMG. I can't believe it's a thing!"
XCTAssertTrue(string[0] == "O", "String.subscript: should return the Character O")
XCTAssertTrue(string[1] == "M", "String.subscript: should return the Character M")
XCTAssertTrue(string[2] == "G", "String.subscript: should return the Character G")
}

func testSubstring() {
let string = "OMG. Is this even a thing?"
XCTAssertTrue(string.substring(0, length: 3) == "OMG", "String.substring: should create a new substring")
}

func testTrim() {
let string = " Hello World \n\n\n "
XCTAssertTrue(string.trim() == "Hello World", "String.trim(): should remove all whitespace and newlines")
}

}
8 changes: 4 additions & 4 deletions FazeKit/Classes/CollectionAdditions.swift
Original file line number Diff line number Diff line change
Expand Up @@ -56,24 +56,24 @@ public extension Sequence {
}
}

public func +<K: Hashable, V>(lhs: Dictionary<K, V>, rhs: Dictionary<K, V>) -> Dictionary<K, V> {
public func +<K, V>(lhs: Dictionary<K, V>, rhs: Dictionary<K, V>) -> Dictionary<K, V> {
var dict = Dictionary<K, V>()
lhs.forEach { dict[$0.key] = $0.value }
rhs.forEach { dict[$0.key] = $0.value }
return dict
}

public func -<K: Hashable, V>(lhs: Dictionary<K, V>, rhs: Dictionary<K, V>) -> Dictionary<K, V> {
public func -<K, V>(lhs: Dictionary<K, V>, rhs: Dictionary<K, V>) -> Dictionary<K, V> {
var dict = Dictionary<K, V>()
lhs.forEach { dict[$0.key] = $0.value }
rhs.forEach { dict.removeValue(forKey: $0.key) }
return dict
}

public func +=<K: Hashable, V>(lhs: inout Dictionary<K, V>, rhs: Dictionary<K, V>) {
public func +=<K, V>(lhs: inout Dictionary<K, V>, rhs: Dictionary<K, V>) {
rhs.forEach { lhs[$0.key] = $0.value }
}

public func -=<K: Hashable, V>(lhs: inout Dictionary<K, V>, rhs: Dictionary<K, V>) {
public func -=<K, V>(lhs: inout Dictionary<K, V>, rhs: Dictionary<K, V>) {
rhs.forEach { lhs.removeValue(forKey: $0.key) }
}
Loading

0 comments on commit 3039139

Please sign in to comment.