diff --git a/app/build.gradle b/app/build.gradle index d4b18b1df0..3289276b59 100644 --- a/app/build.gradle +++ b/app/build.gradle @@ -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}" diff --git a/app/src/test/java/info/nightscout/androidaps/plugins/PumpInsight/HelpersTest.java b/app/src/test/java/info/nightscout/androidaps/plugins/PumpInsight/HelpersTest.java new file mode 100644 index 0000000000..885edfac61 --- /dev/null +++ b/app/src/test/java/info/nightscout/androidaps/plugins/PumpInsight/HelpersTest.java @@ -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); + + } + + + +} \ No newline at end of file