Skip to content

Commit

Permalink
add unit tests for CharacterSet and URL
Browse files Browse the repository at this point in the history
  • Loading branch information
jlandon committed Oct 26, 2016
1 parent 996c7f2 commit d46a4ee
Show file tree
Hide file tree
Showing 4 changed files with 80 additions and 1 deletion.
8 changes: 8 additions & 0 deletions Alexandria.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,8 @@
814C71FA1B69DD0900BB4DBD /* Alexandria.h in Headers */ = {isa = PBXBuildFile; fileRef = 814C71F91B69DD0900BB4DBD /* Alexandria.h */; settings = {ATTRIBUTES = (Public, ); }; };
81A87FD61D1828CD00F43B74 /* Operators.swift in Sources */ = {isa = PBXBuildFile; fileRef = 81A87FD51D1828CD00F43B74 /* Operators.swift */; };
81A87FD81D182E0800F43B74 /* CGFloatTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 81A87FD71D182E0800F43B74 /* CGFloatTests.swift */; };
81E694981DC0E893002A4EB5 /* URLTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 81E694971DC0E893002A4EB5 /* URLTests.swift */; };
81E6949A1DC0EA2B002A4EB5 /* CharacterSetTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 81E694991DC0EA2B002A4EB5 /* CharacterSetTests.swift */; };
/* End PBXBuildFile section */

/* Begin PBXContainerItemProxy section */
Expand Down Expand Up @@ -112,6 +114,8 @@
814C72061B69DD0900BB4DBD /* AlexandriaTests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AlexandriaTests.swift; sourceTree = "<group>"; };
81A87FD51D1828CD00F43B74 /* Operators.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = Operators.swift; sourceTree = "<group>"; };
81A87FD71D182E0800F43B74 /* CGFloatTests.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = CGFloatTests.swift; sourceTree = "<group>"; };
81E694971DC0E893002A4EB5 /* URLTests.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = URLTests.swift; sourceTree = "<group>"; };
81E694991DC0EA2B002A4EB5 /* CharacterSetTests.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = CharacterSetTests.swift; sourceTree = "<group>"; };
/* End PBXFileReference section */

/* Begin PBXFrameworksBuildPhase section */
Expand Down Expand Up @@ -238,6 +242,8 @@
81253BE11C69B2A20054D52C /* DateTests.swift */,
79B152491D01C5FC009E850E /* IntTests.swift */,
81A87FD71D182E0800F43B74 /* CGFloatTests.swift */,
81E694971DC0E893002A4EB5 /* URLTests.swift */,
81E694991DC0EA2B002A4EB5 /* CharacterSetTests.swift */,
814C72041B69DD0900BB4DBD /* Supporting Files */,
);
path = AlexandriaTests;
Expand Down Expand Up @@ -360,11 +366,13 @@
isa = PBXSourcesBuildPhase;
buildActionMask = 2147483647;
files = (
81E694981DC0E893002A4EB5 /* URLTests.swift in Sources */,
79B1524A1D01C5FC009E850E /* IntTests.swift in Sources */,
796510A31C6F4F2F00E01F89 /* DateTests.swift in Sources */,
796510A01C6F4F2F00E01F89 /* StringTests.swift in Sources */,
796510A21C6F4F2F00E01F89 /* ColorTests.swift in Sources */,
81A87FD81D182E0800F43B74 /* CGFloatTests.swift in Sources */,
81E6949A1DC0EA2B002A4EB5 /* CharacterSetTests.swift in Sources */,
796510A11C6F4F2F00E01F89 /* CollectionTests.swift in Sources */,
);
runOnlyForDeploymentPostprocessing = 0;
Expand Down
21 changes: 21 additions & 0 deletions AlexandriaTests/CharacterSetTests.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
//
// CharacterSetTests.swift
// Alexandria
//
// Created by Jonathan Landon on 10/26/16.
//
//

import XCTest

class CharacterSetTests: XCTestCase {

func testStringLiteralInitializer() {
let set: CharacterSet = "abcdefg"

XCTAssert(set.contains("a"), "Character missing from set")
XCTAssert(set.contains("d"), "Character missing from set")
XCTAssert(!set.contains("h"), "Character should not be in set")
}

}
31 changes: 31 additions & 0 deletions AlexandriaTests/URLTests.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
//
// URLTests.swift
// Alexandria
//
// Created by Jonathan Landon on 10/26/16.
//
//

import XCTest
import Alexandria

class URLTests: XCTestCase {

func testStringLiteralInitializer() {
let url: URL = "https://github.com/ovenbits"

XCTAssert(url.absoluteString == "https://github.com/ovenbits", "Absolute strings are not equal")
XCTAssert(url.scheme == "https", "Scheme are not equal")
XCTAssert(url.host == "github.com", "Hosts are not equal")
XCTAssert(url.path == "/ovenbits", "Paths are not equal")
}

func testPathAppendingOperator() {
var url: URL = "https://github.com"
url = url + "ovenbits"
url = url + "Alexandria"

XCTAssert(url.path == "/ovenbits/Alexandria", "Paths are not equal")
}

}
21 changes: 20 additions & 1 deletion Sources/URL+Extensions.swift
Original file line number Diff line number Diff line change
@@ -1,10 +1,29 @@
//
// URL+Extensions.swift
// Alexandria
//
// Created by Jonathan Landon on 10/25/16.
//
// The MIT License (MIT)
//
// Copyright (c) 2014-2016 Oven Bits, LLC
//
// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files (the "Software"), to deal
// in the Software without restriction, including without limitation the rights
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
// copies of the Software, and to permit persons to whom the Software is
// furnished to do so, subject to the following conditions:
//
// The above copyright notice and this permission notice shall be included in all
// copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
// SOFTWARE.

import Foundation

Expand Down

0 comments on commit d46a4ee

Please sign in to comment.