From 618ce4355836319b783ee92a3a9ad54c71cc29ea Mon Sep 17 00:00:00 2001 From: Saraansh Wadkar Date: Mon, 16 Jan 2023 12:25:31 -0500 Subject: [PATCH] fix pounds to kg conversion --- build.gradle | 2 +- src/main/kotlin/org/team4099/lib/units/base/Mass.kt | 2 +- src/test/kotlin/team4099/units/MassTest.kt | 5 ++--- 3 files changed, 4 insertions(+), 5 deletions(-) diff --git a/build.gradle b/build.gradle index 89ab7cf..8f118f7 100644 --- a/build.gradle +++ b/build.gradle @@ -51,7 +51,7 @@ publishing { release(MavenPublication) { groupId = 'org.team4099' artifactId = 'falconutils' - version = '1.0.5' + version = '1.0.6' from(components["kotlin"]) } diff --git a/src/main/kotlin/org/team4099/lib/units/base/Mass.kt b/src/main/kotlin/org/team4099/lib/units/base/Mass.kt index 0d876a1..d26f8f1 100644 --- a/src/main/kotlin/org/team4099/lib/units/base/Mass.kt +++ b/src/main/kotlin/org/team4099/lib/units/base/Mass.kt @@ -34,7 +34,7 @@ val Double.grams: Mass get() = Mass(this / 1000) val Double.pounds: Mass - get() = Mass(this * GRAMS_PER_POUND) + get() = Mass(this * GRAMS_PER_POUND / 1000) val Number.grams: Mass get() = toDouble().grams diff --git a/src/test/kotlin/team4099/units/MassTest.kt b/src/test/kotlin/team4099/units/MassTest.kt index 890ceab..3807845 100644 --- a/src/test/kotlin/team4099/units/MassTest.kt +++ b/src/test/kotlin/team4099/units/MassTest.kt @@ -2,7 +2,6 @@ package com.team4099.units import org.junit.jupiter.api.Assertions.assertEquals import org.junit.jupiter.api.Test -import org.team4099.lib.units.base.GRAMS_PER_POUND import org.team4099.lib.units.base.grams import org.team4099.lib.units.base.inAttograms import org.team4099.lib.units.base.inCentigrams @@ -35,13 +34,13 @@ class MassTest { @Test fun testGramsToPounds() { val weightGrams = 4099.grams - assertEquals(weightGrams.inPounds, weightGrams.inGrams / GRAMS_PER_POUND, kEpsilon) + assertEquals(weightGrams.inPounds, 9.036747529279591, kEpsilon) } @Test fun testPoundsToGrams() { val weightPounds = 4099.pounds - assertEquals(weightPounds.inGrams, weightPounds.inPounds * GRAMS_PER_POUND, kEpsilon) + assertEquals(weightPounds.inGrams, 1859275.2476, kEpsilon) } @Test