diff options
Diffstat (limited to 'src/test/java')
| -rw-r--r-- | src/test/java/de/hysky/skyblocker/UpdateNotificationsTest.java | 67 | ||||
| -rw-r--r-- | src/test/java/de/hysky/skyblocker/skyblock/special/DyeSpecialEffectsTest.java | 7 |
2 files changed, 73 insertions, 1 deletions
diff --git a/src/test/java/de/hysky/skyblocker/UpdateNotificationsTest.java b/src/test/java/de/hysky/skyblocker/UpdateNotificationsTest.java new file mode 100644 index 00000000..751ab570 --- /dev/null +++ b/src/test/java/de/hysky/skyblocker/UpdateNotificationsTest.java @@ -0,0 +1,67 @@ +package de.hysky.skyblocker; + +import java.util.Comparator; + +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.BeforeAll; +import org.junit.jupiter.api.Test; + +import com.mojang.serialization.Codec; +import com.mojang.serialization.JavaOps; + +import net.fabricmc.loader.api.SemanticVersion; +import net.fabricmc.loader.api.Version; +import net.minecraft.Bootstrap; +import net.minecraft.SharedConstants; + +public class UpdateNotificationsTest { + private final Comparator<Version> COMPARATOR = UpdateNotifications.COMPARATOR; + private final Codec<SemanticVersion> SEM_VER_CODEC = UpdateNotifications.SEM_VER_CODEC; + private final SemanticVersion LATEST_VERSION = SEM_VER_CODEC.parse(JavaOps.INSTANCE, "1.22.0+1.21").getOrThrow(); + + @BeforeAll + public static void setupEnvironment() { + SharedConstants.createGameVersion(); + Bootstrap.initialize(); + } + + @Test + void testLatestAgainstRegular() { + SemanticVersion regular = SEM_VER_CODEC.parse(JavaOps.INSTANCE, "1.21.1+1.21").getOrThrow(); + + //Requires that the latest be newer than this normal release version + Assertions.assertTrue(COMPARATOR.compare(LATEST_VERSION, regular) > 0); + } + + @Test + void testLatestAgainstBeta() { + SemanticVersion beta = SEM_VER_CODEC.parse(JavaOps.INSTANCE, "1.22.0-beta.1+1.21").getOrThrow(); + + //Requires that the latest be newer than the beta + Assertions.assertTrue(COMPARATOR.compare(LATEST_VERSION, beta) > 0); + } + + @Test + void testLatestAgainstAlpha() { + SemanticVersion alpha = SEM_VER_CODEC.parse(JavaOps.INSTANCE, "1.22.0-alpha.1+1.21").getOrThrow(); + + //Requires that the latest be newer than the alpha + Assertions.assertTrue(COMPARATOR.compare(LATEST_VERSION, alpha) > 0); + } + + @Test + void testLatestAgainstOldAlpha() { + SemanticVersion oldAlpha = SEM_VER_CODEC.parse(JavaOps.INSTANCE, "1.21.1-alpha-pr-888-afc81df+1.21").getOrThrow(); + + //Requires the alpha is older than the latest + Assertions.assertEquals(COMPARATOR.compare(oldAlpha, LATEST_VERSION), -1); + } + + @Test + void testThatTheCurrentAlphaAgainstLatestShouldBeDiscarded() { + SemanticVersion currentAlpha = SEM_VER_CODEC.parse(JavaOps.INSTANCE, "1.22.0-alpha-pr-908-fe7d89a+1.21").getOrThrow(); + + //Requires that the current alpha be discarded against the latest version + Assertions.assertTrue(UpdateNotifications.shouldDiscard(currentAlpha, LATEST_VERSION)); + } +} diff --git a/src/test/java/de/hysky/skyblocker/skyblock/special/DyeSpecialEffectsTest.java b/src/test/java/de/hysky/skyblocker/skyblock/special/DyeSpecialEffectsTest.java index e5910c8d..9421ca1d 100644 --- a/src/test/java/de/hysky/skyblocker/skyblock/special/DyeSpecialEffectsTest.java +++ b/src/test/java/de/hysky/skyblocker/skyblock/special/DyeSpecialEffectsTest.java @@ -17,6 +17,11 @@ public class DyeSpecialEffectsTest { @Test void testDye3() { - Assertions.assertTrue(DyeSpecialEffects.DROP_PATTERN.matcher("WOW! [MVP+] Viciscat found Cat Dye #1!").matches(), "Dye Test #3 didn't match!"); + Assertions.assertTrue(DyeSpecialEffects.DROP_PATTERN.matcher("WOW! [MVP+] AzureAaron found Necron Dye!").matches(), "Dye Test #3 didn't match!"); + } + + @Test + void testDye4() { + Assertions.assertTrue(DyeSpecialEffects.DROP_PATTERN.matcher("WOW! [MVP+] Viciscat found Cat Dye #1!").matches(), "Dye Test #4 didn't match!"); } } |
