From 04524db1a56435ac3fa47d8dfbede5da64d065c4 Mon Sep 17 00:00:00 2001 From: DBotThePony Date: Thu, 17 Aug 2023 14:33:26 +0700 Subject: [PATCH] TickList tests --- .../{TimerQueueTests.kt => TickListTests.kt} | 29 +++++++++++++++++-- 1 file changed, 26 insertions(+), 3 deletions(-) rename src/test/kotlin/ru/dbotthepony/mc/otm/tests/{TimerQueueTests.kt => TickListTests.kt} (66%) diff --git a/src/test/kotlin/ru/dbotthepony/mc/otm/tests/TimerQueueTests.kt b/src/test/kotlin/ru/dbotthepony/mc/otm/tests/TickListTests.kt similarity index 66% rename from src/test/kotlin/ru/dbotthepony/mc/otm/tests/TimerQueueTests.kt rename to src/test/kotlin/ru/dbotthepony/mc/otm/tests/TickListTests.kt index d38e66af7..b489731ef 100644 --- a/src/test/kotlin/ru/dbotthepony/mc/otm/tests/TimerQueueTests.kt +++ b/src/test/kotlin/ru/dbotthepony/mc/otm/tests/TickListTests.kt @@ -5,10 +5,10 @@ import org.junit.jupiter.api.DisplayName import org.junit.jupiter.api.Test import ru.dbotthepony.mc.otm.core.util.TickList -object TimerQueueTests { +object TickListTests { @Test - @DisplayName("TimerQueue test") - fun test() { + @DisplayName("TickList.Timer test") + fun timers() { val queue = TickList() var state = 0 @@ -37,4 +37,27 @@ object TimerQueueTests { queue.tick() // 8 assertEquals(7, state) } + + @Test + @DisplayName("TickList test") + fun ticks() { + val list = TickList() + + var a = false + var b = 0 + var c = 0 + + list.once { a = true } + list.add { ++b < 4 } + list.always { c++ } + + for (i in 0 .. 10) { + list.tick() + } + + assertEquals(11, list.ticks) + assertEquals(11, c) + assertEquals(true, a) + assertEquals(4, b) + } }