Created
April 3, 2016 22:20
-
-
Save bjc/a394fb03e5239559eb8370e730c4266e to your computer and use it in GitHub Desktop.
Change BinaryFormat to XMLFormat, watch test break.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
func testWeirdSerialiation() { | |
let exp = NSDate() | |
do { | |
let data = try NSPropertyListSerialization.dataWithPropertyList(exp, format: .BinaryFormat_v1_0, options: 0) | |
do { | |
var format: NSPropertyListFormat = .BinaryFormat_v1_0 | |
if let got = try NSPropertyListSerialization.propertyListWithData(data, options: .MutableContainersAndLeaves, format: &format) as? NSDate { | |
let foo = got.timeIntervalSinceDate(exp) | |
XCTAssertEqual(got, exp, "Dates were not the same: \(foo).") | |
} else { | |
XCTFail("Deserialized date is nil.") | |
} | |
} catch let error as NSError { | |
XCTFail("Couldn't deserialze data: \(error).") | |
} | |
} catch let error as NSError { | |
XCTFail("Couldn't serialize data: \(error).") | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment