test: characterize ControlKeyModifer

Plain-JVM coverage is structural: the Java-facing isControlDown(EntityPlayer)
static that the reference scaladoc calls out as existing for Java callers, and
the typo in the class name, which is the published name.

Forge server coverage for the behavior. isControlDown branches on whether the
player's world is remote, so it needs a real player; a Forge FakePlayer on a
dedicated server world takes the server branch and reads the map the client
keeps in sync through packet 1. Unknown players default to not holding, the map
reflects the last recorded value, and clearing resets it.

The client branch reads isClientPressing instead and no harness has a client.

120 plain-JVM tests, 21 Forge server tests.
This commit is contained in:
Algent committed 2026-08-15 19:42:38 +02:00
1 parent 40bb1b71b7
commit 8f73a693cc
2 files changed
+111

No files matched your search

@@ -0,0 +1,35 @@
package codechicken.multipart;
import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertSame;
import static org.junit.jupiter.api.Assertions.assertTrue;
import java.lang.reflect.Method;
import java.lang.reflect.Modifier;
import net.minecraft.entity.player.EntityPlayer;
import org.junit.jupiter.api.Test;
/**
* Every branch of isControlDown needs a player with a world, so the behavior is covered by the Forge server suite
* against a FakePlayer. What is pinned here is the Java-facing entry point, which the reference scaladoc calls out as
* existing for Java callers rather than for the Scala implicit.
*/
class ControlKeyModiferCharacterizationTest {
/** The class name carries a typo in the reference. It is the published name, so the port keeps it. */
@Test
void theTypoInTheClassNameIsPreserved() {
assertEquals("codechicken.multipart.ControlKeyModifer", ControlKeyModifer.class.getName());
}
@Test
void theJavaFacingQueryIsAPublicStaticTakingAPlayer() throws Exception {
Method isControlDown = ControlKeyModifer.class.getDeclaredMethod("isControlDown", EntityPlayer.class);
assertSame(boolean.class, isControlDown.getReturnType());
assertTrue(Modifier.isPublic(isControlDown.getModifiers()));
assertTrue(Modifier.isStatic(isControlDown.getModifiers()));
}
}