1 18 19 package alt.jiapi.reflect; 20 21 import junit.framework.TestCase; 22 23 28 public class SignatureTest extends TestCase { 29 public SignatureTest(String name) { 30 super(name); 31 } 32 33 public String getName() { 34 return "SignatureTest: " + super.getName(); 35 } 36 37 protected void setUp() { 38 } 39 40 public void testSignature() { 41 assertTrue("(B)V".equals(new Signature("void", new String []{"byte"}).getDescriptor())); 42 assertTrue("(I)V".equals(new Signature("void", new String []{"int"}).getDescriptor())); 43 assertTrue("(J)V".equals(new Signature("void", new String []{"long"}).getDescriptor())); 44 assertTrue("(C)V".equals(new Signature("void", new String []{"char"}).getDescriptor())); 45 assertTrue("(Z)V".equals(new Signature("void", new String []{"boolean"}).getDescriptor())); 46 assertTrue("(F)V".equals(new Signature("void", new String []{"float"}).getDescriptor())); 47 assertTrue("(D)V".equals(new Signature("void", new String []{"double"}).getDescriptor())); 48 assertTrue("()V".equals(new Signature("void", new String [0]).getDescriptor())); 49 assertTrue("(Ljava/lang/Object;)V".equals(new Signature("void", new String []{"java.lang.Object"}).getDescriptor())); 50 51 assertTrue("(BI)V".equals(new Signature("void", new String []{"byte", "int"}).getDescriptor())); 52 assertTrue("(BLjava/lang/Object;I)V".equals(new Signature("void", new String []{"byte", "java.lang.Object", "int"}).getDescriptor())); 53 assertTrue("([B[I)V".equals(new Signature("void", new String []{"byte[]", "int[]"}).getDescriptor())); 54 assertTrue("([B[I)[F".equals(new Signature(" float [] ", new String []{" byte [] ", " int [] "}).getDescriptor())); 55 } 56 57 58 public void testSignatureToSimpleName() { 59 assertTrue("byte".equals(SignatureUtil.toSimpleName("B"))); 60 assertTrue("int".equals(SignatureUtil.toSimpleName("I"))); 61 assertTrue("long".equals(SignatureUtil.toSimpleName("J"))); 62 assertTrue("char".equals(SignatureUtil.toSimpleName("C"))); 63 assertTrue("boolean".equals(SignatureUtil.toSimpleName("Z"))); 64 assertTrue("float".equals(SignatureUtil.toSimpleName("F"))); 65 assertTrue("double".equals(SignatureUtil.toSimpleName("D"))); 66 assertTrue("void".equals(SignatureUtil.toSimpleName("V"))); 67 68 assertTrue("java.lang.Object".equals(SignatureUtil.toSimpleName("Ljava/lang/Object;"))); 69 assertTrue("byte[]".equals(SignatureUtil.toSimpleName("[B"))); 70 assertTrue("byte[][]".equals(SignatureUtil.toSimpleName("[[B"))); 71 assertTrue("byte[][][]".equals(SignatureUtil.toSimpleName("[[[B"))); 72 assertTrue("java.lang.Object[]".equals(SignatureUtil.toSimpleName("[Ljava/lang/Object;"))); 73 assertTrue("java.lang.Object[][]".equals(SignatureUtil.toSimpleName("[[Ljava/lang/Object;"))); 74 assertTrue("java.lang.Object[][][]".equals(SignatureUtil.toSimpleName("[[[Ljava/lang/Object;"))); 75 } 76 } 77 | Popular Tags |