package ru.dbotthepony.mc.otm.tests

import org.junit.jupiter.api.Assertions.assertEquals
import org.junit.jupiter.api.DisplayName
import org.junit.jupiter.api.Test
import ru.dbotthepony.mc.otm.core.util.TickList

object TimerQueueTests {
	@Test
	@DisplayName("TimerQueue test")
	fun test() {
		val queue = TickList()

		var state = 0

		queue.Timer(1) { state = 1 }
		queue.Timer(2) { state = 2 }
		queue.Timer(3) { state = 3 }
		queue.Timer(7) { state = 7 }
		queue.Timer(6) { state = 6 }
		queue.Timer(2) { state = 2 }

		queue.tick() // 1
		assertEquals(1, state)
		queue.tick() // 2 + 2
		assertEquals(2, state)
		queue.tick() // 3
		assertEquals(3, state)
		queue.tick() // 4
		assertEquals(3, state)
		queue.tick() // 5
		assertEquals(3, state)
		queue.tick() // 6
		assertEquals(6, state)
		queue.tick() // 7
		assertEquals(7, state)
		queue.tick() // 8
		assertEquals(7, state)
	}
}
