package xyz.cottongin.radio247.audio

import org.junit.Assert.assertEquals
import org.junit.Test

class AudioEngineVolumeTest {

    @Test
    fun setVolumeDoesNotCrashWhenNoTrack() {
        val engine = AudioEngine("http://example.com/stream")
        engine.setVolume(0.5f)
        engine.setVolume(0f)
        engine.setVolume(1f)
    }

    @Test
    fun volumeClampValues() {
        val clamped1 = (-0.5f).coerceIn(0f, 1f)
        assertEquals(0f, clamped1, 0.001f)

        val clamped2 = (1.5f).coerceIn(0f, 1f)
        assertEquals(1f, clamped2, 0.001f)

        val clamped3 = (0.2f).coerceIn(0f, 1f)
        assertEquals(0.2f, clamped3, 0.001f)
    }
}
