Skip to content

Instantly share code, notes, and snippets.

@bjc
Created April 3, 2016 22:20
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save bjc/a394fb03e5239559eb8370e730c4266e to your computer and use it in GitHub Desktop.
Save bjc/a394fb03e5239559eb8370e730c4266e to your computer and use it in GitHub Desktop.
Change BinaryFormat to XMLFormat, watch test break.
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