diff options
Diffstat (limited to 'src/test/kotlin/util')
| -rw-r--r-- | src/test/kotlin/util/math/ProjectionsBoxTest.kt | 28 | ||||
| -rw-r--r-- | src/test/kotlin/util/skyblock/AbilityUtilsTest.kt | 12 | ||||
| -rw-r--r-- | src/test/kotlin/util/skyblock/TabListAPITest.kt | 48 | ||||
| -rw-r--r-- | src/test/kotlin/util/skyblock/TimestampTest.kt | 28 |
4 files changed, 110 insertions, 6 deletions
diff --git a/src/test/kotlin/util/math/ProjectionsBoxTest.kt b/src/test/kotlin/util/math/ProjectionsBoxTest.kt new file mode 100644 index 0000000..dc06e4b --- /dev/null +++ b/src/test/kotlin/util/math/ProjectionsBoxTest.kt @@ -0,0 +1,28 @@ +package moe.nea.firmament.test.util.math + +import java.util.stream.Stream +import org.junit.jupiter.api.Assertions +import org.junit.jupiter.api.DynamicTest +import org.junit.jupiter.api.TestFactory +import kotlin.streams.asStream +import net.minecraft.world.phys.Vec2 +import moe.nea.firmament.util.math.Projections + +class ProjectionsBoxTest { + val Double.degrees get() = Math.toRadians(this) + + @TestFactory + fun testProjections(): Stream<DynamicTest> { + return sequenceOf( + 0.0.degrees to Vec2(1F, 0F), + 63.4349.degrees to Vec2(0.5F, 1F), + ).map { (angle, expected) -> + DynamicTest.dynamicTest("ProjectionsBoxTest::projectAngleOntoUnitBox(${angle})") { + val actual = Projections.Two.projectAngleOntoUnitBox(angle) + fun msg() = "Expected (${expected.x}, ${expected.y}) got (${actual.x}, ${actual.y})" + Assertions.assertEquals(expected.x, actual.x, 0.0001F, ::msg) + Assertions.assertEquals(expected.y, actual.y, 0.0001F, ::msg) + } + }.asStream() + } +} diff --git a/src/test/kotlin/util/skyblock/AbilityUtilsTest.kt b/src/test/kotlin/util/skyblock/AbilityUtilsTest.kt index 9d25aad..43a3212 100644 --- a/src/test/kotlin/util/skyblock/AbilityUtilsTest.kt +++ b/src/test/kotlin/util/skyblock/AbilityUtilsTest.kt @@ -4,7 +4,7 @@ import org.junit.jupiter.api.Assertions import org.junit.jupiter.api.Test import kotlin.time.Duration.Companion.minutes import kotlin.time.Duration.Companion.seconds -import net.minecraft.text.Text +import net.minecraft.network.chat.Component import moe.nea.firmament.test.testutil.ItemResources import moe.nea.firmament.util.skyblock.AbilityUtils import moe.nea.firmament.util.unformattedString @@ -12,7 +12,7 @@ import moe.nea.firmament.util.unformattedString class AbilityUtilsTest { fun List<AbilityUtils.ItemAbility>.stripDescriptions() = map { - it.copy(descriptionLines = it.descriptionLines.map { Text.literal(it.unformattedString) }) + it.copy(descriptionLines = it.descriptionLines.map { Component.literal(it.unformattedString) }) } @Test @@ -28,7 +28,7 @@ class AbilityUtilsTest { "Throw your pickaxe to create an", "explosion mining all ores in a 3 block", "radius." - ).map(Text::literal), + ).map(Component::literal), 48.seconds ) ), @@ -48,7 +48,7 @@ class AbilityUtilsTest { listOf( "Grants +200% ⸕ Mining Speed for", "10s." - ).map(Text::literal), + ).map(Component::literal), 2.minutes ) ), @@ -65,7 +65,7 @@ class AbilityUtilsTest { listOf( "Teleport 12 blocks ahead of you and", "gain +50 ✦ Speed for 3 seconds." - ).map(Text::literal), + ).map(Component::literal), null ), AbilityUtils.ItemAbility( @@ -77,7 +77,7 @@ class AbilityUtilsTest { "Teleport to your targeted block up", "to 61 blocks away.", "Soulflow Cost: 1" - ).map(Text::literal), + ).map(Component::literal), null ) ), diff --git a/src/test/kotlin/util/skyblock/TabListAPITest.kt b/src/test/kotlin/util/skyblock/TabListAPITest.kt new file mode 100644 index 0000000..26eafe0 --- /dev/null +++ b/src/test/kotlin/util/skyblock/TabListAPITest.kt @@ -0,0 +1,48 @@ +package moe.nea.firmament.test.util.skyblock + +import org.junit.jupiter.api.Assertions +import org.junit.jupiter.api.Test +import moe.nea.firmament.test.testutil.ItemResources +import moe.nea.firmament.util.skyblock.TabListAPI + +class TabListAPITest { + val tablist = ItemResources.loadTablist("dungeon_hub") + + @Test + fun checkWithTitle() { + Assertions.assertEquals( + listOf( + "Profile: Strawberry", + " SB Level: [210] 26/100 XP", + " Bank: 1.4B", + " Interest: 12 Hours (689.1k)", + ), + TabListAPI.getWidgetLines(TabListAPI.WidgetName.PROFILE, includeTitle = true, from = tablist).map { it.string }) + } + + @Test + fun checkEndOfColumn() { + Assertions.assertEquals( + listOf( + " Bonzo IV: 110/150", + " Scarf II: 25/50", + " The Professor IV: 141/150", + " Thorn I: 29/50", + " Livid II: 91/100", + " Sadan V: 388/500", + " Necron VI: 531/750", + ), + TabListAPI.getWidgetLines(TabListAPI.WidgetName.COLLECTION, from = tablist).map { it.string } + ) + } + + @Test + fun checkWithoutTitle() { + Assertions.assertEquals( + listOf( + " Undead: 1,907", + " Wither: 318", + ), + TabListAPI.getWidgetLines(TabListAPI.WidgetName.ESSENCE, from = tablist).map { it.string }) + } +} diff --git a/src/test/kotlin/util/skyblock/TimestampTest.kt b/src/test/kotlin/util/skyblock/TimestampTest.kt new file mode 100644 index 0000000..b960cb9 --- /dev/null +++ b/src/test/kotlin/util/skyblock/TimestampTest.kt @@ -0,0 +1,28 @@ +package moe.nea.firmament.test.util.skyblock + +import java.time.Instant +import java.time.ZonedDateTime +import org.junit.jupiter.api.Assertions +import org.junit.jupiter.api.Test +import moe.nea.firmament.test.testutil.ItemResources +import moe.nea.firmament.util.SBData +import moe.nea.firmament.util.timestamp + +class TimestampTest { + + @Test + fun testLongTimestamp() { + Assertions.assertEquals( + Instant.ofEpochSecond(1658091600), + ItemResources.loadItem("hyperion").timestamp + ) + } + + @Test + fun testStringTimestamp() { + Assertions.assertEquals( + ZonedDateTime.of(2021, 10, 11, 15, 39, 0, 0, SBData.hypixelTimeZone).toInstant(), + ItemResources.loadItem("backpack-in-menu").timestamp + ) + } +} |
