package com.projectsacrifice.game; import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertFalse; import static org.junit.Assert.assertTrue; import org.junit.Test; public final class GameMathTest { @Test public void intersectionTreatsTouchingEdgesAsNonOverlap() { assertFalse(GameMath.intersects(0, 0, 10, 10, 10, 0, 10, 10)); assertTrue(GameMath.intersects(0, 0, 10, 10, 9.9f, 0, 10, 10)); } @Test public void pingPongIsDeterministicAndBounded() { assertEquals(0f, GameMath.pingPong(0f, 4f), 0.0001f); assertEquals(1f, GameMath.pingPong(2f, 4f), 0.0001f); assertEquals(0f, GameMath.pingPong(4f, 4f), 0.0001f); for (int i = 0; i < 100; i++) { float value = GameMath.pingPong(i * 0.13f, 3.7f); assertTrue(value >= 0f && value <= 1f); } } @Test public void timeFormattingIsStable() { assertEquals("00:00", GameMath.formatTime(999)); assertEquals("01:05", GameMath.formatTime(65_000)); } }