From f1ccee13c212f3a786ab1608b887c09c781dd4c5 Mon Sep 17 00:00:00 2001 From: EpicKnarvik97 Date: Wed, 25 Jan 2023 16:04:39 +0100 Subject: [PATCH] Adds some tests for the color helper --- .../knarlib/util/ColorHelperTest.java | 41 +++++++++++++++++++ 1 file changed, 41 insertions(+) create mode 100644 src/test/java/net/knarcraft/knarlib/util/ColorHelperTest.java diff --git a/src/test/java/net/knarcraft/knarlib/util/ColorHelperTest.java b/src/test/java/net/knarcraft/knarlib/util/ColorHelperTest.java new file mode 100644 index 0000000..05a2c10 --- /dev/null +++ b/src/test/java/net/knarcraft/knarlib/util/ColorHelperTest.java @@ -0,0 +1,41 @@ +package net.knarcraft.knarlib.util; + +import net.knarcraft.knarlib.property.ColorConversion; +import org.junit.jupiter.api.Test; + +import static org.junit.jupiter.api.Assertions.assertEquals; + +public class ColorHelperTest { + + private final String rawHexColorMessage = "#ffdef3A colored message"; + private final String formattedHexColorMessage = "§x§f§f§d§e§f§3A colored message"; + + @Test + public void RGBColorAmpersandTest() { + ColorHelper.setRequireAmpersandInHexColors(false); + assertEquals(formattedHexColorMessage, + ColorHelper.translateColorCodes("&" + rawHexColorMessage, ColorConversion.RGB)); + } + + @Test + public void RGBColorNoAmpersandTest() { + ColorHelper.setRequireAmpersandInHexColors(false); + assertEquals(formattedHexColorMessage, + ColorHelper.translateColorCodes(rawHexColorMessage, ColorConversion.RGB)); + } + + @Test + public void RGBColorNoAmpersandAmpersandRequiredTest() { + ColorHelper.setRequireAmpersandInHexColors(true); + assertEquals(rawHexColorMessage, + ColorHelper.translateColorCodes(rawHexColorMessage, ColorConversion.RGB)); + } + + @Test + public void RGBColorAmpersandAmpersandRequiredTest() { + ColorHelper.setRequireAmpersandInHexColors(true); + assertEquals(formattedHexColorMessage, + ColorHelper.translateColorCodes("&" + rawHexColorMessage, ColorConversion.RGB)); + } + +}