summaryrefslogtreecommitdiff
path: root/test/cuchaz/enigma/TestJarIndexConstructorReferences.java
diff options
context:
space:
mode:
authorGravatar jeff2014-09-14 23:56:43 -0400
committerGravatar jeff2014-09-14 23:56:43 -0400
commit72e918a5134c2bf747a476284bcfa1bd2ef2fa21 (patch)
tree2fd256d6a8bbe38b7b9fe1892f444a8c29de08ef /test/cuchaz/enigma/TestJarIndexConstructorReferences.java
parentadded test to check constructor references (diff)
downloadenigma-fork-72e918a5134c2bf747a476284bcfa1bd2ef2fa21.tar.gz
enigma-fork-72e918a5134c2bf747a476284bcfa1bd2ef2fa21.tar.xz
enigma-fork-72e918a5134c2bf747a476284bcfa1bd2ef2fa21.zip
added tests to check constructor tokens
fixed a bug with constructor tokens too
Diffstat (limited to 'test/cuchaz/enigma/TestJarIndexConstructorReferences.java')
-rw-r--r--test/cuchaz/enigma/TestJarIndexConstructorReferences.java29
1 files changed, 23 insertions, 6 deletions
diff --git a/test/cuchaz/enigma/TestJarIndexConstructorReferences.java b/test/cuchaz/enigma/TestJarIndexConstructorReferences.java
index 38882a0..c069188 100644
--- a/test/cuchaz/enigma/TestJarIndexConstructorReferences.java
+++ b/test/cuchaz/enigma/TestJarIndexConstructorReferences.java
@@ -18,10 +18,13 @@ import static org.hamcrest.Matchers.containsInAnyOrder;
18import static org.hamcrest.Matchers.empty; 18import static org.hamcrest.Matchers.empty;
19import static org.hamcrest.Matchers.is; 19import static org.hamcrest.Matchers.is;
20 20
21import java.io.File;
22import java.util.Collection;
21import java.util.jar.JarFile; 23import java.util.jar.JarFile;
22 24
23import org.junit.Test; 25import org.junit.Test;
24 26
27import cuchaz.enigma.analysis.EntryReference;
25import cuchaz.enigma.analysis.JarIndex; 28import cuchaz.enigma.analysis.JarIndex;
26import cuchaz.enigma.mapping.BehaviorEntry; 29import cuchaz.enigma.mapping.BehaviorEntry;
27import cuchaz.enigma.mapping.ClassEntry; 30import cuchaz.enigma.mapping.ClassEntry;
@@ -30,17 +33,19 @@ import cuchaz.enigma.mapping.ConstructorEntry;
30public class TestJarIndexConstructorReferences 33public class TestJarIndexConstructorReferences
31{ 34{
32 private JarIndex m_index; 35 private JarIndex m_index;
33 36
34 private ClassEntry m_baseClass = new ClassEntry( "none/a" ); 37 private ClassEntry m_baseClass = new ClassEntry( "none/a" );
35 private ClassEntry m_subClass = new ClassEntry( "none/c" ); 38 private ClassEntry m_subClass = new ClassEntry( "none/d" );
36 private ClassEntry m_subsubClass = new ClassEntry( "none/d" ); 39 private ClassEntry m_subsubClass = new ClassEntry( "none/e" );
40 private ClassEntry m_defaultClass = new ClassEntry( "none/c" );
37 private ClassEntry m_callerClass = new ClassEntry( "none/b" ); 41 private ClassEntry m_callerClass = new ClassEntry( "none/b" );
38 42
39 public TestJarIndexConstructorReferences( ) 43 public TestJarIndexConstructorReferences( )
40 throws Exception 44 throws Exception
41 { 45 {
46 File jarFile = new File( "build/libs/testConstructors.obf.jar" );
42 m_index = new JarIndex(); 47 m_index = new JarIndex();
43 m_index.indexJar( new JarFile( "build/libs/testConstructors.obf.jar" ), false ); 48 m_index.indexJar( new JarFile( jarFile ), false );
44 } 49 }
45 50
46 @Test 51 @Test
@@ -51,6 +56,7 @@ public class TestJarIndexConstructorReferences
51 m_baseClass, 56 m_baseClass,
52 m_subClass, 57 m_subClass,
53 m_subsubClass, 58 m_subsubClass,
59 m_defaultClass,
54 m_callerClass 60 m_callerClass
55 ) ); 61 ) );
56 } 62 }
@@ -60,7 +66,8 @@ public class TestJarIndexConstructorReferences
60 public void baseDefault( ) 66 public void baseDefault( )
61 { 67 {
62 BehaviorEntry source = new ConstructorEntry( m_baseClass, "()V" ); 68 BehaviorEntry source = new ConstructorEntry( m_baseClass, "()V" );
63 assertThat( m_index.getBehaviorReferences( source ), containsInAnyOrder( 69 Collection<EntryReference<BehaviorEntry,BehaviorEntry>> references = m_index.getBehaviorReferences( source );
70 assertThat( references, containsInAnyOrder(
64 newBehaviorReferenceByMethod( source, m_callerClass.getName(), "a", "()V" ), 71 newBehaviorReferenceByMethod( source, m_callerClass.getName(), "a", "()V" ),
65 newBehaviorReferenceByConstructor( source, m_subClass.getName(), "()V" ), 72 newBehaviorReferenceByConstructor( source, m_subClass.getName(), "()V" ),
66 newBehaviorReferenceByConstructor( source, m_subClass.getName(), "(III)V" ) 73 newBehaviorReferenceByConstructor( source, m_subClass.getName(), "(III)V" )
@@ -126,4 +133,14 @@ public class TestJarIndexConstructorReferences
126 newBehaviorReferenceByMethod( source, m_callerClass.getName(), "f", "()V" ) 133 newBehaviorReferenceByMethod( source, m_callerClass.getName(), "f", "()V" )
127 ) ); 134 ) );
128 } 135 }
136
137 @Test
138 @SuppressWarnings( "unchecked" )
139 public void defaultConstructable( )
140 {
141 BehaviorEntry source = new ConstructorEntry( m_defaultClass, "()V" );
142 assertThat( m_index.getBehaviorReferences( source ), containsInAnyOrder(
143 newBehaviorReferenceByMethod( source, m_callerClass.getName(), "g", "()V" )
144 ) );
145 }
129} 146}