Move convertDurationUnit into Duration companion

This commit is contained in:
Ilya Gorbunov
2019-05-30 21:12:16 +03:00
parent ca10d13f34
commit 368452748b
6 changed files with 11 additions and 7 deletions
+2 -2
View File
@@ -52,7 +52,7 @@ class DurationTest {
repeat(10) {
val d1 = value.toDuration(unit)
val unit2 = units.random()
val value2 = convertDurationUnit(value, unit, unit2)
val value2 = Duration.convert(value, unit, unit2)
val d2 = value2.toDuration(unit2)
assertEquals(d1, d2, "$value $unit in $unit2")
assertEquals(d1.hashCode(), d2.hashCode())
@@ -124,7 +124,7 @@ class DurationTest {
val unit = units.random()
val unit2 = units.random()
assertAlmostEquals(convertDurationUnit(value.toDouble(), unit, unit2), value.toDuration(unit).toDouble(unit2))
assertAlmostEquals(Duration.convert(value.toDouble(), unit, unit2), value.toDuration(unit).toDouble(unit2))
}
}
@@ -22,11 +22,11 @@ class DurationUnitTest {
fun conversion() {
fun test(sourceValue: Double, sourceUnit: DurationUnit, targetValue: Double, targetUnit: DurationUnit) {
assertEquals(
targetValue, convertDurationUnit(sourceValue, sourceUnit, targetUnit),
targetValue, Duration.convert(sourceValue, sourceUnit, targetUnit),
"Expected $sourceValue $sourceUnit to be $targetValue $targetUnit"
)
assertEquals(
sourceValue, convertDurationUnit(targetValue, targetUnit, sourceUnit),
sourceValue, Duration.convert(targetValue, targetUnit, sourceUnit),
"Expected $targetValue $targetUnit to be $sourceValue $sourceUnit"
)
}