mirror of
https://github.com/MinecraftForge/MinecraftForge.git
synced 2026-11-17 11:05:40 +00:00
Fix enum helpers for EnumRarity {moved to Commn and changed paramter} and EnumCreatureType {new parameter} and added junit test for them. Closes #1009
This commit is contained in:
1 parent
0a56e19d47
commit
0737601dbf
3 files changed
+70
-11
No files matched your search
@@ -0,0 +1,58 @@
|
||||
package net.minecraftforge.test;
|
||||
|
||||
import java.lang.reflect.Constructor;
|
||||
import java.lang.reflect.Method;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import net.minecraftforge.client.EnumHelperClient;
|
||||
import net.minecraftforge.common.util.EnumHelper;
|
||||
|
||||
import org.apache.logging.log4j.core.helpers.Assert;
|
||||
import org.junit.Test;
|
||||
|
||||
import cpw.mods.fml.relauncher.ReflectionHelper;
|
||||
|
||||
public class EnumHelperTest
|
||||
{
|
||||
private boolean failed = false;
|
||||
|
||||
@Test
|
||||
public void test()
|
||||
{
|
||||
System.out.println("Testing EnumHelper:");
|
||||
Object[][] types = (Object[][])ReflectionHelper.getPrivateValue(EnumHelper.class, null, "commonTypes");
|
||||
for (Object[] o : types)
|
||||
testType(o);
|
||||
|
||||
System.out.println("Testing EnumHelperClient:");
|
||||
types = (Object[][])ReflectionHelper.getPrivateValue(EnumHelperClient.class, null, "clentTypes");
|
||||
for (Object[] o : types)
|
||||
testType(o);
|
||||
|
||||
if (failed)
|
||||
throw new RuntimeException("Enum Helper test failed!");
|
||||
}
|
||||
private void testType(Object[] info)
|
||||
{
|
||||
Class<?> cls = (Class)info[0];
|
||||
Class<?>[] parameterTypes = new Class[info.length + 2 - 1];
|
||||
parameterTypes[0] = String.class;
|
||||
parameterTypes[1] = int.class;
|
||||
System.arraycopy(info, 1, parameterTypes, 2, info.length - 1);
|
||||
try
|
||||
{
|
||||
cls.getDeclaredConstructor(parameterTypes);
|
||||
System.out.println(" " + cls.getName() + ": Success");
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
System.out.println(" " + cls.getName() + ": Failed");
|
||||
for (Constructor<?> c : cls.getDeclaredConstructors())
|
||||
{
|
||||
System.out.println(" " + c.toString());
|
||||
}
|
||||
failed = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user