### Question:
CheckSignatureAdapter extends SignatureVisitor { @Override public void visitBaseType(final char descriptor) { if (type != TYPE_SIGNATURE || state != State.EMPTY) { throw new IllegalStateException(); } if (descriptor == 'V') { if (!canBeVoid) { throw new IllegalArgumentException("Base type descriptor can't be V"); } } else { if ("ZCBSIFJD".indexOf(descriptor) == -1) { throw new IllegalArgumentException("Base type descriptor must be one of ZCBSIFJD"); } } state = State.SIMPLE_TYPE; if (signatureVisitor != null) { signatureVisitor.visitBaseType(descriptor); } } CheckSignatureAdapter(final int type, final SignatureVisitor signatureVisitor); protected  CheckSignatureAdapter(
      final int api, final int type, final SignatureVisitor signatureVisitor); @Override void visitFormalTypeParameter(final String name); @Override SignatureVisitor visitClassBound(); @Override SignatureVisitor visitInterfaceBound(); @Override SignatureVisitor visitSuperclass(); @Override SignatureVisitor visitInterface(); @Override SignatureVisitor visitParameterType(); @Override SignatureVisitor visitReturnType(); @Override SignatureVisitor visitExceptionType(); @Override void visitBaseType(final char descriptor); @Override void visitTypeVariable(final String name); @Override SignatureVisitor visitArrayType(); @Override void visitClassType(final String name); @Override void visitInnerClassType(final String name); @Override void visitTypeArgument(); @Override SignatureVisitor visitTypeArgument(final char wildcard); @Override void visitEnd(); static final int CLASS_SIGNATURE; static final int METHOD_SIGNATURE; static final int TYPE_SIGNATURE; }### Answer:
@Test public void testVisitBaseType_typeSignature_illegalState() { CheckSignatureAdapter checkSignatureAdapter = new CheckSignatureAdapter(CheckSignatureAdapter.TYPE_SIGNATURE, null); checkSignatureAdapter.visitBaseType('I'); Executable visitBaseType = () -> checkSignatureAdapter.visitBaseType('I'); assertThrows(IllegalStateException.class, visitBaseType); }
@Test public void testVisitBaseType_typeSignature_illegalVoidArgument() { CheckSignatureAdapter checkSignatureAdapter = new CheckSignatureAdapter(CheckSignatureAdapter.TYPE_SIGNATURE, null); Executable visitBaseType = () -> checkSignatureAdapter.visitBaseType('V'); Exception exception = assertThrows(IllegalArgumentException.class, visitBaseType); assertEquals("Base type descriptor can't be V", exception.getMessage()); }
@Test public void testVisitBaseType_typeSignature_illegalArgument() { CheckSignatureAdapter checkSignatureAdapter = new CheckSignatureAdapter(CheckSignatureAdapter.TYPE_SIGNATURE, null); Executable visitBaseType = () -> checkSignatureAdapter.visitBaseType('A'); Exception exception = assertThrows(IllegalArgumentException.class, visitBaseType); assertEquals("Base type descriptor must be one of ZCBSIFJD", exception.getMessage()); }
@Test public void testVisitBaseType_classSignature_illegalState() { CheckSignatureAdapter checkSignatureAdapter = new CheckSignatureAdapter(CheckSignatureAdapter.CLASS_SIGNATURE, null); Executable visitBaseType = () -> checkSignatureAdapter.visitBaseType('I'); assertThrows(IllegalStateException.class, visitBaseType); }