2019-02-26 20:38:27 +01:00
|
|
|
package info.nightscout.androidaps.utils;
|
2016-12-28 15:58:44 +01:00
|
|
|
|
|
|
|
import org.junit.Test;
|
|
|
|
|
|
|
|
import static org.junit.Assert.*;
|
|
|
|
|
|
|
|
public class RoundTest {
|
|
|
|
|
2016-12-30 16:43:43 +01:00
|
|
|
public RoundTest(){
|
|
|
|
super();
|
|
|
|
}
|
|
|
|
|
2016-12-28 15:58:44 +01:00
|
|
|
@Test
|
2016-12-30 16:43:43 +01:00
|
|
|
public void roundToTest() throws Exception {
|
2016-12-28 15:58:44 +01:00
|
|
|
assertEquals( 0.55d, Round.roundTo(0.54d, 0.05d), 0.00000001d );
|
|
|
|
assertEquals( 1d, Round.roundTo(1.49d, 1d), 0.00000001d );
|
2018-01-10 23:57:02 +01:00
|
|
|
assertEquals( 0d, Round.roundTo(0d, 1d), 0.00000001d );
|
2016-12-28 15:58:44 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
@Test
|
2016-12-30 16:43:43 +01:00
|
|
|
public void floorToTest() throws Exception {
|
2016-12-28 15:58:44 +01:00
|
|
|
assertEquals( 0.5d, Round.floorTo(0.54d, 0.05d), 0.00000001d );
|
|
|
|
assertEquals( 1d, Round.floorTo(1.59d, 1d), 0.00000001d );
|
2018-01-10 23:57:02 +01:00
|
|
|
assertEquals( 0d, Round.floorTo(0d, 1d), 0.00000001d );
|
2016-12-28 15:58:44 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
@Test
|
2016-12-30 16:43:43 +01:00
|
|
|
public void ceilToTest() throws Exception {
|
2016-12-28 15:58:44 +01:00
|
|
|
assertEquals( 0.6d, Round.ceilTo(0.54d, 0.1d), 0.00000001d );
|
|
|
|
assertEquals( 2d, Round.ceilTo(1.49999d, 1d), 0.00000001d );
|
2018-01-10 23:57:02 +01:00
|
|
|
assertEquals( 0d, Round.ceilTo(0d, 1d), 0.00000001d );
|
2016-12-28 15:58:44 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
}
|