SPIGOT-4646: Test + fix InventoryWrapper.getContents

This commit is contained in:
md_5 2019-03-05 16:59:40 +11:00
parent faa6226959
commit 1dbe87c8cc
2 changed files with 24 additions and 1 deletions

View File

@ -128,7 +128,7 @@ public class InventoryWrapper implements IInventory {
List<ItemStack> items = new ArrayList<ItemStack>(size);
for (int i = 0; i < size; i++) {
items.set(i, getItem(i));
items.add(getItem(i));
}
return items;

View File

@ -0,0 +1,23 @@
package org.bukkit.craftbukkit.inventory;
import junit.framework.Assert;
import org.bukkit.Material;
import org.bukkit.inventory.Inventory;
import org.bukkit.inventory.ItemStack;
import org.junit.Test;
public class InventoryWrapperTest {
@Test
public void test() {
Inventory raw = new CraftInventoryCustom(null, 9);
raw.addItem(new ItemStack(Material.STONE));
Assert.assertTrue(raw.contains(Material.STONE));
InventoryWrapper wrapper = new InventoryWrapper(raw);
CraftInventory proxy = new CraftInventory(wrapper);
Assert.assertTrue(proxy.contains(Material.STONE));
}
}