summaryrefslogtreecommitdiffstats
path: root/src/test/java/org
diff options
context:
space:
mode:
authorryanbennitt <ryanbennitt@googlemail.com>2016-01-11 18:07:51 +0000
committermd_5 <git@md-5.net>2016-01-12 09:42:07 +1100
commitf517b6e6a95a7a7f5498bce806a9b997e433f75b (patch)
treef15badb8ae7c28c1ff5cfb1b32582ee9058423ec /src/test/java/org
parentf10a7a92f33995b08f63633b23de6ec80b50a609 (diff)
downloadbukkit-f517b6e6a95a7a7f5498bce806a9b997e433f75b.tar
bukkit-f517b6e6a95a7a7f5498bce806a9b997e433f75b.tar.gz
bukkit-f517b6e6a95a7a7f5498bce806a9b997e433f75b.tar.lz
bukkit-f517b6e6a95a7a7f5498bce806a9b997e433f75b.tar.xz
bukkit-f517b6e6a95a7a7f5498bce806a9b997e433f75b.zip
SPIGOT-1393: Fixed door direction mask
Diffstat (limited to 'src/test/java/org')
-rw-r--r--src/test/java/org/bukkit/materials/MaterialDataTest.java61
1 files changed, 61 insertions, 0 deletions
diff --git a/src/test/java/org/bukkit/materials/MaterialDataTest.java b/src/test/java/org/bukkit/materials/MaterialDataTest.java
new file mode 100644
index 00000000..e888381d
--- /dev/null
+++ b/src/test/java/org/bukkit/materials/MaterialDataTest.java
@@ -0,0 +1,61 @@
+package org.bukkit.materials;
+
+import static org.hamcrest.Matchers.equalTo;
+import static org.junit.Assert.assertThat;
+
+import org.bukkit.Material;
+import org.bukkit.block.BlockFace;
+import org.bukkit.material.Door;
+import org.junit.Test;
+
+public class MaterialDataTest {
+
+ @Test
+ public void testDoor()
+ {
+ @SuppressWarnings("deprecation")
+ Door door = new Door();
+ assertThat("Constructed with default door type",door.getItemType(),equalTo(Material.WOODEN_DOOR));
+ assertThat("Constructed with default top or bottom",door.isTopHalf(),equalTo(false));
+ assertThat("Constructed with default direction",door.getFacing(),equalTo(BlockFace.WEST));
+ assertThat("Constructed with default open state",door.isOpen(),equalTo(false));
+
+ Material[] types = new Material[] { Material.WOODEN_DOOR,
+ Material.IRON_DOOR_BLOCK, Material.SPRUCE_DOOR,
+ Material.BIRCH_DOOR, Material.JUNGLE_DOOR,
+ Material.ACACIA_DOOR, Material.DARK_OAK_DOOR };
+ BlockFace[] directions = new BlockFace[] { BlockFace.WEST, BlockFace.NORTH, BlockFace.EAST, BlockFace.SOUTH };
+ boolean[] openStates = new boolean[] {false, true};
+ boolean[] hingeStates = new boolean[] {false, true};
+ for(Material type : types)
+ {
+ // Test bottom half
+ for(BlockFace facing : directions)
+ {
+ door = new Door(type,facing);
+ assertThat("Constructed with correct door type",door.getItemType(),equalTo(type));
+ assertThat("Constructed with default top or bottom",door.isTopHalf(),equalTo(false));
+ assertThat("Constructed with correct direction",door.getFacing(),equalTo(facing));
+ assertThat("Constructed with default open state",door.isOpen(),equalTo(false));
+
+ for(boolean openState : openStates)
+ {
+ door = new Door(type,facing,openState);
+ assertThat("Constructed with correct door type",door.getItemType(),equalTo(type));
+ assertThat("Constructed with default top or bottom",door.isTopHalf(),equalTo(false));
+ assertThat("Constructed with correct direction",door.getFacing(),equalTo(facing));
+ assertThat("Constructed with correct open state",door.isOpen(),equalTo(openState));
+ }
+ }
+
+ // Test top half
+ for(boolean hingeState : hingeStates)
+ {
+ door = new Door(type,hingeState);
+ assertThat("Constructed with correct door type",door.getItemType(),equalTo(type));
+ assertThat("Constructed with default top or bottom",door.isTopHalf(),equalTo(true));
+ assertThat("Constructed with correct direction",door.getHinge(),equalTo(hingeState));
+ }
+ }
+ }
+}