Skip to content

Commit

Permalink
fix pounds to kg conversion
Browse files Browse the repository at this point in the history
  • Loading branch information
sswadkar committed Jan 16, 2023
1 parent ec61922 commit 618ce43
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 5 deletions.
2 changes: 1 addition & 1 deletion build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ publishing {
release(MavenPublication) {
groupId = 'org.team4099'
artifactId = 'falconutils'
version = '1.0.5'
version = '1.0.6'

from(components["kotlin"])
}
Expand Down
2 changes: 1 addition & 1 deletion src/main/kotlin/org/team4099/lib/units/base/Mass.kt
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
5 changes: 2 additions & 3 deletions src/test/kotlin/team4099/units/MassTest.kt
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down

0 comments on commit 618ce43

Please sign in to comment.