summaryrefslogtreecommitdiffstats
path: root/src/test
diff options
context:
space:
mode:
authorSenmori <thesenmori@gmail.com>2018-08-11 11:24:33 +1000
committermd_5 <git@md-5.net>2018-08-11 11:25:09 +1000
commit29e75648741b877c06165d82241b6b3a417474f6 (patch)
treefc774019f25e93d6d20ffdfd5f9ab57417f883aa /src/test
parent50e6858b72343827ddc8ca15a387fa950d459e3a (diff)
downloadcraftbukkit-29e75648741b877c06165d82241b6b3a417474f6.tar
craftbukkit-29e75648741b877c06165d82241b6b3a417474f6.tar.gz
craftbukkit-29e75648741b877c06165d82241b6b3a417474f6.tar.lz
craftbukkit-29e75648741b877c06165d82241b6b3a417474f6.tar.xz
craftbukkit-29e75648741b877c06165d82241b6b3a417474f6.zip
Expand GameRule API
Diffstat (limited to 'src/test')
-rw-r--r--src/test/java/org/bukkit/GameRuleTest.java56
1 files changed, 56 insertions, 0 deletions
diff --git a/src/test/java/org/bukkit/GameRuleTest.java b/src/test/java/org/bukkit/GameRuleTest.java
new file mode 100644
index 00000000..883f5081
--- /dev/null
+++ b/src/test/java/org/bukkit/GameRuleTest.java
@@ -0,0 +1,56 @@
+package org.bukkit;
+
+import java.util.Map;
+import java.util.TreeMap;
+import net.minecraft.server.GameRules;
+import org.junit.Assert;
+import org.junit.Test;
+
+public class GameRuleTest {
+
+ @Test
+ public void testBukkitRules() {
+ GameRule<?>[] rules = GameRule.values();
+
+ for (GameRule<?> rule : rules) {
+ GameRule<?> registeredRule = GameRule.getByName(rule.getName());
+ Assert.assertNotNull("Null GameRule", registeredRule);
+ Assert.assertEquals("Invalid GameRule equality", rule, registeredRule);
+ }
+ }
+
+ @Test
+ public void testMinecraftRules() {
+ TreeMap<String, GameRules.b> minecraftRules = GameRules.getGameRules();
+
+ for (Map.Entry<String, GameRules.b> entry : minecraftRules.entrySet()) {
+ GameRule<?> bukkitRule = GameRule.getByName(entry.getKey());
+
+ Assert.assertNotNull(bukkitRule);
+ Assert.assertEquals("Invalid GameRule Name", bukkitRule.getName(), entry.getKey());
+ }
+ }
+
+ @Test(expected = NullPointerException.class)
+ public void nullGameRuleName() {
+ GameRule.getByName(null);
+ }
+
+ @Test
+ public void emptyGameRuleName() {
+ Assert.assertNull(GameRule.getByName(""));
+ }
+
+ @Test
+ public void incorrectGameRuleName() {
+ Assert.assertNull(GameRule.getByName("doAnnounceAdvancements"));
+ Assert.assertNull(GameRule.getByName("sendCommandBlockFeedback"));
+ }
+
+ @Test
+ public void invalidCasing() {
+ Assert.assertNull(GameRule.getByName("CommandBlockOutput"));
+ Assert.assertNull(GameRule.getByName("spAwnRadius"));
+ Assert.assertNull(GameRule.getByName("rand0mTickSpeEd"));
+ }
+}