move test to core

This commit is contained in:
Milos Kozak 2021-02-18 17:01:41 +01:00
parent 73da2a1a3f
commit 6d32516aec
3 changed files with 41 additions and 41 deletions

View file

@ -1,41 +0,0 @@
package info.nightscout.androidaps.utils;
import org.junit.Test;
import static org.junit.Assert.*;
public class RoundTest {
public RoundTest(){
super();
}
@Test
public void roundToTest() throws Exception {
assertEquals( 0.55d, Round.roundTo(0.54d, 0.05d), 0.00000000000000000001d );
assertEquals( -3.26d, Round.roundTo(-3.2553715764602713d, 0.01d), 0.00000000000000000001d );
assertEquals( 0.816d, Round.roundTo(0.8156666666666667d, 0.001d), 0.00000000000000000001d );
assertEquals( 0.235d, Round.roundTo(0.235d, 0.001d), 0.00000000000000000001d );
assertEquals( 0.3d, Round.roundTo(0.3d, 0.1d), 0.00000000000000001d );
assertEquals( 0.0017d, Round.roundTo(0.0016960652144170627d, 0.0001d), 0.00000000000000000001d );
assertEquals( 0.0078d, Round.roundTo(0.007804436682291013d, 0.0001d), 0.00000000000000000001d );
assertEquals( 0.6d, Round.roundTo(0.6d, 0.05d), 0.00000000000000000001d );
assertEquals( 1d, Round.roundTo(1.49d, 1d), 0.00000000000000000001d );
assertEquals( 0d, Round.roundTo(0d, 1d), 0.00000000000000000001d );
}
@Test
public void floorToTest() throws Exception {
assertEquals( 0.5d, Round.floorTo(0.54d, 0.05d), 0.00000001d );
assertEquals( 1d, Round.floorTo(1.59d, 1d), 0.00000001d );
assertEquals( 0d, Round.floorTo(0d, 1d), 0.00000001d );
}
@Test
public void ceilToTest() throws Exception {
assertEquals( 0.6d, Round.ceilTo(0.54d, 0.1d), 0.00000001d );
assertEquals( 2d, Round.ceilTo(1.49999d, 1d), 0.00000001d );
assertEquals( 0d, Round.ceilTo(0d, 1d), 0.00000001d );
}
}

View file

@ -36,6 +36,12 @@ android {
ext.enableCrashlytics = false
}
}
flavorDimensions "standard"
productFlavors {
full {
dimension "standard"
}
}
compileOptions {
sourceCompatibility JavaVersion.VERSION_1_8
targetCompatibility JavaVersion.VERSION_1_8

View file

@ -0,0 +1,35 @@
package info.nightscout.androidaps.utils
import org.junit.Assert
import org.junit.Test
class RoundTest {
@Test
fun roundToTest() {
Assert.assertEquals(0.55, Round.roundTo(0.54, 0.05), 0.00000000000000000001)
Assert.assertEquals(-3.26, Round.roundTo(-3.2553715764602713, 0.01), 0.00000000000000000001)
Assert.assertEquals(0.816, Round.roundTo(0.8156666666666667, 0.001), 0.00000000000000000001)
Assert.assertEquals(0.235, Round.roundTo(0.235, 0.001), 0.00000000000000000001)
Assert.assertEquals(0.3, Round.roundTo(0.3, 0.1), 0.00000000000000001)
Assert.assertEquals(0.0017, Round.roundTo(0.0016960652144170627, 0.0001), 0.00000000000000000001)
Assert.assertEquals(0.0078, Round.roundTo(0.007804436682291013, 0.0001), 0.00000000000000000001)
Assert.assertEquals(0.6, Round.roundTo(0.6, 0.05), 0.00000000000000000001)
Assert.assertEquals(1.0, Round.roundTo(1.49, 1.0), 0.00000000000000000001)
Assert.assertEquals(0.0, Round.roundTo(0.0, 1.0), 0.00000000000000000001)
}
@Test
fun floorToTest() {
Assert.assertEquals(0.5, Round.floorTo(0.54, 0.05), 0.00000001)
Assert.assertEquals(1.0, Round.floorTo(1.59, 1.0), 0.00000001)
Assert.assertEquals(0.0, Round.floorTo(0.0, 1.0), 0.00000001)
}
@Test
fun ceilToTest() {
Assert.assertEquals(0.6, Round.ceilTo(0.54, 0.1), 0.00000001)
Assert.assertEquals(2.0, Round.ceilTo(1.49999, 1.0), 0.00000001)
Assert.assertEquals(0.0, Round.ceilTo(0.0, 1.0), 0.00000001)
}
}