mirror of
https://github.com/PaperMC/Paper.git
synced 2025-08-14 19:55:52 -07:00
@@ -18,7 +18,7 @@ import org.junit.runners.Parameterized.Parameters;
|
||||
@RunWith(Parameterized.class)
|
||||
public class BukkitMirrorTest {
|
||||
|
||||
@Parameters(name="{index}: {1}")
|
||||
@Parameters(name = "{index}: {1}")
|
||||
public static List<Object[]> data() {
|
||||
return Lists.transform(Arrays.asList(Server.class.getDeclaredMethods()), new Function<Method, Object[]>() {
|
||||
@Override
|
||||
|
@@ -26,7 +26,7 @@ public class ColorTest {
|
||||
}
|
||||
}
|
||||
|
||||
static TestColor[] examples = new TestColor[] {
|
||||
static TestColor[] examples = new TestColor[]{
|
||||
/* 0xRRGGBB, 0xBBGGRR, 0xRR, 0xGG, 0xBB */
|
||||
new TestColor(0xFFFFFF, 0xFFFFFF, 0xFF, 0xFF, 0xFF),
|
||||
new TestColor(0xFFFFAA, 0xAAFFFF, 0xFF, 0xFF, 0xAA),
|
||||
@@ -98,22 +98,22 @@ public class ColorTest {
|
||||
}
|
||||
}
|
||||
|
||||
@Test(expected=IllegalArgumentException.class)
|
||||
@Test(expected = IllegalArgumentException.class)
|
||||
public void testInvalidRGB1() {
|
||||
Color.fromRGB(0x01000000);
|
||||
}
|
||||
|
||||
@Test(expected=IllegalArgumentException.class)
|
||||
@Test(expected = IllegalArgumentException.class)
|
||||
public void testInvalidRGB2() {
|
||||
Color.fromRGB(Integer.MIN_VALUE);
|
||||
}
|
||||
|
||||
@Test(expected=IllegalArgumentException.class)
|
||||
@Test(expected = IllegalArgumentException.class)
|
||||
public void testInvalidRGB3() {
|
||||
Color.fromRGB(Integer.MAX_VALUE);
|
||||
}
|
||||
|
||||
@Test(expected=IllegalArgumentException.class)
|
||||
@Test(expected = IllegalArgumentException.class)
|
||||
public void testInvalidRGB4() {
|
||||
Color.fromRGB(-1);
|
||||
}
|
||||
@@ -129,22 +129,22 @@ public class ColorTest {
|
||||
}
|
||||
}
|
||||
|
||||
@Test(expected=IllegalArgumentException.class)
|
||||
@Test(expected = IllegalArgumentException.class)
|
||||
public void testInvalidBGR1() {
|
||||
Color.fromBGR(0x01000000);
|
||||
}
|
||||
|
||||
@Test(expected=IllegalArgumentException.class)
|
||||
@Test(expected = IllegalArgumentException.class)
|
||||
public void testInvalidBGR2() {
|
||||
Color.fromBGR(Integer.MIN_VALUE);
|
||||
}
|
||||
|
||||
@Test(expected=IllegalArgumentException.class)
|
||||
@Test(expected = IllegalArgumentException.class)
|
||||
public void testInvalidBGR3() {
|
||||
Color.fromBGR(Integer.MAX_VALUE);
|
||||
}
|
||||
|
||||
@Test(expected=IllegalArgumentException.class)
|
||||
@Test(expected = IllegalArgumentException.class)
|
||||
public void testInvalidBGR4() {
|
||||
Color.fromBGR(-1);
|
||||
}
|
||||
@@ -160,62 +160,62 @@ public class ColorTest {
|
||||
}
|
||||
}
|
||||
|
||||
@Test(expected=IllegalArgumentException.class)
|
||||
@Test(expected = IllegalArgumentException.class)
|
||||
public void testInvalidR01() {
|
||||
Color.fromRGB(-1, 0x00, 0x00);
|
||||
}
|
||||
|
||||
@Test(expected=IllegalArgumentException.class)
|
||||
@Test(expected = IllegalArgumentException.class)
|
||||
public void testInvalidR02() {
|
||||
Color.fromRGB(Integer.MAX_VALUE, 0x00, 0x00);
|
||||
}
|
||||
|
||||
@Test(expected=IllegalArgumentException.class)
|
||||
@Test(expected = IllegalArgumentException.class)
|
||||
public void testInvalidR03() {
|
||||
Color.fromRGB(Integer.MIN_VALUE, 0x00, 0x00);
|
||||
}
|
||||
|
||||
@Test(expected=IllegalArgumentException.class)
|
||||
@Test(expected = IllegalArgumentException.class)
|
||||
public void testInvalidR04() {
|
||||
Color.fromRGB(0x100, 0x00, 0x00);
|
||||
}
|
||||
|
||||
@Test(expected=IllegalArgumentException.class)
|
||||
@Test(expected = IllegalArgumentException.class)
|
||||
public void testInvalidR05() {
|
||||
Color.fromBGR(0x00, 0x00, -1);
|
||||
}
|
||||
|
||||
@Test(expected=IllegalArgumentException.class)
|
||||
@Test(expected = IllegalArgumentException.class)
|
||||
public void testInvalidR06() {
|
||||
Color.fromBGR(0x00, 0x00, Integer.MAX_VALUE);
|
||||
}
|
||||
|
||||
@Test(expected=IllegalArgumentException.class)
|
||||
@Test(expected = IllegalArgumentException.class)
|
||||
public void testInvalidR07() {
|
||||
Color.fromBGR(0x00, 0x00, Integer.MIN_VALUE);
|
||||
}
|
||||
|
||||
@Test(expected=IllegalArgumentException.class)
|
||||
@Test(expected = IllegalArgumentException.class)
|
||||
public void testInvalidR08() {
|
||||
Color.fromBGR(0x00, 0x00, 0x100);
|
||||
}
|
||||
|
||||
@Test(expected=IllegalArgumentException.class)
|
||||
@Test(expected = IllegalArgumentException.class)
|
||||
public void testInvalidR09() {
|
||||
Color.WHITE.setRed(-1);
|
||||
}
|
||||
|
||||
@Test(expected=IllegalArgumentException.class)
|
||||
@Test(expected = IllegalArgumentException.class)
|
||||
public void testInvalidR10() {
|
||||
Color.WHITE.setRed(Integer.MAX_VALUE);
|
||||
}
|
||||
|
||||
@Test(expected=IllegalArgumentException.class)
|
||||
@Test(expected = IllegalArgumentException.class)
|
||||
public void testInvalidR11() {
|
||||
Color.WHITE.setRed(Integer.MIN_VALUE);
|
||||
}
|
||||
|
||||
@Test(expected=IllegalArgumentException.class)
|
||||
@Test(expected = IllegalArgumentException.class)
|
||||
public void testInvalidR12() {
|
||||
Color.WHITE.setRed(0x100);
|
||||
}
|
||||
@@ -231,62 +231,62 @@ public class ColorTest {
|
||||
}
|
||||
}
|
||||
|
||||
@Test(expected=IllegalArgumentException.class)
|
||||
@Test(expected = IllegalArgumentException.class)
|
||||
public void testInvalidB01() {
|
||||
Color.fromRGB(0x00, 0x00, -1);
|
||||
}
|
||||
|
||||
@Test(expected=IllegalArgumentException.class)
|
||||
@Test(expected = IllegalArgumentException.class)
|
||||
public void testInvalidB02() {
|
||||
Color.fromRGB(0x00, 0x00, Integer.MAX_VALUE);
|
||||
}
|
||||
|
||||
@Test(expected=IllegalArgumentException.class)
|
||||
@Test(expected = IllegalArgumentException.class)
|
||||
public void testInvalidB03() {
|
||||
Color.fromRGB(0x00, 0x00, Integer.MIN_VALUE);
|
||||
}
|
||||
|
||||
@Test(expected=IllegalArgumentException.class)
|
||||
@Test(expected = IllegalArgumentException.class)
|
||||
public void testInvalidB04() {
|
||||
Color.fromRGB(0x00, 0x00, 0x100);
|
||||
}
|
||||
|
||||
@Test(expected=IllegalArgumentException.class)
|
||||
@Test(expected = IllegalArgumentException.class)
|
||||
public void testInvalidB05() {
|
||||
Color.fromBGR(-1, 0x00, 0x00);
|
||||
}
|
||||
|
||||
@Test(expected=IllegalArgumentException.class)
|
||||
@Test(expected = IllegalArgumentException.class)
|
||||
public void testInvalidB06() {
|
||||
Color.fromBGR(Integer.MAX_VALUE, 0x00, 0x00);
|
||||
}
|
||||
|
||||
@Test(expected=IllegalArgumentException.class)
|
||||
@Test(expected = IllegalArgumentException.class)
|
||||
public void testInvalidB07() {
|
||||
Color.fromBGR(Integer.MIN_VALUE, 0x00, 0x00);
|
||||
}
|
||||
|
||||
@Test(expected=IllegalArgumentException.class)
|
||||
@Test(expected = IllegalArgumentException.class)
|
||||
public void testInvalidB08() {
|
||||
Color.fromBGR(0x100, 0x00, 0x00);
|
||||
}
|
||||
|
||||
@Test(expected=IllegalArgumentException.class)
|
||||
@Test(expected = IllegalArgumentException.class)
|
||||
public void testInvalidB09() {
|
||||
Color.WHITE.setBlue(-1);
|
||||
}
|
||||
|
||||
@Test(expected=IllegalArgumentException.class)
|
||||
@Test(expected = IllegalArgumentException.class)
|
||||
public void testInvalidB10() {
|
||||
Color.WHITE.setBlue(Integer.MAX_VALUE);
|
||||
}
|
||||
|
||||
@Test(expected=IllegalArgumentException.class)
|
||||
@Test(expected = IllegalArgumentException.class)
|
||||
public void testInvalidB11() {
|
||||
Color.WHITE.setBlue(Integer.MIN_VALUE);
|
||||
}
|
||||
|
||||
@Test(expected=IllegalArgumentException.class)
|
||||
@Test(expected = IllegalArgumentException.class)
|
||||
public void testInvalidB12() {
|
||||
Color.WHITE.setBlue(0x100);
|
||||
}
|
||||
@@ -302,62 +302,62 @@ public class ColorTest {
|
||||
}
|
||||
}
|
||||
|
||||
@Test(expected=IllegalArgumentException.class)
|
||||
@Test(expected = IllegalArgumentException.class)
|
||||
public void testInvalidG01() {
|
||||
Color.fromRGB(0x00, -1, 0x00);
|
||||
}
|
||||
|
||||
@Test(expected=IllegalArgumentException.class)
|
||||
@Test(expected = IllegalArgumentException.class)
|
||||
public void testInvalidG02() {
|
||||
Color.fromRGB(0x00, Integer.MAX_VALUE, 0x00);
|
||||
}
|
||||
|
||||
@Test(expected=IllegalArgumentException.class)
|
||||
@Test(expected = IllegalArgumentException.class)
|
||||
public void testInvalidG03() {
|
||||
Color.fromRGB(0x00, Integer.MIN_VALUE, 0x00);
|
||||
}
|
||||
|
||||
@Test(expected=IllegalArgumentException.class)
|
||||
@Test(expected = IllegalArgumentException.class)
|
||||
public void testInvalidG04() {
|
||||
Color.fromRGB(0x00, 0x100, 0x00);
|
||||
}
|
||||
|
||||
@Test(expected=IllegalArgumentException.class)
|
||||
@Test(expected = IllegalArgumentException.class)
|
||||
public void testInvalidG05() {
|
||||
Color.fromBGR(0x00, -1, 0x00);
|
||||
}
|
||||
|
||||
@Test(expected=IllegalArgumentException.class)
|
||||
@Test(expected = IllegalArgumentException.class)
|
||||
public void testInvalidG06() {
|
||||
Color.fromBGR(0x00, Integer.MAX_VALUE, 0x00);
|
||||
}
|
||||
|
||||
@Test(expected=IllegalArgumentException.class)
|
||||
@Test(expected = IllegalArgumentException.class)
|
||||
public void testInvalidG07() {
|
||||
Color.fromBGR(0x00, Integer.MIN_VALUE, 0x00);
|
||||
}
|
||||
|
||||
@Test(expected=IllegalArgumentException.class)
|
||||
@Test(expected = IllegalArgumentException.class)
|
||||
public void testInvalidG08() {
|
||||
Color.fromBGR(0x00, 0x100, 0x00);
|
||||
}
|
||||
|
||||
@Test(expected=IllegalArgumentException.class)
|
||||
@Test(expected = IllegalArgumentException.class)
|
||||
public void testInvalidG09() {
|
||||
Color.WHITE.setGreen(-1);
|
||||
}
|
||||
|
||||
@Test(expected=IllegalArgumentException.class)
|
||||
@Test(expected = IllegalArgumentException.class)
|
||||
public void testInvalidG10() {
|
||||
Color.WHITE.setGreen(Integer.MAX_VALUE);
|
||||
}
|
||||
|
||||
@Test(expected=IllegalArgumentException.class)
|
||||
@Test(expected = IllegalArgumentException.class)
|
||||
public void testInvalidG11() {
|
||||
Color.WHITE.setGreen(Integer.MIN_VALUE);
|
||||
}
|
||||
|
||||
@Test(expected=IllegalArgumentException.class)
|
||||
@Test(expected = IllegalArgumentException.class)
|
||||
public void testInvalidG12() {
|
||||
Color.WHITE.setGreen(0x100);
|
||||
}
|
||||
|
@@ -16,7 +16,7 @@ import org.junit.runners.Parameterized.Parameters;
|
||||
@RunWith(Parameterized.class)
|
||||
public class DyeColorTest {
|
||||
|
||||
@Parameters(name= "{index}: {0}")
|
||||
@Parameters(name = "{index}: {0}")
|
||||
public static List<Object[]> data() {
|
||||
List<Object[]> list = new ArrayList<Object[]>();
|
||||
for (DyeColor dye : DyeColor.values()) {
|
||||
|
@@ -36,56 +36,56 @@ public class LocationTest {
|
||||
*/
|
||||
private static final double HALF_HALF_UNIT = Math.sqrt(1 / 4f);
|
||||
|
||||
@Parameters(name= "{index}: {0}")
|
||||
@Parameters(name = "{index}: {0}")
|
||||
public static List<Object[]> data() {
|
||||
Random RANDOM = new Random(1L); // Test is deterministic
|
||||
int r = 0;
|
||||
return ImmutableList.<Object[]>of(
|
||||
new Object[] { "X",
|
||||
new Object[]{"X",
|
||||
1, 0, 0,
|
||||
270, 0
|
||||
},
|
||||
new Object[] { "-X",
|
||||
new Object[]{"-X",
|
||||
-1, 0, 0,
|
||||
90, 0
|
||||
},
|
||||
new Object[] { "Z",
|
||||
new Object[]{"Z",
|
||||
0, 0, 1,
|
||||
0, 0
|
||||
},
|
||||
new Object[] { "-Z",
|
||||
new Object[]{"-Z",
|
||||
0, 0, -1,
|
||||
180, 0
|
||||
},
|
||||
new Object[] { "Y",
|
||||
new Object[]{"Y",
|
||||
0, 1, 0,
|
||||
0, -90 // Zero is here as a "default" value
|
||||
},
|
||||
new Object[] { "-Y",
|
||||
new Object[]{"-Y",
|
||||
0, -1, 0,
|
||||
0, 90 // Zero is here as a "default" value
|
||||
},
|
||||
new Object[] { "X Z",
|
||||
new Object[]{"X Z",
|
||||
HALF_UNIT, 0, HALF_UNIT,
|
||||
(270 + 360) / 2, 0
|
||||
},
|
||||
new Object[] { "X -Z",
|
||||
new Object[]{"X -Z",
|
||||
HALF_UNIT, 0, -HALF_UNIT,
|
||||
(270 + 180) / 2, 0
|
||||
},
|
||||
new Object[] { "-X -Z",
|
||||
new Object[]{"-X -Z",
|
||||
-HALF_UNIT, 0, -HALF_UNIT,
|
||||
(90 + 180) / 2, 0
|
||||
},
|
||||
new Object[] { "-X Z",
|
||||
new Object[]{"-X Z",
|
||||
-HALF_UNIT, 0, HALF_UNIT,
|
||||
(90 + 0) / 2, 0
|
||||
},
|
||||
new Object[] { "X Y Z",
|
||||
new Object[]{"X Y Z",
|
||||
HALF_HALF_UNIT, HALF_UNIT, HALF_HALF_UNIT,
|
||||
(270 + 360) / 2, -45
|
||||
},
|
||||
new Object[] { "-X -Y -Z",
|
||||
new Object[]{"-X -Y -Z",
|
||||
-HALF_HALF_UNIT, -HALF_UNIT, -HALF_HALF_UNIT,
|
||||
(90 + 180) / 2, 45
|
||||
},
|
||||
@@ -140,7 +140,7 @@ public class LocationTest {
|
||||
location.setDirection(vector);
|
||||
}
|
||||
|
||||
return new Object[] { "R" + index,
|
||||
return new Object[]{"R" + index,
|
||||
vector.getX(), vector.getY(), vector.getZ(),
|
||||
location.getYaw(), location.getPitch()
|
||||
};
|
||||
|
@@ -114,7 +114,7 @@ public class NoteTest {
|
||||
assertEquals(note.getOctave(), 2);
|
||||
}
|
||||
|
||||
@Test(expected=IllegalArgumentException.class)
|
||||
@Test(expected = IllegalArgumentException.class)
|
||||
public void testSharpWrapping2() {
|
||||
new Note(2, Note.Tone.F, true).sharped();
|
||||
}
|
||||
@@ -122,13 +122,13 @@ public class NoteTest {
|
||||
@Test
|
||||
public void testHighest() {
|
||||
Note note = new Note(2, Note.Tone.F, true);
|
||||
assertEquals(note.getId(), (byte)24);
|
||||
assertEquals(note.getId(), (byte) 24);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testLowest() {
|
||||
Note note = new Note(0, Note.Tone.F, true);
|
||||
assertEquals(note.getId(), (byte)0);
|
||||
assertEquals(note.getId(), (byte) 0);
|
||||
}
|
||||
|
||||
@Test
|
||||
|
@@ -25,9 +25,9 @@ public abstract class ConfigurationSectionTest {
|
||||
section.set("key2", true);
|
||||
section.set("42", true);
|
||||
|
||||
assertArrayEquals(new String[] { "key", "subsection", "key2", "42" }, section.getKeys(false).toArray());
|
||||
assertArrayEquals(new String[] { "key", "subsection", "subsection.subkey", "subsection.subkey2", "subsection.subsubsection", "subsection.subsubsection.key", "key2", "42" }, section.getKeys(true).toArray());
|
||||
assertArrayEquals(new String[] { "subkey", "subkey2", "subsubsection", "subsubsection.key" }, section.getConfigurationSection("subsection").getKeys(true).toArray());
|
||||
assertArrayEquals(new String[]{"key", "subsection", "key2", "42"}, section.getKeys(false).toArray());
|
||||
assertArrayEquals(new String[]{"key", "subsection", "subsection.subkey", "subsection.subkey2", "subsection.subsubsection", "subsection.subsubsection.key", "key2", "42"}, section.getKeys(true).toArray());
|
||||
assertArrayEquals(new String[]{"subkey", "subkey2", "subsubsection", "subsubsection.key"}, section.getConfigurationSection("subsection").getKeys(true).toArray());
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -41,9 +41,9 @@ public abstract class ConfigurationSectionTest {
|
||||
section.addDefault("subsection.subsubsection.key", true);
|
||||
section.addDefault("key2", true);
|
||||
|
||||
assertArrayEquals(new String[] { "subsection", "key2", "key" }, section.getKeys(false).toArray());
|
||||
assertArrayEquals(new String[] { "subsection", "subsection.subkey", "subsection.subkey2", "subsection.subsubsection", "subsection.subsubsection.key", "key2", "key" }, section.getKeys(true).toArray());
|
||||
assertArrayEquals(new String[] { "subkey", "subkey2", "subsubsection", "subsubsection.key" }, section.getConfigurationSection("subsection").getKeys(true).toArray());
|
||||
assertArrayEquals(new String[]{"subsection", "key2", "key"}, section.getKeys(false).toArray());
|
||||
assertArrayEquals(new String[]{"subsection", "subsection.subkey", "subsection.subkey2", "subsection.subsubsection", "subsection.subsubsection.key", "key2", "key"}, section.getKeys(true).toArray());
|
||||
assertArrayEquals(new String[]{"subkey", "subkey2", "subsubsection", "subsubsection.key"}, section.getConfigurationSection("subsection").getKeys(true).toArray());
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -56,12 +56,12 @@ public abstract class ConfigurationSectionTest {
|
||||
section.set("int", 42);
|
||||
|
||||
Map<String, Object> shallowValues = section.getValues(false);
|
||||
assertArrayEquals(new String[] { "bool", "subsection", "int" }, shallowValues.keySet().toArray());
|
||||
assertArrayEquals(new Object[] { true, section.getConfigurationSection("subsection"), 42 }, shallowValues.values().toArray());
|
||||
assertArrayEquals(new String[]{"bool", "subsection", "int"}, shallowValues.keySet().toArray());
|
||||
assertArrayEquals(new Object[]{true, section.getConfigurationSection("subsection"), 42}, shallowValues.values().toArray());
|
||||
|
||||
Map<String, Object> deepValues = section.getValues(true);
|
||||
assertArrayEquals(new String[] { "bool", "subsection", "subsection.string", "subsection.long", "int" }, deepValues.keySet().toArray());
|
||||
assertArrayEquals(new Object[] { true, section.getConfigurationSection("subsection"), "test", Long.MAX_VALUE, 42 }, deepValues.values().toArray());
|
||||
assertArrayEquals(new String[]{"bool", "subsection", "subsection.string", "subsection.long", "int"}, deepValues.keySet().toArray());
|
||||
assertArrayEquals(new Object[]{true, section.getConfigurationSection("subsection"), "test", Long.MAX_VALUE, 42}, deepValues.values().toArray());
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -78,12 +78,12 @@ public abstract class ConfigurationSectionTest {
|
||||
section.addDefault("int", 42);
|
||||
|
||||
Map<String, Object> shallowValues = section.getValues(false);
|
||||
assertArrayEquals(new String[] { "int", "bool", "subsection" }, shallowValues.keySet().toArray());
|
||||
assertArrayEquals(new Object[] { 42, true, section.getConfigurationSection("subsection") }, shallowValues.values().toArray());
|
||||
assertArrayEquals(new String[]{"int", "bool", "subsection"}, shallowValues.keySet().toArray());
|
||||
assertArrayEquals(new Object[]{42, true, section.getConfigurationSection("subsection")}, shallowValues.values().toArray());
|
||||
|
||||
Map<String, Object> deepValues = section.getValues(true);
|
||||
assertArrayEquals(new String[] { "subsection.long", "int", "bool", "subsection", "subsection.string" }, deepValues.keySet().toArray());
|
||||
assertArrayEquals(new Object[] { Long.MAX_VALUE, 42, true, section.getConfigurationSection("subsection"), "test" }, deepValues.values().toArray());
|
||||
assertArrayEquals(new String[]{"subsection.long", "int", "bool", "subsection", "subsection.string"}, deepValues.keySet().toArray());
|
||||
assertArrayEquals(new Object[]{Long.MAX_VALUE, 42, true, section.getConfigurationSection("subsection"), "test"}, deepValues.values().toArray());
|
||||
}
|
||||
|
||||
@Test
|
||||
|
@@ -22,23 +22,23 @@ public class YamlConfigurationTest extends FileConfigurationTest {
|
||||
|
||||
@Override
|
||||
public String getTestValuesString() {
|
||||
return "integer: -2147483648\n" +
|
||||
"string: String Value\n" +
|
||||
"long: 9223372036854775807\n" +
|
||||
"true-boolean: true\n" +
|
||||
"false-boolean: false\n" +
|
||||
"vector:\n" +
|
||||
" ==: Vector\n" +
|
||||
" x: 12345.67\n" +
|
||||
" y: 64.0\n" +
|
||||
" z: -12345.6789\n" +
|
||||
"list:\n" +
|
||||
"- 1\n" +
|
||||
"- 2\n" +
|
||||
"- 3\n" +
|
||||
"- 4\n" +
|
||||
"- 5\n" +
|
||||
"'42': The Answer\n";
|
||||
return "integer: -2147483648\n"
|
||||
+ "string: String Value\n"
|
||||
+ "long: 9223372036854775807\n"
|
||||
+ "true-boolean: true\n"
|
||||
+ "false-boolean: false\n"
|
||||
+ "vector:\n"
|
||||
+ " ==: Vector\n"
|
||||
+ " x: 12345.67\n"
|
||||
+ " y: 64.0\n"
|
||||
+ " z: -12345.6789\n"
|
||||
+ "list:\n"
|
||||
+ "- 1\n"
|
||||
+ "- 2\n"
|
||||
+ "- 3\n"
|
||||
+ "- 4\n"
|
||||
+ "- 5\n"
|
||||
+ "'42': The Answer\n";
|
||||
}
|
||||
|
||||
@Test
|
||||
|
@@ -25,50 +25,45 @@ import org.junit.Test;
|
||||
public class MaterialDataTest {
|
||||
|
||||
@Test
|
||||
public void testDoor()
|
||||
{
|
||||
public void testDoor() {
|
||||
@SuppressWarnings("deprecation")
|
||||
Door door = new Door();
|
||||
assertThat("Constructed with default door type",door.getItemType(),equalTo(Material.LEGACY_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));
|
||||
assertThat("Constructed with default door type", door.getItemType(), equalTo(Material.LEGACY_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.LEGACY_WOODEN_DOOR,
|
||||
Material.LEGACY_IRON_DOOR_BLOCK, Material.LEGACY_SPRUCE_DOOR,
|
||||
Material.LEGACY_BIRCH_DOOR, Material.LEGACY_JUNGLE_DOOR,
|
||||
Material.LEGACY_ACACIA_DOOR, Material.LEGACY_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)
|
||||
{
|
||||
Material[] types = new Material[]{Material.LEGACY_WOODEN_DOOR,
|
||||
Material.LEGACY_IRON_DOOR_BLOCK, Material.LEGACY_SPRUCE_DOOR,
|
||||
Material.LEGACY_BIRCH_DOOR, Material.LEGACY_JUNGLE_DOOR,
|
||||
Material.LEGACY_ACACIA_DOOR, Material.LEGACY_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 (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));
|
||||
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));
|
||||
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));
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -242,10 +237,10 @@ public class MaterialDataTest {
|
||||
|
||||
@Test
|
||||
public void testMushroom() {
|
||||
Material[] mushroomTypes = new Material[] { Material.LEGACY_HUGE_MUSHROOM_1, Material.LEGACY_HUGE_MUSHROOM_2 };
|
||||
BlockFace[] setFaces = new BlockFace[] { BlockFace.SELF, BlockFace.UP, BlockFace.NORTH,
|
||||
BlockFace.SOUTH, BlockFace.EAST, BlockFace.WEST, BlockFace.NORTH_EAST, BlockFace.NORTH_WEST,
|
||||
BlockFace.SOUTH_EAST, BlockFace.SOUTH_WEST };
|
||||
Material[] mushroomTypes = new Material[]{Material.LEGACY_HUGE_MUSHROOM_1, Material.LEGACY_HUGE_MUSHROOM_2};
|
||||
BlockFace[] setFaces = new BlockFace[]{BlockFace.SELF, BlockFace.UP, BlockFace.NORTH,
|
||||
BlockFace.SOUTH, BlockFace.EAST, BlockFace.WEST, BlockFace.NORTH_EAST, BlockFace.NORTH_WEST,
|
||||
BlockFace.SOUTH_EAST, BlockFace.SOUTH_WEST};
|
||||
MushroomBlockTexture[] textures = MushroomBlockTexture.values();
|
||||
for (Material type : mushroomTypes) {
|
||||
Mushroom mushroom = new Mushroom(type);
|
||||
@@ -280,7 +275,7 @@ public class MaterialDataTest {
|
||||
}
|
||||
|
||||
// The crops which fully implement all crop states
|
||||
Material[] allCrops = new Material[] {Material.LEGACY_CROPS, Material.LEGACY_CARROT, Material.LEGACY_POTATO};
|
||||
Material[] allCrops = new Material[]{Material.LEGACY_CROPS, Material.LEGACY_CARROT, Material.LEGACY_POTATO};
|
||||
for (Material crop : allCrops) {
|
||||
crops = new Crops(crop);
|
||||
assertThat("Constructed with correct crops type", crops.getItemType(), equalTo(crop));
|
||||
@@ -295,7 +290,7 @@ public class MaterialDataTest {
|
||||
|
||||
// Beetroot are crops too, but they only have four states
|
||||
// Setting different crop states for beetroot will return the following when retrieved back
|
||||
CropState[] beetrootStates = new CropState[] {CropState.SEEDED, CropState.SEEDED, CropState.SMALL, CropState.SMALL, CropState.TALL, CropState.TALL, CropState.RIPE, CropState.RIPE};
|
||||
CropState[] beetrootStates = new CropState[]{CropState.SEEDED, CropState.SEEDED, CropState.SMALL, CropState.SMALL, CropState.TALL, CropState.TALL, CropState.RIPE, CropState.RIPE};
|
||||
assertThat("Beetroot state translations match size", beetrootStates.length, equalTo(allStates.length));
|
||||
crops = new Crops(Material.LEGACY_BEETROOT_BLOCK);
|
||||
assertThat("Constructed with correct crops type", crops.getItemType(), equalTo(Material.LEGACY_BEETROOT_BLOCK));
|
||||
@@ -312,7 +307,7 @@ public class MaterialDataTest {
|
||||
assertThat("Constructed with correct crops type", crops.getItemType(), equalTo(warts.getItemType()));
|
||||
assertThat("Constructed with default crop state", crops.getState(), equalTo(CropState.SEEDED));
|
||||
assertThat("Constructed with default wart state", warts.getState(), equalTo(NetherWartsState.SEEDED));
|
||||
allStates = new CropState[] {CropState.SEEDED, CropState.SMALL, CropState.TALL, CropState.RIPE};
|
||||
allStates = new CropState[]{CropState.SEEDED, CropState.SMALL, CropState.TALL, CropState.RIPE};
|
||||
NetherWartsState[] allWartStates = NetherWartsState.values();
|
||||
assertThat("Nether Warts state translations match size", allWartStates.length, equalTo(allStates.length));
|
||||
for (int s = 0; s < allStates.length; s++) {
|
||||
@@ -332,9 +327,9 @@ public class MaterialDataTest {
|
||||
assertThat("Constructed with default delay", diode.getDelay(), equalTo(1));
|
||||
assertThat("Constructed with default direction", diode.getFacing(), equalTo(BlockFace.NORTH));
|
||||
|
||||
BlockFace[] directions = new BlockFace[] {BlockFace.NORTH, BlockFace.EAST, BlockFace.SOUTH, BlockFace.WEST};
|
||||
int[] delays = new int[] {1, 2, 3, 4};
|
||||
boolean[] states = new boolean[] {false, true};
|
||||
BlockFace[] directions = new BlockFace[]{BlockFace.NORTH, BlockFace.EAST, BlockFace.SOUTH, BlockFace.WEST};
|
||||
int[] delays = new int[]{1, 2, 3, 4};
|
||||
boolean[] states = new boolean[]{false, true};
|
||||
for (BlockFace direction : directions) {
|
||||
diode = new Diode(direction);
|
||||
assertThat("Constructed with default diode state", diode.getItemType(), equalTo(Material.LEGACY_DIODE_BLOCK_OFF));
|
||||
@@ -367,9 +362,9 @@ public class MaterialDataTest {
|
||||
assertThat("Constructed with default mode", comparator.isSubtractionMode(), equalTo(false));
|
||||
assertThat("Constructed with default direction", comparator.getFacing(), equalTo(BlockFace.NORTH));
|
||||
|
||||
BlockFace[] directions = new BlockFace[] {BlockFace.NORTH, BlockFace.EAST, BlockFace.SOUTH, BlockFace.WEST};
|
||||
boolean[] modes = new boolean[] {false, true};
|
||||
boolean[] states = new boolean[] {false, true};
|
||||
BlockFace[] directions = new BlockFace[]{BlockFace.NORTH, BlockFace.EAST, BlockFace.SOUTH, BlockFace.WEST};
|
||||
boolean[] modes = new boolean[]{false, true};
|
||||
boolean[] states = new boolean[]{false, true};
|
||||
for (BlockFace direction : directions) {
|
||||
comparator = new Comparator(direction);
|
||||
assertThat("Constructed with default comparator state", comparator.getItemType(), equalTo(Material.LEGACY_REDSTONE_COMPARATOR_OFF));
|
||||
@@ -393,7 +388,7 @@ public class MaterialDataTest {
|
||||
assertThat("Constructed with correct direction", comparator.getFacing(), equalTo(direction));
|
||||
|
||||
// Check if the game sets the fourth bit, that block data is still interpreted correctly
|
||||
comparator.setData((byte)((comparator.getData() & 0x7) | 0x8));
|
||||
comparator.setData((byte) ((comparator.getData() & 0x7) | 0x8));
|
||||
assertThat("Constructed with correct comparator state", comparator.getItemType(), equalTo(state ? Material.LEGACY_REDSTONE_COMPARATOR_ON : Material.LEGACY_REDSTONE_COMPARATOR_OFF));
|
||||
assertThat("Constructed with correct powered", comparator.isPowered(), equalTo(state));
|
||||
assertThat("Constructed with correct being powered", comparator.isBeingPowered(), equalTo(true));
|
||||
@@ -412,15 +407,15 @@ public class MaterialDataTest {
|
||||
assertThat("Constructed with default powered state", hopper.isPowered(), equalTo(false));
|
||||
assertThat("Constructed with default direction", hopper.getFacing(), equalTo(BlockFace.DOWN));
|
||||
|
||||
BlockFace[] directions = new BlockFace[] {BlockFace.DOWN, BlockFace.NORTH, BlockFace.SOUTH, BlockFace.WEST, BlockFace.EAST};
|
||||
boolean[] activeStates = new boolean[] {true, false};
|
||||
BlockFace[] directions = new BlockFace[]{BlockFace.DOWN, BlockFace.NORTH, BlockFace.SOUTH, BlockFace.WEST, BlockFace.EAST};
|
||||
boolean[] activeStates = new boolean[]{true, false};
|
||||
for (BlockFace direction : directions) {
|
||||
hopper = new Hopper(direction);
|
||||
assertThat("Constructed with default hopper type", hopper.getItemType(), equalTo(Material.LEGACY_HOPPER));
|
||||
assertThat("Constructed with default active state", hopper.isActive(), equalTo(true));
|
||||
assertThat("Constructed with correct powered state", hopper.isPowered(), equalTo(false));
|
||||
assertThat("Constructed with correct direction", hopper.getFacing(), equalTo(direction));
|
||||
for(boolean isActive : activeStates) {
|
||||
for (boolean isActive : activeStates) {
|
||||
hopper = new Hopper(direction, isActive);
|
||||
assertThat("Constructed with default hopper type", hopper.getItemType(), equalTo(Material.LEGACY_HOPPER));
|
||||
assertThat("Constructed with correct active state", hopper.isActive(), equalTo(isActive));
|
||||
|
@@ -22,7 +22,7 @@ public class LazyMetadataValueTest {
|
||||
double value = 10.5;
|
||||
subject = makeSimpleCallable(value);
|
||||
|
||||
assertEquals(value, (Double)subject.value(), 0.01);
|
||||
assertEquals(value, (Double) subject.value(), 0.01);
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -41,7 +41,7 @@ public class LazyMetadataValueTest {
|
||||
assertEquals(value, subject.value());
|
||||
}
|
||||
|
||||
@Test(expected=MetadataEvaluationException.class)
|
||||
@Test(expected = MetadataEvaluationException.class)
|
||||
public void testEvalException() {
|
||||
subject = new LazyMetadataValue(plugin, LazyMetadataValue.CacheStrategy.CACHE_AFTER_FIRST_EVAL, new Callable<Object>() {
|
||||
@Override
|
||||
|
@@ -71,7 +71,9 @@ public class PluginManagerTest {
|
||||
} catch (Throwable ex) {
|
||||
store.value = ex;
|
||||
}
|
||||
}});
|
||||
}
|
||||
}
|
||||
);
|
||||
secondThread.start();
|
||||
secondThread.join();
|
||||
if (store.value != null) {
|
||||
|
@@ -13,7 +13,7 @@ import org.junit.runners.Parameterized.Parameters;
|
||||
@RunWith(Parameterized.class)
|
||||
public class StringUtilStartsWithTest {
|
||||
|
||||
@Parameters(name= "{index}: {0} startsWith {1} == {2}")
|
||||
@Parameters(name = "{index}: {0} startsWith {1} == {2}")
|
||||
public static List<Object[]> data() {
|
||||
return ImmutableList.<Object[]>of(
|
||||
new Object[] {
|
||||
|
@@ -10,27 +10,27 @@ import org.junit.Test;
|
||||
|
||||
public class StringUtilTest {
|
||||
|
||||
@Test(expected=NullPointerException.class)
|
||||
@Test(expected = NullPointerException.class)
|
||||
public void nullPrefixTest() {
|
||||
StringUtil.startsWithIgnoreCase("String", null);
|
||||
}
|
||||
|
||||
@Test(expected=IllegalArgumentException.class)
|
||||
@Test(expected = IllegalArgumentException.class)
|
||||
public void nullStringTest() {
|
||||
StringUtil.startsWithIgnoreCase(null, "String");
|
||||
}
|
||||
|
||||
@Test(expected=IllegalArgumentException.class)
|
||||
@Test(expected = IllegalArgumentException.class)
|
||||
public void nullCollectionTest() {
|
||||
StringUtil.copyPartialMatches("Token", ImmutableList.<String>of(), null);
|
||||
}
|
||||
|
||||
@Test(expected=IllegalArgumentException.class)
|
||||
@Test(expected = IllegalArgumentException.class)
|
||||
public void nullIterableTest() {
|
||||
StringUtil.copyPartialMatches("Token", null, new ArrayList<String>());
|
||||
}
|
||||
|
||||
@Test(expected=IllegalArgumentException.class)
|
||||
@Test(expected = IllegalArgumentException.class)
|
||||
public void nullTokenTest() {
|
||||
StringUtil.copyPartialMatches(null, ImmutableList.<String>of(), new ArrayList<String>());
|
||||
}
|
||||
@@ -38,20 +38,20 @@ public class StringUtilTest {
|
||||
@Test
|
||||
public void copyTokenTest() {
|
||||
String token = "ab";
|
||||
Iterable<String> original = ImmutableList.of("ab12", "aC561", "AB5195", "Ab76", "", "a");
|
||||
List<String> expected = ImmutableList.of("ab12", "AB5195", "Ab76" );
|
||||
List<String> original = ImmutableList.of("ab12", "aC561", "AB5195", "Ab76", "", "a");
|
||||
List<String> expected = ImmutableList.of("ab12", "AB5195", "Ab76");
|
||||
List<String> list = new ArrayList<String>();
|
||||
assertThat(StringUtil.copyPartialMatches(token, original, list), is(expected));
|
||||
assertThat(StringUtil.copyPartialMatches(token, original, list), is(sameInstance(list)));
|
||||
assertThat(list.size(), is(expected.size() * 2));
|
||||
}
|
||||
|
||||
@Test(expected=UnsupportedOperationException.class)
|
||||
@Test(expected = UnsupportedOperationException.class)
|
||||
public void copyUnsupportedTest() {
|
||||
StringUtil.copyPartialMatches("token", ImmutableList.of("token1", "token2"), ImmutableList.of());
|
||||
}
|
||||
|
||||
@Test(expected=IllegalArgumentException.class)
|
||||
@Test(expected = IllegalArgumentException.class)
|
||||
public void copyNullTest() {
|
||||
StringUtil.copyPartialMatches("token", Arrays.asList("token1", "token2", null), new ArrayList<String>());
|
||||
}
|
||||
|
@@ -25,7 +25,7 @@ import org.yaml.snakeyaml.external.biz.base64Coder.Base64Coder;
|
||||
@RunWith(Parameterized.class)
|
||||
public class BukkitObjectStreamTest {
|
||||
|
||||
@Parameters(name= "{index}: {0}")
|
||||
@Parameters(name = "{index}: {0}")
|
||||
public static List<Object[]> data() {
|
||||
return ImmutableList.<Object[]>of(
|
||||
new Object[] {
|
||||
|
Reference in New Issue
Block a user