From acfb4f2fbe00bf103c2779cfa7d970ebdeb48fa3 Mon Sep 17 00:00:00 2001 From: Andrew Ardill Date: Tue, 20 Dec 2011 00:25:15 +1100 Subject: [PATCH] Test cloning enchanted CraftItemStacks --- .../inventory/CraftItemStackTest.java | 28 +++++++++++++++++++ 1 file changed, 28 insertions(+) create mode 100644 src/test/java/org/bukkit/craftbukkit/inventory/CraftItemStackTest.java diff --git a/src/test/java/org/bukkit/craftbukkit/inventory/CraftItemStackTest.java b/src/test/java/org/bukkit/craftbukkit/inventory/CraftItemStackTest.java new file mode 100644 index 0000000000..28ad98a514 --- /dev/null +++ b/src/test/java/org/bukkit/craftbukkit/inventory/CraftItemStackTest.java @@ -0,0 +1,28 @@ +package org.bukkit.craftbukkit.inventory; + +import net.minecraft.server.Enchantment; +import net.minecraft.server.StatisticList; +import org.bukkit.inventory.ItemStack; +import org.junit.Before; +import org.junit.Test; + +public class CraftItemStackTest { + @Before + public void setUp() throws Exception { + StatisticList.a(); + } + + @Test + public void testCloneEnchantedItem() throws Exception { + net.minecraft.server.ItemStack nmsItemStack = new net.minecraft.server.ItemStack(net.minecraft.server.Item.POTION); + nmsItemStack.addEnchantment(Enchantment.DAMAGE_ALL, 1); + ItemStack itemStack = new CraftItemStack(nmsItemStack); + ItemStack clone = itemStack.clone(); + assert (clone.getType().equals(itemStack.getType())); + assert (clone.getAmount() == itemStack.getAmount()); + assert (clone.getDurability() == itemStack.getDurability()); + assert (clone.getEnchantments().equals(itemStack.getEnchantments())); + assert (clone.getTypeId() == itemStack.getTypeId()); + assert (clone.getData().equals(itemStack.getData())); + } +}