You've already forked Arcturus-Morningstar-Extended
mirror of
https://github.com/duckietm/Arcturus-Morningstar-Extended.git
synced 2026-06-20 07:26:18 +00:00
Merge pull request #241 from simoleo89/fix/wired-match-position-inputs
fix(wired): bound match position inputs
This commit is contained in:
+33
@@ -0,0 +1,33 @@
|
||||
package com.eu.habbo.habbohotel.items.interactions.wired.conditions;
|
||||
|
||||
import com.eu.habbo.habbohotel.wired.core.WiredSourceUtil;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
import static org.junit.jupiter.api.Assertions.assertEquals;
|
||||
import static org.junit.jupiter.api.Assertions.assertFalse;
|
||||
|
||||
class WiredMatchPositionInputGuardTest {
|
||||
|
||||
@Test
|
||||
void furniSourcesFallBackToTriggerWhenUnknown() {
|
||||
assertEquals(WiredSourceUtil.SOURCE_TRIGGER, WiredMatchPositionInputGuard.normalizeFurniSource(-1, false));
|
||||
assertEquals(WiredSourceUtil.SOURCE_SELECTOR, WiredMatchPositionInputGuard.normalizeFurniSource(WiredSourceUtil.SOURCE_SELECTOR, false));
|
||||
assertEquals(WiredSourceUtil.SOURCE_SIGNAL, WiredMatchPositionInputGuard.normalizeFurniSource(WiredSourceUtil.SOURCE_SIGNAL, false));
|
||||
}
|
||||
|
||||
@Test
|
||||
void selectedSettingsPromoteTriggerSourceToSelected() {
|
||||
assertEquals(WiredSourceUtil.SOURCE_SELECTED,
|
||||
WiredMatchPositionInputGuard.normalizeFurniSource(WiredSourceUtil.SOURCE_TRIGGER, true));
|
||||
}
|
||||
|
||||
@Test
|
||||
void stateIsNullSafeSingleLineAndBounded() {
|
||||
assertEquals("", WiredMatchPositionInputGuard.normalizeState(null));
|
||||
assertEquals("a b c", WiredMatchPositionInputGuard.normalizeState("a\tb\nc"));
|
||||
String longState = "x".repeat(WiredMatchPositionInputGuard.MAX_STATE_LENGTH + 10);
|
||||
String normalized = WiredMatchPositionInputGuard.normalizeState(longState);
|
||||
assertEquals(WiredMatchPositionInputGuard.MAX_STATE_LENGTH, normalized.length());
|
||||
assertFalse(normalized.contains("\n"));
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user