From 8b58259fe0f83d74a089ca7faf38076dc9bc5b71 Mon Sep 17 00:00:00 2001 From: Etienne Zink Date: Sun, 20 Mar 2022 16:34:01 +0100 Subject: [PATCH] =?UTF-8?q?Hinzuf=C3=BCgen=20von=20Test=20zu=20Intermediat?= =?UTF-8?q?eRefTypeTest=20und=20IntermediateGenericTypeTest.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../types/IntermediateGenericTypeTest.java | 56 +++++++++++++++++-- .../types/IntermediateRefTypeTest.java | 8 +-- 2 files changed, 56 insertions(+), 8 deletions(-) diff --git a/src/test/java/intermediate/types/IntermediateGenericTypeTest.java b/src/test/java/intermediate/types/IntermediateGenericTypeTest.java index c7dbed45..3663faae 100644 --- a/src/test/java/intermediate/types/IntermediateGenericTypeTest.java +++ b/src/test/java/intermediate/types/IntermediateGenericTypeTest.java @@ -1,11 +1,59 @@ package intermediate.types; -import org.junit.Assert; +import de.dhbwstuttgart.intermediate.types.IntermediateGenericType; +import de.dhbwstuttgart.intermediate.types.IntermediateRefType; +import de.dhbwstuttgart.parser.scope.JavaClassName; +import org.junit.BeforeClass; import org.junit.Test; +import org.objectweb.asm.Type; + +import static org.junit.Assert.assertEquals; public class IntermediateGenericTypeTest { - @Test - public void ToDo(){ - Assert.fail(); + + private static String tSignature; + private static String tDescriptor; + private static IntermediateGenericType t; + + private static String sExtendsStringSignature; + private static String sExtendsStringDescriptor; + private static IntermediateGenericType sExtendsString; + + private static String rExtendsSSignature; + private static String rExtendsSDescriptor; + private static IntermediateGenericType rExtendsS; + + @BeforeClass + public static void StartUp(){ + tSignature = "TT;"; + tDescriptor = "Ljava/lang/Object;"; + t = new IntermediateGenericType("T"); + + sExtendsStringSignature = "TS;"; + sExtendsStringDescriptor = "Ljava/lang/String;"; + sExtendsString = new IntermediateGenericType("S", + new IntermediateRefType(new JavaClassName(Type.getInternalName(String.class)))); + + rExtendsSSignature = "TR;"; + rExtendsSDescriptor = sExtendsStringDescriptor; + rExtendsS = new IntermediateGenericType("R", sExtendsString); } + + @Test + public void SignatureTest_T(){ assertEquals(tSignature, t.getSignature()); } + + @Test + public void DescriptorTest_T(){ assertEquals(tDescriptor, t.getDescriptor()); } + + @Test + public void SignatureTest_TExtendsString(){ assertEquals(sExtendsStringSignature, sExtendsString.getSignature()); } + + @Test + public void DescriptorTest_TExtendsString(){ assertEquals(sExtendsStringDescriptor, sExtendsString.getDescriptor()); } + + @Test + public void SignatureTest_TExtendsS(){ assertEquals(rExtendsSSignature, rExtendsS.getSignature()); } + + @Test + public void DescriptorTest_TExtendsS(){ assertEquals(rExtendsSDescriptor, rExtendsS.getDescriptor()); } } diff --git a/src/test/java/intermediate/types/IntermediateRefTypeTest.java b/src/test/java/intermediate/types/IntermediateRefTypeTest.java index b9cfa6d0..b03a988e 100644 --- a/src/test/java/intermediate/types/IntermediateRefTypeTest.java +++ b/src/test/java/intermediate/types/IntermediateRefTypeTest.java @@ -20,7 +20,7 @@ public class IntermediateRefTypeTest { private static String listOfIntegerSignature; private static String listOfIntegerDescriptor; - private static IntermediateRefType typeToTest_ListofInteger; + private static IntermediateRefType typeToTest_ListOfInteger; private static String voidSignature; private static String voidDescriptor; @@ -34,7 +34,7 @@ public class IntermediateRefTypeTest { listOfIntegerSignature = "Ljava/util/List;"; listOfIntegerDescriptor = "Ljava/util/List;"; - typeToTest_ListofInteger = new IntermediateRefType( + typeToTest_ListOfInteger = new IntermediateRefType( new JavaClassName(Type.getInternalName(List.class)), Arrays.asList(typeToTest_Integer)); @@ -54,10 +54,10 @@ public class IntermediateRefTypeTest { } @Test - public void SignatureTest_List(){ assertEquals(listOfIntegerSignature, typeToTest_ListofInteger.getSignature()); } + public void SignatureTest_List(){ assertEquals(listOfIntegerSignature, typeToTest_ListOfInteger.getSignature()); } @Test - public void DescriptorTest_List(){ assertEquals(listOfIntegerDescriptor, typeToTest_ListofInteger.getDescriptor()); } + public void DescriptorTest_List(){ assertEquals(listOfIntegerDescriptor, typeToTest_ListOfInteger.getDescriptor()); } @Test public void SignatureTest_Void(){