100% test coverage for MutableExceptionCheck, #1009
This commit is contained in:
parent
d8c8ab3077
commit
66caf30d0f
1
pom.xml
1
pom.xml
|
|
@ -761,7 +761,6 @@
|
|||
|
||||
<regex><pattern>.*.checks.design.InnerTypeLastCheck</pattern><branchRate>100</branchRate><lineRate>93</lineRate></regex>
|
||||
<regex><pattern>.*.checks.design.InterfaceIsTypeCheck</pattern><branchRate>100</branchRate><lineRate>85</lineRate></regex>
|
||||
<regex><pattern>.*.checks.design.MutableExceptionCheck</pattern><branchRate>85</branchRate><lineRate>92</lineRate></regex>
|
||||
<regex><pattern>.*.checks.design.OneTopLevelClassCheck</pattern><branchRate>77</branchRate><lineRate>95</lineRate></regex>
|
||||
<regex><pattern>.*.checks.design.VisibilityModifierCheck</pattern><branchRate>95</branchRate><lineRate>95</lineRate></regex>
|
||||
|
||||
|
|
|
|||
|
|
@ -19,15 +19,20 @@
|
|||
|
||||
package com.puppycrawl.tools.checkstyle.checks.design;
|
||||
|
||||
import antlr.CommonHiddenStreamToken;
|
||||
|
||||
import com.puppycrawl.tools.checkstyle.BaseCheckTestSupport;
|
||||
import com.puppycrawl.tools.checkstyle.DefaultConfiguration;
|
||||
import com.puppycrawl.tools.checkstyle.api.DetailAST;
|
||||
import com.puppycrawl.tools.checkstyle.api.TokenTypes;
|
||||
|
||||
import org.junit.Test;
|
||||
|
||||
import java.io.File;
|
||||
|
||||
import static com.puppycrawl.tools.checkstyle.checks.design.MutableExceptionCheck.MSG_KEY;
|
||||
import static org.junit.Assert.assertArrayEquals;
|
||||
import static org.junit.Assert.fail;
|
||||
|
||||
public class MutableExceptionCheckTest extends BaseCheckTestSupport {
|
||||
@Test
|
||||
|
|
@ -67,4 +72,18 @@ public class MutableExceptionCheckTest extends BaseCheckTestSupport {
|
|||
int[] expected = {TokenTypes.CLASS_DEF, TokenTypes.VARIABLE_DEF};
|
||||
assertArrayEquals(expected, obj.getRequiredTokens());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testWrongTokenType() {
|
||||
MutableExceptionCheck obj = new MutableExceptionCheck();
|
||||
DetailAST ast = new DetailAST();
|
||||
ast.initialize(new CommonHiddenStreamToken(TokenTypes.INTERFACE_DEF, "interface"));
|
||||
try {
|
||||
obj.visitToken(ast);
|
||||
fail();
|
||||
}
|
||||
catch (IllegalStateException e) {
|
||||
//expected
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -32,6 +32,11 @@ public class InputMutableException {
|
|||
|
||||
public class CustomFailure extends ThreadDeath {
|
||||
private int errorCode;
|
||||
public void someMethod() {
|
||||
if(true) {
|
||||
final int i = 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue