Skip to content

Commit

Permalink
Fix Swift 3 warnings
Browse files Browse the repository at this point in the history
  • Loading branch information
3lvis committed Mar 28, 2017
1 parent def4c3d commit 13c53ef
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 17 deletions.
2 changes: 1 addition & 1 deletion Source/Sync/NSManagedObject+Sync.swift
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ extension NSManagedObject {
func sync_copyInContext(_ context: NSManagedObjectContext) -> NSManagedObject {
guard let entityName = self.entity.name else { fatalError("Couldn't find entity name") }
let localPrimaryKey = value(forKey: self.entity.sync_localPrimaryKey())
guard let copiedObject = context.safeObject(entityName, localPrimaryKey: localPrimaryKey, parent: nil, parentRelationshipName: nil) else { fatalError("Couldn't fetch a safe object from entityName: \(entityName) localPrimaryKey: \(localPrimaryKey)") }
guard let copiedObject = context.safeObject(entityName, localPrimaryKey: localPrimaryKey, parent: nil, parentRelationshipName: nil) else { fatalError("Couldn't fetch a safe object from entityName: \(entityName) localPrimaryKey: \(String(describing: localPrimaryKey))") }

return copiedObject
}
Expand Down
2 changes: 1 addition & 1 deletion Source/Sync/NSManagedObjectContext+Sync.swift
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ public extension NSManagedObjectContext {
let objects = try fetch(request)
result = objects.first as? NSManagedObject
} catch {
fatalError("Failed to fetch request for entityName: \(entityName), predicate: \(request.predicate)")
fatalError("Failed to fetch request for entityName: \(entityName), predicate: \(String(describing: request.predicate))")
}
} else if let parentRelationshipName = parentRelationshipName {
// More info: https://github.com/SyncDB/Sync/pull/72
Expand Down
30 changes: 15 additions & 15 deletions Tests/DateParser/DateTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -5,55 +5,55 @@ class DateTests: XCTestCase {

func testDateA() {
let date = Date.dateWithHourAndTimeZoneString(dateString: "2015-06-23T12:40:08.000")
let resultDate = NSDate(fromDateString: "2015-06-23T14:40:08.000+02:00") as! Date
let resultDate = NSDate(fromDateString: "2015-06-23T14:40:08.000+02:00")! as Date

XCTAssertNotNil(resultDate)
XCTAssertEqual(date.timeIntervalSince1970, resultDate.timeIntervalSince1970)
}

func testDateB() {
let date = Date.dateWithDayString(dateString: "2014-01-01")
let resultDate = NSDate(fromDateString: "2014-01-01T00:00:00+00:00") as! Date
let resultDate = NSDate(fromDateString: "2014-01-01T00:00:00+00:00")! as Date

XCTAssertNotNil(resultDate)
XCTAssertEqual(date, resultDate)
}

func testDateC() {
let date = Date.dateWithDayString(dateString: "2014-01-02")
let resultDate = NSDate(fromDateString: "2014-01-02") as! Date
let resultDate = NSDate(fromDateString: "2014-01-02")! as Date

XCTAssertNotNil(resultDate)
XCTAssertEqual(date, resultDate)
}

func testDateD() {
let date = Date.dateWithDayString(dateString: "2014-01-02")
let resultDate = NSDate(fromDateString: "2014-01-02T00:00:00.000000+00:00") as! Date
let resultDate = NSDate(fromDateString: "2014-01-02T00:00:00.000000+00:00")! as Date

XCTAssertNotNil(resultDate)
XCTAssertEqual(date, resultDate)
}

func testDateE() {
let date = Date.dateWithDayString(dateString: "2015-09-10")
let resultDate = NSDate(fromDateString: "2015-09-10T00:00:00.116+0000") as! Date
let resultDate = NSDate(fromDateString: "2015-09-10T00:00:00.116+0000")! as Date

XCTAssertNotNil(resultDate)
XCTAssertEqual(date, resultDate)
}

func testDateF() {
let date = Date.dateWithDayString(dateString: "2015-09-10")
let resultDate = NSDate(fromDateString: "2015-09-10T00:00:00.184968Z") as! Date
let resultDate = NSDate(fromDateString: "2015-09-10T00:00:00.184968Z")! as Date

XCTAssertNotNil(resultDate)
XCTAssertEqual(date, resultDate)
}

func testDateG() {
let date = Date.dateWithHourAndTimeZoneString(dateString: "2015-06-23T19:04:19.911Z")
let resultDate = NSDate(fromDateString: "2015-06-23T19:04:19.911Z") as! Date
let resultDate = NSDate(fromDateString: "2015-06-23T19:04:19.911Z")! as Date
print(date.timeIntervalSince1970)
print(resultDate.timeIntervalSince1970)
date.prettyPrint()
Expand All @@ -64,7 +64,7 @@ class DateTests: XCTestCase {

func testDateH() {
let date = Date.dateWithHourAndTimeZoneString(dateString: "2014-03-30T09:13:00.000Z")
let resultDate = NSDate(fromDateString: "2014-03-30T09:13:00Z") as! Date
let resultDate = NSDate(fromDateString: "2014-03-30T09:13:00Z")! as Date
XCTAssertNotNil(resultDate)
XCTAssertEqual(date, resultDate)
}
Expand All @@ -76,21 +76,21 @@ class DateTests: XCTestCase {

func testDateJ() {
let date = Date.dateWithDayString(dateString: "2016-01-09")
let resultDate = NSDate(fromDateString: "2016-01-09T00:00:00.00") as! Date
let resultDate = NSDate(fromDateString: "2016-01-09T00:00:00.00")! as Date
XCTAssertNotNil(resultDate)
XCTAssertEqual(date, resultDate)
}

func testDateK() {
let date = Date.dateWithDayString(dateString: "2016-01-09")
let resultDate = NSDate(fromDateString: "2016-01-09T00:00:00") as! Date
let resultDate = NSDate(fromDateString: "2016-01-09T00:00:00")! as Date
XCTAssertNotNil(resultDate)
XCTAssertEqual(date, resultDate)
}

func testDateL() {
let date = Date.dateWithDayString(dateString: "2009-10-09")
let resultDate = NSDate(fromDateString: "2009-10-09 00:00:00") as! Date
let resultDate = NSDate(fromDateString: "2009-10-09 00:00:00")! as Date
XCTAssertNotNil(resultDate)
XCTAssertEqual(date, resultDate)
}
Expand All @@ -100,31 +100,31 @@ class TimestampDateTests: XCTestCase {

func testTimestampA() {
let date = Date.dateWithDayString(dateString: "2015-09-10")
let resultDate = NSDate(fromDateString: "1441843200") as! Date
let resultDate = NSDate(fromDateString: "1441843200")! as Date

XCTAssertNotNil(resultDate)
XCTAssertEqual(date, resultDate)
}

func testTimestampB() {
let date = Date.dateWithDayString(dateString: "2015-09-10")
let resultDate = NSDate(fromDateString: "1441843200000000") as! Date
let resultDate = NSDate(fromDateString: "1441843200000000")! as Date

XCTAssertNotNil(resultDate)
XCTAssertEqual(date, resultDate)
}

func testTimestampC() {
let date = Date.dateWithDayString(dateString: "2015-09-10")
let resultDate = NSDate(fromUnixTimestampNumber: 1441843200) as! Date
let resultDate = NSDate(fromUnixTimestampNumber: 1441843200)! as Date

XCTAssertNotNil(resultDate)
XCTAssertEqual(date, resultDate)
}

func testTimestampD() {
let date = Date.dateWithDayString(dateString: "2015-09-10")
let resultDate = NSDate(fromUnixTimestampNumber: NSNumber(value: 1441843200000000.0)) as! Date
let resultDate = NSDate(fromUnixTimestampNumber: NSNumber(value: 1441843200000000.0))! as Date

XCTAssertNotNil(resultDate)
XCTAssertEqual(date, resultDate)
Expand Down

0 comments on commit 13c53ef

Please sign in to comment.