-
-
Notifications
You must be signed in to change notification settings - Fork 316
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
ref: Add nanosecondsToTimeInterval (#3483)
SentryTime has timeIntervalToNanoseconds but not nanosecondsToTimeInterval. This PR adds nanosecondsToTimeInterval. Co-authored-by: Andrew McKnight <andrew.mcknight@sentry.io>
- Loading branch information
1 parent
20f4f5d
commit 29d558e
Showing
4 changed files
with
36 additions
and
2 deletions.
There are no files selected for viewing
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
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
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
import Nimble | ||
import XCTest | ||
|
||
final class SentryTimeSwiftTests: XCTestCase { | ||
|
||
func testTimeIntervalToNanoseconds() { | ||
expect(timeIntervalToNanoseconds(0.0)) == UInt64(0) | ||
expect(timeIntervalToNanoseconds(0.5)) == UInt64(500_000_000) | ||
expect(timeIntervalToNanoseconds(1.0)) == UInt64(1_000_000_000) | ||
expect(timeIntervalToNanoseconds(1.123456789)) == UInt64(1_123_456_789) | ||
expect(timeIntervalToNanoseconds(123_456_789.123456)) == UInt64(123_456_789_123_456_000) | ||
} | ||
|
||
func testNanosecondsToTimeInterval() { | ||
expect(nanosecondsToTimeInterval(0)).to(beCloseTo(0.0, within: 1e-9)) | ||
expect(nanosecondsToTimeInterval(500_000_000)).to(beCloseTo(0.5, within: 1e-9)) | ||
expect(nanosecondsToTimeInterval(1_000_000_000)).to(beCloseTo(1.0, within: 1e-9)) | ||
expect(nanosecondsToTimeInterval(1_123_456_789)).to(beCloseTo(1.123456789, within: 1e-9)) | ||
expect(nanosecondsToTimeInterval(123_456_789_123_456_000)).to(beCloseTo(123_456_789.123456, within: 1e-9)) | ||
} | ||
} |