summaryrefslogtreecommitdiffstats
path: root/src/test/java
diff options
context:
space:
mode:
authorCeltic Minstrel <celtic.minstrel.ca@some.place>2012-03-04 18:58:18 -0500
committerEvilSeph <evilseph@gmail.com>2012-03-21 12:31:21 -0400
commitbf771c192d4a859ae59891a6258d49176883ae86 (patch)
treeaef5d5226ed30738ff87a6497d5ecf62648c2246 /src/test/java
parent132ee0454229477f2403d445758594c3566405bc (diff)
downloadbukkit-bf771c192d4a859ae59891a6258d49176883ae86.tar
bukkit-bf771c192d4a859ae59891a6258d49176883ae86.tar.gz
bukkit-bf771c192d4a859ae59891a6258d49176883ae86.tar.lz
bukkit-bf771c192d4a859ae59891a6258d49176883ae86.tar.xz
bukkit-bf771c192d4a859ae59891a6258d49176883ae86.zip
[Bleeding] Fixed some issues with no-effect potions, and added more potion tests. Fixes BUKKIT-1251
Diffstat (limited to 'src/test/java')
-rw-r--r--src/test/java/org/bukkit/potion/PotionTest.java84
1 files changed, 54 insertions, 30 deletions
diff --git a/src/test/java/org/bukkit/potion/PotionTest.java b/src/test/java/org/bukkit/potion/PotionTest.java
index afc54352..58252aeb 100644
--- a/src/test/java/org/bukkit/potion/PotionTest.java
+++ b/src/test/java/org/bukkit/potion/PotionTest.java
@@ -85,38 +85,62 @@ public class PotionTest {
assertTrue((potion.toDamageValue() & 0x3F) == (PotionType.POISON.getDamageValue() | 0x20));
}
- @Test
- public void useNulls() {
- try {
- new Potion(null, 2);
- fail("cannot use null type in constructor with a level");
- } catch (IllegalArgumentException ex) {
- }
-
- try {
- new Potion(PotionType.POISON, 3);
- fail("level must be less than 3 in constructor");
- } catch (IllegalArgumentException ex) {
- }
+ @Test(expected=IllegalArgumentException.class)
+ public void nullType() {
+ new Potion(null, 2);
+ }
+
+ @Test(expected=IllegalArgumentException.class)
+ public void maxLevelConstruct() {
+ new Potion(PotionType.POISON, 3);
+ }
+
+ @Test(expected=IllegalArgumentException.class)
+ public void maxLevelSet() {
+ Potion potion = new Potion(PotionType.POISON);
+ potion.setLevel(3);
+ }
+
+ @Test(expected=IllegalArgumentException.class)
+ public void nullStack() {
+ Potion potion = new Potion(PotionType.POISON);
+ potion.apply((ItemStack) null);
+ }
+ @Test(expected=IllegalArgumentException.class)
+ public void nullEntity() {
Potion potion = new Potion(PotionType.POISON);
- try {
- potion.setLevel(3);
- fail("level must be set less than 3");
- } catch (IllegalArgumentException ex) {
- }
-
- try {
- potion.apply((ItemStack) null);
- fail("cannot apply to a null itemstack");
- } catch (IllegalArgumentException ex) {
- }
-
- try {
- potion.apply((LivingEntity) null);
- fail("cannot apply to a null entity");
- } catch (IllegalArgumentException ex) {
- }
+ potion.apply((LivingEntity) null);
+ }
+
+ @Test
+ public void water() {
+ Potion potion = new Potion(PotionType.WATER);
+ assertEquals(0, potion.getLevel());
+ assertFalse(potion.isSplash());
+ assertFalse(potion.hasExtendedDuration());
+ assertEquals(0, potion.toDamageValue());
+ }
+
+ @Test
+ public void mundane() {
+ Potion potion = new Potion(0);
+ assertFalse(potion.getType() == PotionType.WATER);
+ assertFalse(potion.toDamageValue() == 0);
+ assertEquals(8192, potion.toDamageValue());
+ Potion potion2 = Potion.fromDamage(8192);
+ assertEquals(potion, potion2);
+ assertEquals(0, potion.getLevel());
+ }
+
+ @Test
+ public void awkward() {
+ Potion potion = new Potion(16);
+ assertEquals(16, potion.getNameId());
+ assertFalse(potion.isSplash());
+ assertFalse(potion.hasExtendedDuration());
+ assertNull(potion.getType());
+ assertEquals(16, potion.toDamageValue());
}
private static final int EXTENDED_BIT = 0x40;