Add unit test
This commit is contained in:
parent
b831fd7dfb
commit
2c9cd89ff3
2 changed files with 32 additions and 0 deletions
|
@ -214,6 +214,7 @@ dependencies {
|
||||||
testCompile "org.powermock:powermock-module-junit4-rule:${powermockVersion}"
|
testCompile "org.powermock:powermock-module-junit4-rule:${powermockVersion}"
|
||||||
testCompile "org.powermock:powermock-module-junit4:${powermockVersion}"
|
testCompile "org.powermock:powermock-module-junit4:${powermockVersion}"
|
||||||
testCompile "joda-time:joda-time:2.9.4.2"
|
testCompile "joda-time:joda-time:2.9.4.2"
|
||||||
|
testCompile "com.google.truth:truth:0.39"
|
||||||
|
|
||||||
androidTestCompile "org.mockito:mockito-core:2.7.22"
|
androidTestCompile "org.mockito:mockito-core:2.7.22"
|
||||||
androidTestCompile "com.google.dexmaker:dexmaker:${dexmakerVersion}"
|
androidTestCompile "com.google.dexmaker:dexmaker:${dexmakerVersion}"
|
||||||
|
|
|
@ -0,0 +1,31 @@
|
||||||
|
package info.nightscout.androidaps.plugins.PumpInsight;
|
||||||
|
|
||||||
|
|
||||||
|
import com.google.common.truth.Truth;
|
||||||
|
|
||||||
|
import org.junit.Test;
|
||||||
|
|
||||||
|
import static info.nightscout.androidaps.plugins.PumpInsight.utils.Helpers.roundDouble;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Created by jamorham on 26.01.2018.
|
||||||
|
*/
|
||||||
|
|
||||||
|
public class HelpersTest {
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void checkRounding() throws Exception {
|
||||||
|
|
||||||
|
// TODO more test cases including known precision breakdowns
|
||||||
|
|
||||||
|
Truth.assertThat(roundDouble(Double.parseDouble("0.999999"),0))
|
||||||
|
.isEqualTo(1d);
|
||||||
|
|
||||||
|
Truth.assertThat(roundDouble(Double.parseDouble("0.123456"),0))
|
||||||
|
.isEqualTo(0d);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
}
|
Loading…
Reference in a new issue