From d4bd14793bf920d27de14bcea7350d67f1a8a000 Mon Sep 17 00:00:00 2001 From: Linnea Gräf Date: Thu, 29 Feb 2024 22:13:22 +0100 Subject: Improve performance of removeColor. (#1079) --- .../at/hannibal2/skyhanni/test/RemoveColorTest.kt | 45 ++++++++++++++++++++++ 1 file changed, 45 insertions(+) create mode 100644 src/test/java/at/hannibal2/skyhanni/test/RemoveColorTest.kt (limited to 'src/test/java/at/hannibal2/skyhanni') diff --git a/src/test/java/at/hannibal2/skyhanni/test/RemoveColorTest.kt b/src/test/java/at/hannibal2/skyhanni/test/RemoveColorTest.kt new file mode 100644 index 000000000..f12f295fa --- /dev/null +++ b/src/test/java/at/hannibal2/skyhanni/test/RemoveColorTest.kt @@ -0,0 +1,45 @@ +package at.hannibal2.skyhanni.test + +import at.hannibal2.skyhanni.utils.StringUtils.removeColor +import org.junit.jupiter.api.Assertions +import org.junit.jupiter.api.Test + +class RemoveColorTest { + @Test + fun testEdging() { + Assertions.assertEquals("", "§".removeColor()) + Assertions.assertEquals("a", "a§".removeColor()) + Assertions.assertEquals("b", "§ab§".removeColor()) + } + + @Test + fun `testDouble§`() { + Assertions.assertEquals("1", "§§1".removeColor()) + Assertions.assertEquals("1", "§§1".removeColor(true)) + Assertions.assertEquals("k", "§§k".removeColor(true)) + } + + @Test + fun testKeepNonColor() { + Assertions.assertEquals("§k§l§m§n§o§r", "§k§l§m§f§n§o§r".removeColor(true)) + } + + @Test + fun testPlainString() { + Assertions.assertEquals("bcdefgp", "bcdefgp") + Assertions.assertEquals("", "") + } + + @Test + fun testSomeNormalTestCases() { + Assertions.assertEquals( + "You are not currently in a party.", + "§r§cYou are not currently in a party.§r".removeColor() + ) + Assertions.assertEquals( + "Ancient Necron's Chestplate ✪✪✪✪", + "§dAncient Necron's Chestplate §6✪§6✪§6✪§6✪".removeColor() + ) + } + +} -- cgit