Skip to content
This repository has been archived by the owner on Apr 20, 2024. It is now read-only.

Commit

Permalink
updated date tests to get codecov up
Browse files Browse the repository at this point in the history
  • Loading branch information
Casperhr committed Dec 29, 2016
1 parent fc5d9c6 commit eef970d
Showing 1 changed file with 22 additions and 4 deletions.
26 changes: 22 additions & 4 deletions Tests/SugarTests/DateSugerTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ class DateSugarTests: XCTestCase {
XCTAssertEqual(try Date.parse(.ISO8601, iso8601Str)?.to(.ISO8601), iso8601Str)
}

func testParseOrFail() {
func testParseOrFailError() {
do {
let notValidDateTimeString = "2016-12-29T12:35:51+0000"
_ = try Date.parseOrFail(.dateTime, notValidDateTimeString)
Expand All @@ -29,12 +29,28 @@ class DateSugarTests: XCTestCase {
}
}

func testParseFallback() {
func testParseOrFailSuccess() {
do {
let validDateTimeString = "2016-12-29 12:35:51"
_ = try Date.parseOrFail(.dateTime, validDateTimeString)
XCTAssertEqual(true, true)
} catch {
XCTAssertEqual(false, true)
}
}

func testParseFallbackError() {
let notValidDateTimeString = "2016-12-29T12:35:51+0000"
let fallback = Date()
XCTAssertEqual(try Date.parse(.dateTime, notValidDateTimeString, fallback).to(.dateTime), try fallback.toDateTimeString())
}

func testParseFallbackSuccess() {
let validDateTimeString = "2016-12-29 12:35:51"
let fallback = Date()
XCTAssertEqual(try Date.parse(.dateTime, validDateTimeString, fallback).to(.dateTime), validDateTimeString)
}

func testPast() {
let past = Date().addingTimeInterval(-1)
XCTAssertTrue(past.isPast())
Expand Down Expand Up @@ -70,8 +86,10 @@ class DateSugarTests: XCTestCase {
("testDateTime", testDateTime),
("testDate", testDate),
("testISO8601", testISO8601),
("testParseOrFail", testParseOrFail),
("testParseFallback", testParseFallback),
("testParseOrFailError", testParseOrFailError),
("testParseOrFailSuccess", testParseOrFailSuccess),
("testParseFallbackError", testParseFallbackError),
("testParseFallbackSuccess", testParseFallbackSuccess),
("testPast", testPast),
("testFuture", testFuture),
("testIsBefore", testIsBefore),
Expand Down

0 comments on commit eef970d

Please sign in to comment.