diff options
Diffstat (limited to 'android-app/app/src/test/kotlin')
| -rw-r--r-- | android-app/app/src/test/kotlin/com/example/androidapp/safety/AnchorWatchStateTest.kt | 32 |
1 files changed, 32 insertions, 0 deletions
diff --git a/android-app/app/src/test/kotlin/com/example/androidapp/safety/AnchorWatchStateTest.kt b/android-app/app/src/test/kotlin/com/example/androidapp/safety/AnchorWatchStateTest.kt new file mode 100644 index 0000000..40f7df0 --- /dev/null +++ b/android-app/app/src/test/kotlin/com/example/androidapp/safety/AnchorWatchStateTest.kt @@ -0,0 +1,32 @@ +package com.example.androidapp.safety + +import org.junit.Assert.* +import org.junit.Test +import kotlin.math.sqrt + +class AnchorWatchStateTest { + + private val state = AnchorWatchState() + + @Test + fun calculateRecommendedWatchCircleRadius_validGeometry() { + // depth=6m, rode=50m → vertical=8m, radius=sqrt(50²-8²)=sqrt(2436) + val expected = sqrt(2436.0) + val actual = state.calculateRecommendedWatchCircleRadius(depthM = 6.0, rodeOutM = 50.0) + assertEquals(expected, actual, 0.001) + } + + @Test + fun calculateRecommendedWatchCircleRadius_rodeShorterThanVertical_fallsBackToRode() { + // depth=10m, rode=5m → vertical=12m > rode, fallback returns rode + val actual = state.calculateRecommendedWatchCircleRadius(depthM = 10.0, rodeOutM = 5.0) + assertEquals(5.0, actual, 0.001) + } + + @Test + fun calculateRecommendedWatchCircleRadius_rodeEqualsVertical_fallsBackToRode() { + // depth=8m, rode=10m → vertical=10m == rode, fallback returns rode + val actual = state.calculateRecommendedWatchCircleRadius(depthM = 8.0, rodeOutM = 10.0) + assertEquals(10.0, actual, 0.001) + } +} |
