blob: 576a77a34c53b1fd20f0a27f72427703fd911c6d [file] [log] [blame]
package androidx.webgpu
import androidx.webgpu.helper.roundDownToNearestMultipleOf
import androidx.webgpu.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));
}
}