下面是代码,这给我带来了一些问题:的NSDate比较失败
NSDate * d1 = [NSDate dateWithTimeIntervalSinceReferenceDate:444555883.659000];
NSTimeInterval since1970 = [d1 timeIntervalSince1970];
NSDate * d2 = [NSDate dateWithTimeIntervalSince1970:since1970];
NSLog(@"%@\n%@", d1, d2);
NSLog(@"%d", [d1 compare: d2] == NSOrderedSame);
我不明白的问题是,测试失败与以下日志:
2015-02-02 07:44:43 +0000
2015-02-02 07:44:43 +0000
0 // test failed
有什么可以测试失败的原因是什么?
尝试使用'XCTAssertEqualWithAccuracy' – Berendschot 2015-02-10 13:10:06
@ Maarten1909即时将使用我的代码以外的测试。如何解决比较失败呢? – 2015-02-10 13:13:56
只是两个NSDates之间的定期比较? – Berendschot 2015-02-10 13:17:52