Change `description`.

This commit is contained in:
YOCKOW 2020-05-24 13:17:37 +09:00
parent ecb0846476
commit a1f456e63d
No known key found for this signature in database
GPG Key ID: BEEDB9712A367313
2 changed files with 7 additions and 2 deletions

View File

@ -106,11 +106,11 @@ extension TimeSpecification {
extension TimeSpecification: CustomStringConvertible, CustomDebugStringConvertible {
public var description: String {
return String(format:"%.09f seconds", self.doubleValue)
return String(format:"\(self.seconds).%09d", self.nanoseconds)
}
public var debugDescription: String {
return self.description
return self.description + " seconds."
}
}

View File

@ -46,6 +46,11 @@ class TimeSpecificationTests: XCTestCase {
XCTAssertEqual(L1 - R1, TimeSpecification(seconds:0, nanoseconds:-864_197_532), "Difference Test 1")
}
func test_description() {
let spec = TimeSpecification(seconds: 123, nanoseconds: 456_789)
XCTAssertEqual(spec.description, "123.000456789")
}
func test_date() {
let spec = TimeSpecification(seconds: 100, nanoseconds: 123_456_789)
XCTAssertEqual(Date(timeIntervalSinceReferenceDate: spec),