Skip to content

Commit

Permalink
Initial port of files completed
Browse files Browse the repository at this point in the history
  • Loading branch information
wmcginty committed Dec 20, 2017
1 parent 30a4fc8 commit 2036e5b
Show file tree
Hide file tree
Showing 53 changed files with 2,894 additions and 213 deletions.
1 change: 1 addition & 0 deletions .swift-version
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
4.0
13 changes: 13 additions & 0 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
Contributing
============

If you would like to contribute code to this project you can do so through GitHub by
forking the repository and sending a pull request.

When submitting code follow the existing conventions and code style. Ensure that your code changes build and unit tests pass.

Before your code can be accepted into the project you must also sign the
[Individual Contributor License Agreement (CLA)][1].


[1]: https://brcontributor.parseapp.com/
1 change: 1 addition & 0 deletions Example/Podfile
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ target 'UtiliKit_Example' do
pod 'UtiliKit', :path => '../'

target 'UtiliKit_Tests' do
pod 'UtiliKit', :path => '../'
inherit! :search_paths


Expand Down
28 changes: 28 additions & 0 deletions Example/Podfile.lock
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
PODS:
- UtiliKit (0.1.0):
- UtiliKit/Core (= 0.1.0)
- UtiliKit/General (= 0.1.0)
- UtiliKit/Instantiation (= 0.1.0)
- UtiliKit/TimelessDate (= 0.1.0)
- UtiliKit/Version (= 0.1.0)
- UtiliKit/Core (0.1.0):
- UtiliKit/General
- UtiliKit/Instantiation
- UtiliKit/General (0.1.0)
- UtiliKit/Instantiation (0.1.0)
- UtiliKit/TimelessDate (0.1.0)
- UtiliKit/Version (0.1.0)

DEPENDENCIES:
- UtiliKit (from `../`)

EXTERNAL SOURCES:
UtiliKit:
:path: ../

SPEC CHECKSUMS:
UtiliKit: d7af3fa8b0f610b7a031a7e445d190892ef7a802

PODFILE CHECKSUM: c2d5052eeec551f2e08653fd8021aeb849aaea2e

COCOAPODS: 1.4.0.beta.2
190 changes: 190 additions & 0 deletions Example/Tests/DateTests.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,190 @@
//
// DateTests.swift
// UtiliKit
//
// Copyright © 2017 Bottle Rocket Studios. All rights reserved.
//

import XCTest
@testable import UtiliKit

class DateTests: XCTestCase {
var today: Date!
let dateFormatter = DateFormatter()
static let secondsPerDay: Double = 86400
static let secondsPerHour: Double = 3600
static let secondsPerMinute: Double = 60
var timelessTomorrow: TimelessDate = TimelessDate(dateIntervalSinceNow: 1)

override func setUp() {
super.setUp()
today = Date()
dateFormatter.timeStyle = .full
dateFormatter.dateStyle = .full
}

override func tearDown() {
today = nil

super.tearDown()
}

//MARK: - Date tests
func test_DateInitialization_DaysCorrect() {
let tomorrow = Date(days: 1, since: today)
let alsoTomorrow = Date(timeInterval: DateTests.secondsPerDay, since: today)

XCTAssertEqual(dateFormatter.string(from: tomorrow!), dateFormatter.string(from: alsoTomorrow))
}

func test_DateInitialization_HoursCorrect() {
let anHour = Date(hours: 1, since: today)
let alsoAnHour = Date(timeInterval: DateTests.secondsPerHour, since: today)

XCTAssertEqual(dateFormatter.string(from: anHour!), dateFormatter.string(from: alsoAnHour))
}

func test_DateInitialization_MinutesCorrect() {
let aMinute = Date(minutes: 1, since: today)
let alsoAMinute = Date(timeInterval: DateTests.secondsPerMinute, since: today)

XCTAssertEqual(dateFormatter.string(from: aMinute!), dateFormatter.string(from: alsoAMinute))
}

func test_DateInitialization_SecondsCorrect() {
let aSecond = Date(seconds: 1, since: today)
let alsoASecond = Date(timeInterval: 1, since: today)

XCTAssertEqual(dateFormatter.string(from: aSecond!), dateFormatter.string(from: alsoASecond))
}

func test_DateAddition_AddDaysCorrectly() {
let tomorrow = today.adding(days: 1)
let alsoTomorrow = Date(days: 1, since: today)

XCTAssertEqual(dateFormatter.string(from: tomorrow!), dateFormatter.string(from: alsoTomorrow!))
}

func test_DateAddition_AddHoursCorrectly() {
let anHour = today.adding(hours: 1)
let alsoAnHour = Date(hours: 1, since: today)

XCTAssertEqual(dateFormatter.string(from: anHour!), dateFormatter.string(from: alsoAnHour!))
}

func test_DateAddition_AddMinutesCorrectly() {
let aMinute = today.adding(minutes: 1)
let alsoAMinute = Date(minutes: 1, since: today)

XCTAssertEqual(dateFormatter.string(from: aMinute!), dateFormatter.string(from: alsoAMinute!))
}

func test_DateAddition_AddSecondsCorrectly() {
let aSecond = today.adding(seconds: 1)
let alsoASecond = Date(timeInterval: 1, since: today)

XCTAssertEqual(dateFormatter.string(from: aSecond!), dateFormatter.string(from: alsoASecond))
}

func test_DateSubtraction_SubtractDaysCorrectly() {
let tomorrow = today.subtracting(days: 1)
let alsoTomorrow = Date(days: -1, since: today)

XCTAssertEqual(dateFormatter.string(from: tomorrow!), dateFormatter.string(from: alsoTomorrow!))
}

func test_DateSubtraction_SubtractHoursCorrectly() {
let anHour = today.subtracting(hours: 1)
let alsoAnHour = Date(hours: -1, since: today)

XCTAssertEqual(dateFormatter.string(from: anHour!), dateFormatter.string(from: alsoAnHour!))
}

func test_DateSubtraction_SubtractMinutesCorrectly() {
let aMinute = today.subtracting(minutes: 1)
let alsoAMinute = Date(minutes: -1, since: today)

XCTAssertEqual(dateFormatter.string(from: aMinute!), dateFormatter.string(from: alsoAMinute!))
}

func test_TimelessDate_Initialization() {
XCTAssertEqual(TimelessDate(dateInterval: 0, since: timelessTomorrow.date), timelessTomorrow)
}

func test_TimelessDate_LessThan() {
let today = TimelessDate()

XCTAssertLessThan(today, timelessTomorrow)
}

func test_TimelessDate_GreaterThan() {
let today = TimelessDate()

XCTAssertGreaterThan(timelessTomorrow, today)
}

func test_TimelessDate_PlusEquals() {
var tomorrow = TimelessDate(dateInterval: 0, since: TimelessDate())
tomorrow += 1

XCTAssertEqual(tomorrow, timelessTomorrow)
}

func test_TimelessDate_MinusEquals() {
var tomorrow = TimelessDate() + 2
tomorrow -= 1

XCTAssertEqual(tomorrow, timelessTomorrow)
}

func test_TimelessDate_GreaterThanOrEqualGreaterWorks() {
let today = TimelessDate()
XCTAssertGreaterThanOrEqual(timelessTomorrow, today)
}

func test_TimelessDate_GreaterThanOrEqualEqualWorks() {
XCTAssertGreaterThanOrEqual(timelessTomorrow, timelessTomorrow)
}

func test_TimelessDate_LessThanOrEqualLessThanWorks() {
let today = TimelessDate()
let tomorrow = today + 1

XCTAssertLessThanOrEqual(tomorrow, tomorrow)
}

func test_TimelessDate_LessThanOrEqualEqualWorks() {
let today = TimelessDate()
let tomorrow = today + 1

XCTAssertLessThanOrEqual(today, tomorrow)
}

func test_TimelessDate_AddingDays() {
let today = TimelessDate()
let tomorrow = today + 1
XCTAssertEqual(tomorrow, today.addingDateInterval(1))
}

func test_TimelessDate_MutatingAddingDays() {
var today = TimelessDate()
let tomorrow = today + 1
today.addDateInterval(1)
XCTAssertEqual(tomorrow, today)
}

func test_TimelessDate_1970DateIntervalVariable() {
let ref1970 = TimelessDate(dateIntervalSince1970: 3)
XCTAssertEqual(3, ref1970.dateIntervalSince1970)
}

func test_TimelessDate_ReferenceDateIntervalVariable() {
let ref = TimelessDate(dateIntervalSinceReferenceDate: 3)
XCTAssertEqual(3, ref.dateIntervalSinceReferenceDate)
}

func test_TimelessDate_CurrentDateIntervalVariable() {
let today = TimelessDate(dateIntervalSinceNow: 3)
XCTAssertEqual(3, today.dateIntervalSinceNow)
}
}
29 changes: 0 additions & 29 deletions Example/Tests/Tests.swift

This file was deleted.

51 changes: 51 additions & 0 deletions Example/Tests/UtiliKitTests.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
//
// UtiliKitTests.swift
// UtiliKit
//
// Copyright © 2017 Bottle Rocket Studios. All rights reserved.
//

import XCTest
@testable import UtiliKit

class OpenSourceUtilitiesTests: XCTestCase {
var view: UIView!
var superview: UIView!

override func setUp() {
super.setUp()

superview = UIView(frame: CGRect(x: 0, y: 0, width: 100, height: 100))
view = UIView(frame: .zero)
}

override func tearDown() {
view = nil
superview = nil

super.tearDown()
}

//MARK: - Subview Tests
@available(iOS 11, *)
func test_AddSubview_TranslatesAutoresizingMaskIntoConstraintsIsFalse() {
superview.addSubview(view, constrainedToSuperview: true, usingSafeArea: true)

XCTAssertFalse(view.translatesAutoresizingMaskIntoConstraints)
}

@available(iOS 11, *)
func test_AddSubview_ConstraintsAdded() {
superview.addSubview(view, constrainedToSuperview: true, usingSafeArea: false)

XCTAssertEqual(superview.constraints.count, 4)
}

@available(iOS 11, *)
func test_ConstrainSubview_ConstraintsAdded() {
superview.addSubview(view)
view.centerViewInSuperview(usingSafeArea: true)

XCTAssertEqual(superview.constraints.count, 2)
}
}
Loading

0 comments on commit 2036e5b

Please sign in to comment.