1 30 package org.objectweb.asm.signature; 31 32 import java.io.InputStream ; 33 import java.io.InputStreamReader ; 34 import java.io.LineNumberReader ; 35 36 import org.objectweb.asm.signature.SignatureReader; 37 import org.objectweb.asm.signature.SignatureWriter; 38 39 import junit.framework.TestCase; 40 import junit.framework.TestSuite; 41 42 48 public class SignatureTest extends TestCase { 49 50 private String line; 51 52 public SignatureTest(String line) { 53 super("test"); 54 this.line = line; 55 } 56 57 public static TestSuite suite() throws Exception { 58 TestSuite suite = new TestSuite(); 59 InputStream is = SignatureTest.class.getResourceAsStream("signatures.txt"); 60 LineNumberReader lnr = new LineNumberReader (new InputStreamReader (is)); 61 62 String line; 63 while ((line = lnr.readLine()) != null) { 64 if (line.length() < 2) { 65 continue; 66 } 67 suite.addTest(new SignatureTest(line)); 68 } 69 lnr.close(); 70 return suite; 71 } 72 73 public void test() throws Exception { 74 if (line.length() > 2) { 75 String signature = line.substring(2); 76 SignatureWriter wrt = new SignatureWriter(); 77 SignatureReader rdr = new SignatureReader(signature); 78 switch (line.charAt(0)) { 79 case 'C': 80 case 'M': 81 rdr.accept(wrt); 82 break; 83 case 'T': 84 rdr.acceptType(wrt); 85 break; 86 default: 87 return; 88 } 89 assertEquals(signature, wrt.toString()); 90 } 91 } 92 } 93 | Popular Tags |