test(US-04): add failing tests for BPM interval calculation and volume clamping
This commit is contained in:
parent
4d72536d78
commit
8e08a53d30
1 changed files with 42 additions and 0 deletions
42
app/src/test/kotlin/net/jeena/pacer/BpmCalculatorTest.kt
Normal file
42
app/src/test/kotlin/net/jeena/pacer/BpmCalculatorTest.kt
Normal file
|
|
@ -0,0 +1,42 @@
|
||||||
|
package net.jeena.pacer
|
||||||
|
|
||||||
|
import org.junit.Assert.assertEquals
|
||||||
|
import org.junit.Assert.assertTrue
|
||||||
|
import org.junit.Test
|
||||||
|
|
||||||
|
class BpmCalculatorTest {
|
||||||
|
|
||||||
|
@Test
|
||||||
|
fun `intervalMs returns 1000ms for 60 BPM`() {
|
||||||
|
assertEquals(1000L, BpmCalculator.intervalMs(60))
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
fun `intervalMs returns 500ms for 120 BPM`() {
|
||||||
|
assertEquals(500L, BpmCalculator.intervalMs(120))
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
fun `intervalMs returns correct value for 130 BPM`() {
|
||||||
|
// 60000 / 130 = 461ms
|
||||||
|
assertEquals(461L, BpmCalculator.intervalMs(130))
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
fun `intervalMs returns correct value for 80 BPM`() {
|
||||||
|
assertEquals(750L, BpmCalculator.intervalMs(80))
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
fun `clampVolume keeps value within 0 to 1`() {
|
||||||
|
assertEquals(0f, BpmCalculator.clampVolume(-0.5f))
|
||||||
|
assertEquals(1f, BpmCalculator.clampVolume(1.5f))
|
||||||
|
assertEquals(0.7f, BpmCalculator.clampVolume(0.7f))
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
fun `intervalMs decreases as BPM increases`() {
|
||||||
|
assertTrue(BpmCalculator.intervalMs(60) > BpmCalculator.intervalMs(120))
|
||||||
|
assertTrue(BpmCalculator.intervalMs(120) > BpmCalculator.intervalMs(180))
|
||||||
|
}
|
||||||
|
}
|
||||||
Loading…
Add table
Add a link
Reference in a new issue