Hinzufügen von equals() und hashCode() Tests zu IntermediateRefTypeTest und IntermediateGenericTypeTest.
This commit is contained in:
parent
8b58259fe0
commit
f1f028f0b9
@ -4,6 +4,5 @@ package de.dhbwstuttgart.intermediate.types;
|
|||||||
* Only Java types which can be used as an inner type, have a descriptor definition.
|
* Only Java types which can be used as an inner type, have a descriptor definition.
|
||||||
*/
|
*/
|
||||||
public abstract class IntermediateInnerType extends IntermediateType {
|
public abstract class IntermediateInnerType extends IntermediateType {
|
||||||
|
|
||||||
public abstract String getDescriptor();
|
public abstract String getDescriptor();
|
||||||
}
|
}
|
||||||
|
@ -8,6 +8,7 @@ import org.junit.Test;
|
|||||||
import org.objectweb.asm.Type;
|
import org.objectweb.asm.Type;
|
||||||
|
|
||||||
import static org.junit.Assert.assertEquals;
|
import static org.junit.Assert.assertEquals;
|
||||||
|
import static org.junit.Assert.assertNotEquals;
|
||||||
|
|
||||||
public class IntermediateGenericTypeTest {
|
public class IntermediateGenericTypeTest {
|
||||||
|
|
||||||
@ -23,6 +24,8 @@ public class IntermediateGenericTypeTest {
|
|||||||
private static String rExtendsSDescriptor;
|
private static String rExtendsSDescriptor;
|
||||||
private static IntermediateGenericType rExtendsS;
|
private static IntermediateGenericType rExtendsS;
|
||||||
|
|
||||||
|
private static IntermediateGenericType rSame;
|
||||||
|
|
||||||
@BeforeClass
|
@BeforeClass
|
||||||
public static void StartUp(){
|
public static void StartUp(){
|
||||||
tSignature = "TT;";
|
tSignature = "TT;";
|
||||||
@ -37,6 +40,8 @@ public class IntermediateGenericTypeTest {
|
|||||||
rExtendsSSignature = "TR;";
|
rExtendsSSignature = "TR;";
|
||||||
rExtendsSDescriptor = sExtendsStringDescriptor;
|
rExtendsSDescriptor = sExtendsStringDescriptor;
|
||||||
rExtendsS = new IntermediateGenericType("R", sExtendsString);
|
rExtendsS = new IntermediateGenericType("R", sExtendsString);
|
||||||
|
|
||||||
|
rSame = new IntermediateGenericType("R", sExtendsString);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
@ -56,4 +61,16 @@ public class IntermediateGenericTypeTest {
|
|||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void DescriptorTest_TExtendsS(){ assertEquals(rExtendsSDescriptor, rExtendsS.getDescriptor()); }
|
public void DescriptorTest_TExtendsS(){ assertEquals(rExtendsSDescriptor, rExtendsS.getDescriptor()); }
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void HashCodeTest_Succeed() { assertEquals(rSame.hashCode(), rExtendsS.hashCode());}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void HashCodeTest_Fail() { assertNotEquals(rSame.hashCode(), t.hashCode()); }
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void EqualsTest_Succeed() { assertEquals(rSame, rExtendsS); }
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void EqualsTest_Fail() { assertNotEquals(rSame, t); }
|
||||||
}
|
}
|
||||||
|
@ -11,6 +11,7 @@ import java.util.Arrays;
|
|||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
import static org.junit.Assert.assertEquals;
|
import static org.junit.Assert.assertEquals;
|
||||||
|
import static org.junit.Assert.assertNotEquals;
|
||||||
|
|
||||||
public class IntermediateRefTypeTest {
|
public class IntermediateRefTypeTest {
|
||||||
|
|
||||||
@ -26,6 +27,8 @@ public class IntermediateRefTypeTest {
|
|||||||
private static String voidDescriptor;
|
private static String voidDescriptor;
|
||||||
private static IntermediateRefType typeToTest_void;
|
private static IntermediateRefType typeToTest_void;
|
||||||
|
|
||||||
|
private static IntermediateRefType typeToTest_ListOfIntegerSame;
|
||||||
|
|
||||||
@BeforeClass
|
@BeforeClass
|
||||||
public static void StartUp(){
|
public static void StartUp(){
|
||||||
integerSignature = "Ljava/lang/Integer;";
|
integerSignature = "Ljava/lang/Integer;";
|
||||||
@ -41,6 +44,10 @@ public class IntermediateRefTypeTest {
|
|||||||
voidSignature = "V";
|
voidSignature = "V";
|
||||||
voidDescriptor = "V";
|
voidDescriptor = "V";
|
||||||
typeToTest_void = new IntermediateRefType(new JavaClassName("void"));
|
typeToTest_void = new IntermediateRefType(new JavaClassName("void"));
|
||||||
|
|
||||||
|
typeToTest_ListOfIntegerSame = new IntermediateRefType(
|
||||||
|
new JavaClassName(Type.getInternalName(List.class)),
|
||||||
|
Arrays.asList(typeToTest_Integer));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
@ -68,4 +75,16 @@ public class IntermediateRefTypeTest {
|
|||||||
public void DescriptorTest_Void(){
|
public void DescriptorTest_Void(){
|
||||||
assertEquals(voidDescriptor, typeToTest_void.getDescriptor());
|
assertEquals(voidDescriptor, typeToTest_void.getDescriptor());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void HashCodeTest_Succeed() { assertEquals(typeToTest_ListOfIntegerSame.hashCode(), typeToTest_ListOfInteger.hashCode());}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void HashCodeTest_Fail() { assertNotEquals(typeToTest_ListOfIntegerSame.hashCode(), typeToTest_Integer.hashCode()); }
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void EqualsTest_Succeed() { assertEquals(typeToTest_ListOfIntegerSame, typeToTest_ListOfInteger); }
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void EqualsTest_Fail() { assertNotEquals(typeToTest_ListOfIntegerSame, typeToTest_Integer); }
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user