diff options
author | Yasin <a.piri@hotmail.de> | 2023-10-09 12:58:02 +0200 |
---|---|---|
committer | Yasin <a.piri@hotmail.de> | 2023-10-09 12:58:02 +0200 |
commit | bd3f0329d0e391bd84b5f9e3ff207d9dd9815853 (patch) | |
tree | 2fd1d1ef625f57acc2e4916c967d8d2393844798 /src/test/java/me/xmrvizzy/skyblocker/utils | |
parent | 2315b90da8117f28f66348927afdb621ee4fc815 (diff) | |
download | Skyblocker-bd3f0329d0e391bd84b5f9e3ff207d9dd9815853.tar.gz Skyblocker-bd3f0329d0e391bd84b5f9e3ff207d9dd9815853.tar.bz2 Skyblocker-bd3f0329d0e391bd84b5f9e3ff207d9dd9815853.zip |
new pr because fixing merge conflict would take too long
Diffstat (limited to 'src/test/java/me/xmrvizzy/skyblocker/utils')
-rw-r--r-- | src/test/java/me/xmrvizzy/skyblocker/utils/chat/ChatPatternListenerTest.java | 28 | ||||
-rw-r--r-- | src/test/java/me/xmrvizzy/skyblocker/utils/scheduler/SchedulerTest.java | 88 |
2 files changed, 0 insertions, 116 deletions
diff --git a/src/test/java/me/xmrvizzy/skyblocker/utils/chat/ChatPatternListenerTest.java b/src/test/java/me/xmrvizzy/skyblocker/utils/chat/ChatPatternListenerTest.java deleted file mode 100644 index 5d6f5727..00000000 --- a/src/test/java/me/xmrvizzy/skyblocker/utils/chat/ChatPatternListenerTest.java +++ /dev/null @@ -1,28 +0,0 @@ -package me.xmrvizzy.skyblocker.utils.chat; - -import java.util.regex.Matcher; - -import static org.junit.jupiter.api.Assertions.assertEquals; -import static org.junit.jupiter.api.Assertions.assertTrue; - -public abstract class ChatPatternListenerTest<T extends ChatPatternListener> { - protected final T listener; - - public ChatPatternListenerTest(T listener) { - this.listener = listener; - } - - protected Matcher matcher(String message) { - return listener.pattern.matcher(message); - } - - protected void assertMatches(String message) { - assertTrue(matcher(message).matches()); - } - - protected void assertGroup(String message, int group, String expect) { - Matcher matcher = matcher(message); - assertTrue(matcher.matches()); - assertEquals(expect, matcher.group(group)); - } -}
\ No newline at end of file diff --git a/src/test/java/me/xmrvizzy/skyblocker/utils/scheduler/SchedulerTest.java b/src/test/java/me/xmrvizzy/skyblocker/utils/scheduler/SchedulerTest.java deleted file mode 100644 index 5b3317ab..00000000 --- a/src/test/java/me/xmrvizzy/skyblocker/utils/scheduler/SchedulerTest.java +++ /dev/null @@ -1,88 +0,0 @@ -package me.xmrvizzy.skyblocker.utils.scheduler; - -import org.apache.commons.lang3.mutable.MutableInt; -import org.junit.jupiter.api.Assertions; -import org.junit.jupiter.api.Test; - -public class SchedulerTest { - private final MutableInt currentTick = new MutableInt(0); - private final MutableInt cycleCount1 = new MutableInt(0); - private final MutableInt cycleCount2 = new MutableInt(0); - private final MutableInt cycleCount3 = new MutableInt(0); - private final MutableInt cycleCount4 = new MutableInt(0); - private final MutableInt cycleCount5 = new MutableInt(0); - private final MutableInt cycleCount6 = new MutableInt(0); - private final MutableInt cycleCount7 = new MutableInt(0); - private final MutableInt cycleCount8 = new MutableInt(0); - - @Test - public void testSchedule() { - Scheduler.INSTANCE.schedule(() -> Assertions.assertEquals(0, currentTick.intValue()), 0); - Scheduler.INSTANCE.schedule(() -> Assertions.assertEquals(1, currentTick.intValue()), 1); - Scheduler.INSTANCE.schedule(() -> Assertions.assertEquals(2, currentTick.intValue()), 2); - Scheduler.INSTANCE.schedule(() -> Assertions.assertEquals(10, currentTick.intValue()), 10); - Scheduler.INSTANCE.schedule(() -> Assertions.assertEquals(20, currentTick.intValue()), 20); - Scheduler.INSTANCE.schedule(() -> Assertions.assertEquals(50, currentTick.intValue()), 50); - Scheduler.INSTANCE.schedule(() -> Assertions.assertEquals(100, currentTick.intValue()), 100); - Scheduler.INSTANCE.schedule(() -> Assertions.assertEquals(123, currentTick.intValue()), 123); - Scheduler.INSTANCE.scheduleCyclic(() -> {}, 1); - Scheduler.INSTANCE.scheduleCyclic(() -> {}, 1); - Scheduler.INSTANCE.scheduleCyclic(() -> {}, 1); - Scheduler.INSTANCE.scheduleCyclic(() -> {}, 1); - Scheduler.INSTANCE.scheduleCyclic(() -> { - Assertions.assertEquals(cycleCount1.intValue(), currentTick.intValue()); - cycleCount1.increment(); - }, 1); - Scheduler.INSTANCE.scheduleCyclic(() -> { - Assertions.assertEquals(0, currentTick.intValue() % 10); - Assertions.assertEquals(cycleCount2.intValue(), currentTick.intValue() / 10); - cycleCount2.increment(); - }, 10); - Scheduler.INSTANCE.scheduleCyclic(() -> { - Assertions.assertEquals(0, currentTick.intValue() % 55); - Assertions.assertEquals(cycleCount3.intValue(), currentTick.intValue() / 55); - cycleCount3.increment(); - }, 55); - Scheduler.INSTANCE.schedule(() -> Scheduler.INSTANCE.scheduleCyclic(() -> { - Assertions.assertEquals(7, currentTick.intValue() % 10); - Assertions.assertEquals(cycleCount4.intValue(), currentTick.intValue() / 10); - cycleCount4.increment(); - }, 10), 7); - Scheduler.INSTANCE.schedule(() -> Scheduler.INSTANCE.scheduleCyclic(() -> { - Assertions.assertEquals(0, currentTick.intValue() % 75); - Assertions.assertEquals(cycleCount5.intValue(), currentTick.intValue() / 75); - cycleCount5.increment(); - }, 75), 0); - Scheduler.INSTANCE.schedule(() -> Scheduler.INSTANCE.scheduleCyclic(() -> { - Assertions.assertEquals(1, currentTick.intValue() % 99); - Assertions.assertEquals(cycleCount6.intValue(), currentTick.intValue() / 99); - cycleCount6.increment(); - }, 99), 1); - Scheduler.INSTANCE.scheduleCyclic(() -> Scheduler.INSTANCE.schedule(() -> { - Assertions.assertEquals(5, currentTick.intValue() % 10); - Assertions.assertEquals(cycleCount7.intValue(), currentTick.intValue() / 10); - cycleCount7.increment(); - }, 5), 10); - Scheduler.INSTANCE.scheduleCyclic(() -> Scheduler.INSTANCE.schedule(() -> { - Assertions.assertEquals(10, currentTick.intValue() % 55); - Assertions.assertEquals(cycleCount8.intValue(), currentTick.intValue() / 55); - cycleCount8.increment(); - }, 10), 55); - while (currentTick.intValue() < 100_000) { - tick(); - } - Assertions.assertEquals(100000, cycleCount1.intValue()); - Assertions.assertEquals(10000, cycleCount2.intValue()); - Assertions.assertEquals(1819, cycleCount3.intValue()); - Assertions.assertEquals(10000, cycleCount4.intValue()); - Assertions.assertEquals(1334, cycleCount5.intValue()); - Assertions.assertEquals(1011, cycleCount6.intValue()); - Assertions.assertEquals(10000, cycleCount7.intValue()); - Assertions.assertEquals(1818, cycleCount8.intValue()); - } - - private void tick() { - Scheduler.INSTANCE.tick(); - currentTick.increment(); - } -} |