Add unit test

This commit is contained in:
Jamorham 2018-01-26 22:44:12 +00:00
parent b831fd7dfb
commit 2c9cd89ff3
No known key found for this signature in database
GPG key ID: 0BC5C3E0AAD64DF9
2 changed files with 32 additions and 0 deletions

View file

@ -214,6 +214,7 @@ dependencies {
testCompile "org.powermock:powermock-module-junit4-rule:${powermockVersion}"
testCompile "org.powermock:powermock-module-junit4:${powermockVersion}"
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 "com.google.dexmaker:dexmaker:${dexmakerVersion}"

View file

@ -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);
}
}