aboutsummaryrefslogtreecommitdiff
path: root/src/test/java/at/hannibal2
diff options
context:
space:
mode:
authorLinnea Gräf <nea@nea.moe>2024-02-29 22:13:22 +0100
committerGitHub <noreply@github.com>2024-02-29 22:13:22 +0100
commitd4bd14793bf920d27de14bcea7350d67f1a8a000 (patch)
tree1bf8b3e241448317e102302de6ced3815cb35bde /src/test/java/at/hannibal2
parent0c96b9d6ee14a9dcaafad303ed82357f252fdd6b (diff)
downloadskyhanni-d4bd14793bf920d27de14bcea7350d67f1a8a000.tar.gz
skyhanni-d4bd14793bf920d27de14bcea7350d67f1a8a000.tar.bz2
skyhanni-d4bd14793bf920d27de14bcea7350d67f1a8a000.zip
Improve performance of removeColor. (#1079)
Diffstat (limited to 'src/test/java/at/hannibal2')
-rw-r--r--src/test/java/at/hannibal2/skyhanni/test/RemoveColorTest.kt45
1 files changed, 45 insertions, 0 deletions
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()
+ )
+ }
+
+}