commonTest.io.islandtime.clock.ClockTest.kt Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of core-metadata Show documentation
Show all versions of core-metadata Show documentation
A multiplatform library for working with dates and times
The newest version!
package io.islandtime.clock
import io.islandtime.Instant
import io.islandtime.TimeZone
import io.islandtime.measures.milliseconds
import kotlin.test.Test
import kotlin.test.assertEquals
import kotlin.test.assertNotEquals
import kotlin.test.assertTrue
class ClockTest {
@Test
fun `UTC SystemClock`() {
val clock = SystemClock.UTC
assertTrue { clock.readMilliseconds() > 0L.milliseconds }
assertTrue { clock.readInstant() > Instant.UNIX_EPOCH }
assertEquals(TimeZone.UTC, clock.zone)
}
@Test
fun `SystemClock() without zone`() {
val clock = SystemClock()
assertTrue { clock.readMilliseconds() > 0L.milliseconds }
assertTrue { clock.readInstant() > Instant.UNIX_EPOCH }
assertNotEquals("", clock.zone.id)
}
@Test
fun `SystemClock() with zone`() {
val clock = SystemClock(TimeZone("America/Denver"))
assertTrue { clock.readMilliseconds() > 0L.milliseconds }
assertTrue { clock.readInstant() > Instant.UNIX_EPOCH }
assertEquals(TimeZone("America/Denver"), clock.zone)
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy