summaryrefslogtreecommitdiffstats
path: root/src/test/java/org
diff options
context:
space:
mode:
authorNathan Adams <dinnerbone@dinnerbone.com>2012-01-16 19:38:08 +0000
committerNathan Adams <dinnerbone@dinnerbone.com>2012-01-16 19:38:08 +0000
commited34f17ddf0b539d33dd0bec8b055c4e154f7cfc (patch)
tree2cc01076a3e1d76b1e7f3e0abb7d19b931af2667 /src/test/java/org
parent2e547c5b33667afb9faa68998c82ee47b99b08e1 (diff)
downloadbukkit-ed34f17ddf0b539d33dd0bec8b055c4e154f7cfc.tar
bukkit-ed34f17ddf0b539d33dd0bec8b055c4e154f7cfc.tar.gz
bukkit-ed34f17ddf0b539d33dd0bec8b055c4e154f7cfc.tar.lz
bukkit-ed34f17ddf0b539d33dd0bec8b055c4e154f7cfc.tar.xz
bukkit-ed34f17ddf0b539d33dd0bec8b055c4e154f7cfc.zip
Added ChatColor.MAGIC, changed to char based values and deprecated old methods. Added unit tests for ChatColor
Diffstat (limited to 'src/test/java/org')
-rw-r--r--src/test/java/org/bukkit/ChatColorTest.java58
1 files changed, 58 insertions, 0 deletions
diff --git a/src/test/java/org/bukkit/ChatColorTest.java b/src/test/java/org/bukkit/ChatColorTest.java
new file mode 100644
index 00000000..acf7c5e9
--- /dev/null
+++ b/src/test/java/org/bukkit/ChatColorTest.java
@@ -0,0 +1,58 @@
+package org.bukkit;
+
+import org.junit.AfterClass;
+import org.junit.Test;
+import static org.junit.Assert.*;
+import org.junit.BeforeClass;
+import static org.hamcrest.CoreMatchers.*;
+
+public class ChatColorTest {
+ @Test
+ public void testGetCode() {
+ ChatColor color = ChatColor.DARK_RED;
+ assertThat(color.getCode(), equalTo(4));
+ }
+
+ @Test
+ public void testGetChar() {
+ ChatColor color = ChatColor.MAGIC;
+ assertThat(color.getChar(), equalTo('k'));
+ }
+
+ @Test
+ public void testToString() {
+ ChatColor color = ChatColor.LIGHT_PURPLE;
+ assertThat(color.toString(), equalTo("\u00A7d"));
+ }
+
+ @Test
+ public void testGetByCode() {
+ ChatColor color = ChatColor.AQUA;
+ assertThat(ChatColor.getByCode(color.getCode()), equalTo(color));
+ }
+
+ @Test
+ public void testGetByChar_char() {
+ ChatColor color = ChatColor.GOLD;
+ assertThat(ChatColor.getByChar(color.getChar()), equalTo(color));
+ }
+
+ @Test
+ public void testGetByChar_String() {
+ ChatColor color = ChatColor.BLUE;
+ assertThat(ChatColor.getByChar(((Character)color.getChar()).toString()), equalTo(color));
+ }
+
+ @Test
+ public void testStripColor() {
+ String string = "";
+ String expected = "";
+
+ for (ChatColor color : ChatColor.values()) {
+ string += color + "test";
+ expected += "test";
+ }
+
+ assertThat(ChatColor.stripColor(string), equalTo(expected));
+ }
+}