blob: a292eef11c15806347c6788b2089692a1813672b [file] [log] [blame]
package android.dawn
import android.dawn.helper.roundDownToNearestMultipleOf
import android.dawn.helper.roundUpToNearestMultipleOf
import org.junit.Assert
import org.junit.Test
class RoundingTest {
@Test
fun roundingIsCorrect() {
Assert.assertEquals(1000, 1234.roundDownToNearestMultipleOf(1000));
Assert.assertEquals(2000, 1234.roundUpToNearestMultipleOf(1000));
Assert.assertEquals(-2000, (-1234).roundDownToNearestMultipleOf(1000));
Assert.assertEquals(-1000, (-1234).roundUpToNearestMultipleOf(1000));
// Int.MAX_VALUE is 2,147,483,647 (2^31 - 1)
Assert.assertEquals(2_147_483_000L, 2_147_483_648L.roundDownToNearestMultipleOf(1000));
Assert.assertEquals(2_147_484_000L, 2_147_483_648L.roundUpToNearestMultipleOf(1000));
Assert.assertEquals(1000, 1000.roundDownToNearestMultipleOf(1000));
Assert.assertEquals(1000, 1000.roundUpToNearestMultipleOf(1000));
Assert.assertEquals(-1000, (-1000).roundDownToNearestMultipleOf(1000));
Assert.assertEquals(-1000, (-1000).roundUpToNearestMultipleOf(1000));
}
}