### Question:
Type { public String getDescriptor() { if (sort == OBJECT) { return valueBuffer.substring(valueBegin - 1, valueEnd + 1); } else if (sort == INTERNAL) { return 'L' + valueBuffer.substring(valueBegin, valueEnd) + ';'; } else { return valueBuffer.substring(valueBegin, valueEnd); } } private  Type(final int sort, final String valueBuffer, final int valueBegin, final int valueEnd); static Type getType(final String typeDescriptor); static Type getType(final Class<?> clazz); static Type getType(final Constructor<?> constructor); static Type getType(final Method method); Type getElementType(); static Type getObjectType(final String internalName); static Type getMethodType(final String methodDescriptor); static Type getMethodType(final Type returnType, final Type... argumentTypes); Type[] getArgumentTypes(); static Type[] getArgumentTypes(final String methodDescriptor); static Type[] getArgumentTypes(final Method method); Type getReturnType(); static Type getReturnType(final String methodDescriptor); static Type getReturnType(final Method method); String getClassName(); String getInternalName(); static String getInternalName(final Class<?> clazz); String getDescriptor(); static String getDescriptor(final Class<?> clazz); static String getConstructorDescriptor(final Constructor<?> constructor); static String getMethodDescriptor(final Type returnType, final Type... argumentTypes); static String getMethodDescriptor(final Method method); int getSort(); int getDimensions(); int getSize(); int getArgumentsAndReturnSizes(); static int getArgumentsAndReturnSizes(final String methodDescriptor); int getOpcode(final int opcode); @Override boolean equals(final Object object); @Override int hashCode(); @Override String toString(); static final int VOID; static final int BOOLEAN; static final int CHAR; static final int BYTE; static final int SHORT; static final int INT; static final int FLOAT; static final int LONG; static final int DOUBLE; static final int ARRAY; static final int OBJECT; static final int METHOD; static final Type VOID_TYPE; static final Type BOOLEAN_TYPE; static final Type CHAR_TYPE; static final Type BYTE_TYPE; static final Type SHORT_TYPE; static final Type INT_TYPE; static final Type FLOAT_TYPE; static final Type LONG_TYPE; static final Type DOUBLE_TYPE; }### Answer:
@Test public void testGetDescriptor_typeConstants() { assertEquals("V", Type.VOID_TYPE.getDescriptor()); assertEquals("Z", Type.BOOLEAN_TYPE.getDescriptor()); assertEquals("C", Type.CHAR_TYPE.getDescriptor()); assertEquals("B", Type.BYTE_TYPE.getDescriptor()); assertEquals("S", Type.SHORT_TYPE.getDescriptor()); assertEquals("I", Type.INT_TYPE.getDescriptor()); assertEquals("F", Type.FLOAT_TYPE.getDescriptor()); assertEquals("J", Type.LONG_TYPE.getDescriptor()); assertEquals("J", Type.LONG_TYPE.getDescriptor()); assertEquals("D", Type.DOUBLE_TYPE.getDescriptor()); }
@Test public void testGetDescriptor() { assertEquals("[LI;", Type.getObjectType("[LI;").getDescriptor()); assertEquals("Ljava/lang/Object;", Type.getObjectType("java/lang/Object").getDescriptor()); assertEquals("Ljava/lang/Object;", Type.getType("Ljava/lang/Object;").getDescriptor()); }
@Test public void testGetDescriptorFromClass() { assertEquals("V", Type.getDescriptor(void.class)); assertEquals("Z", Type.getDescriptor(boolean.class)); assertEquals("C", Type.getDescriptor(char.class)); assertEquals("B", Type.getDescriptor(byte.class)); assertEquals("S", Type.getDescriptor(short.class)); assertEquals("I", Type.getDescriptor(int.class)); assertEquals("F", Type.getDescriptor(float.class)); assertEquals("J", Type.getDescriptor(long.class)); assertEquals("D", Type.getDescriptor(double.class)); assertEquals("Ljava/lang/Object;", Type.getDescriptor(Object.class)); assertEquals("[Ljava/lang/Object;", Type.getDescriptor(Object[].class)); assertEquals("[[Ljava/lang/Object;", Type.getDescriptor(Object[][].class)); assertEquals("[[I", Type.getDescriptor(int[][].class)); }