package com.onthelevel.core.sensors

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

class SurfaceGuidanceTest {
    @Test fun `bubble mapping follows pitch roll and clamps before animation`() {
        val guidance = SurfaceGuidance.from(2.0, -3.0)
        assertEquals(-0.6, guidance.normalizedX, 1e-9)
        assertEquals(-0.4, guidance.normalizedY, 1e-9)
        val clamped = SurfaceGuidance.from(-8.0, 9.0)
        assertEquals(1.0, clamped.normalizedX, 1e-9)
        assertEquals(1.0, clamped.normalizedY, 1e-9)
    }

    @Test fun `direction uses edges for dominant axes and corners otherwise`() {
        assertEquals("High: top edge", SurfaceGuidance.from(2.0, 0.2).highLabel)
        assertEquals("High: bottom-left", SurfaceGuidance.from(-2.0, -2.0).highLabel)
        assertEquals("High: top-right", SurfaceGuidance.from(2.0, 2.0).highLabel)
        assertNull(SurfaceGuidance.from(0.05, -0.05).highLabel)
    }

    @Test fun `rings share the visual degree scale`() {
        assertEquals(0.2, SurfaceGuidance.ringRadiusRatio(1.0), 1e-9)
        assertEquals(0.4, SurfaceGuidance.ringRadiusRatio(2.0), 1e-9)
        assertEquals(1.0, SurfaceGuidance.ringRadiusRatio(5.0), 1e-9)
    }
}
