Skip to content

Commit 8dd0c81

Browse files
committed
Minor cleanup of test and linting issues
1 parent 95999f8 commit 8dd0c81

File tree

4 files changed

+11
-17
lines changed

4 files changed

+11
-17
lines changed

Example/SwiftCronExampleTests/TimeZoneTests.swift

+5-11
Original file line numberDiff line numberDiff line change
@@ -3,16 +3,6 @@ import SwiftCron
33

44
class TimeZoneTests: XCTestCase {
55

6-
override func setUp() {
7-
super.setUp()
8-
// Put setup code here. This method is called before the invocation of each test method in the class.
9-
}
10-
11-
override func tearDown() {
12-
// Put teardown code here. This method is called after the invocation of each test method in the class.
13-
super.tearDown()
14-
}
15-
166
func testTimeZoneDifferencesResultInVariationOfNextRunDate() {
177
let newYorkTZ = TimeZone(identifier: "America/New_York")!
188
let losAngelesTZ = TimeZone(identifier: "America/Los_Angeles")!
@@ -22,6 +12,10 @@ class TimeZoneTests: XCTestCase {
2212
let nextRunNewYorkTZ = cronExpression.getNextRunDateFromNow(adjustingForTimeZone: newYorkTZ)!
2313
let nextRunLosAngelesTZ = cronExpression.getNextRunDateFromNow(adjustingForTimeZone: losAngelesTZ)!
2414

25-
XCTAssertNotEqual(nextRunNewYorkTZ, nextRunLosAngelesTZ)
15+
let milliDiff = nextRunLosAngelesTZ.timeIntervalSince1970 - nextRunNewYorkTZ.timeIntervalSince1970
16+
let hourDiff = milliDiff / (60*60)
17+
18+
let expectedTimezoneOffset: Double = 3
19+
XCTAssertEqual(expectedTimezoneOffset, hourDiff)
2620
}
2721
}

README.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
SwiftCron
22
==============
3-
[![Build Status](https://travis-ci.org/TheCodedSelf/SwiftCron.svg?branch=master)](https://travis-ci.org/TheCodedSelf/SwiftCron) [![codecov](https://codecov.io/gh/TheCodedSelf/SwiftCron/branch/master/graph/badge.svg)](https://codecov.io/gh/TheCodedSelf/SwiftCron) [![CocoaPod Version](https://img.shields.io/cocoapods/v/SwiftCron.svg)](http://cocoapods.org/pods/SwiftCron)
3+
[![codecov](https://codecov.io/gh/TheCodedSelf/SwiftCron/branch/master/graph/badge.svg)](https://codecov.io/gh/TheCodedSelf/SwiftCron) [![CocoaPod Version](https://img.shields.io/cocoapods/v/SwiftCron.svg)](http://cocoapods.org/pods/SwiftCron)
44

55
A cron expression parser that can take a cron string and give you the next run date and time specified in the string.
66

Sources/CronExpression.swift

+4-4
Original file line numberDiff line numberDiff line change
@@ -37,10 +37,10 @@ public class CronExpression {
3737
cronRepresentation = theCronRepresentation
3838

3939
let parts = cronRepresentation.cronParts
40-
for i: Int in 0 ..< parts.count {
41-
let field = CronField(rawValue: i)!
42-
if field.getFieldChecker().validate(parts[i]) == false {
43-
NSLog("\(#function): Invalid cron field value \(parts[i]) at position \(i)")
40+
for index: Int in 0 ..< parts.count {
41+
let field = CronField(rawValue: index)!
42+
if field.getFieldChecker().validate(parts[index]) == false {
43+
NSLog("\(#function): Invalid cron field value \(parts[index]) at position \(index)")
4444
return nil
4545
}
4646
}

Sources/StringValidator.swift

+1-1
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ struct StringValidator {
2929
typealias Regex = NSRegularExpression
3030
#endif
3131

32-
let regex = try! Regex(pattern: regex, options: [])
32+
guard let regex = try? Regex(pattern: regex, options: []) else { return false }
3333
return regex.numberOfMatches(in: value, options: [], range: NSMakeRange(0, value.count)) > 0
3434
}
3535
}

0 commit comments

Comments
 (0)