Make DurationUnit not a typealias of TimeUnit on JVM
Provide conversion functions between DurationUnit and TimeUnit
This commit is contained in:
@@ -92,6 +92,7 @@ class DurationTest {
|
||||
repeat(10) {
|
||||
val d1 = value.toDuration(unit)
|
||||
val unit2 = units.random()
|
||||
@OptIn(ExperimentalTime::class)
|
||||
val value2 = Duration.convert(value, unit, unit2)
|
||||
val d2 = value2.toDuration(unit2)
|
||||
assertEquals(d1, d2, "$value $unit in $unit2")
|
||||
@@ -200,6 +201,7 @@ class DurationTest {
|
||||
val unit = units.random()
|
||||
val unit2 = units.random()
|
||||
|
||||
@OptIn(ExperimentalTime::class)
|
||||
assertAlmostEquals(Duration.convert(value.toDouble(), unit, unit2), value.toDuration(unit).toDouble(unit2))
|
||||
}
|
||||
|
||||
|
||||
@@ -19,6 +19,7 @@ import kotlin.time.DurationUnit.NANOSECONDS
|
||||
class DurationUnitTest {
|
||||
|
||||
@Test
|
||||
@OptIn(ExperimentalTime::class)
|
||||
fun conversion() {
|
||||
fun test(sourceValue: Double, sourceUnit: DurationUnit, targetValue: Double, targetUnit: DurationUnit) {
|
||||
assertEquals(
|
||||
|
||||
Reference in New Issue
Block a user