100% test coverage for ThrowsCountCheck, #1009
This commit is contained in:
parent
893621b965
commit
2c99b9706e
1
pom.xml
1
pom.xml
|
|
@ -766,7 +766,6 @@
|
|||
<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.ThrowsCountCheck</pattern><branchRate>75</branchRate><lineRate>82</lineRate></regex>
|
||||
<regex><pattern>.*.checks.design.VisibilityModifierCheck</pattern><branchRate>95</branchRate><lineRate>95</lineRate></regex>
|
||||
|
||||
<regex><pattern>.*.checks.header.AbstractHeaderCheck</pattern><branchRate>85</branchRate><lineRate>85</lineRate></regex>
|
||||
|
|
|
|||
|
|
@ -19,15 +19,22 @@
|
|||
|
||||
package com.puppycrawl.tools.checkstyle.checks.design;
|
||||
|
||||
import antlr.CommonHiddenStreamToken;
|
||||
|
||||
import com.puppycrawl.tools.checkstyle.BaseCheckTestSupport;
|
||||
import com.puppycrawl.tools.checkstyle.DefaultConfiguration;
|
||||
|
||||
import java.io.File;
|
||||
|
||||
import com.puppycrawl.tools.checkstyle.api.DetailAST;
|
||||
import com.puppycrawl.tools.checkstyle.api.TokenTypes;
|
||||
|
||||
import org.junit.Test;
|
||||
|
||||
import static com.puppycrawl.tools.checkstyle.checks.design.ThrowsCountCheck.MSG_KEY;
|
||||
import static org.junit.Assert.assertArrayEquals;
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import static org.junit.Assert.fail;
|
||||
|
||||
public class ThrowsCountCheckTest extends BaseCheckTestSupport {
|
||||
@Test
|
||||
|
|
@ -68,4 +75,18 @@ public class ThrowsCountCheckTest extends BaseCheckTestSupport {
|
|||
int[] expected = {TokenTypes.LITERAL_THROWS};
|
||||
assertArrayEquals(expected, obj.getRequiredTokens());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testWrongTokenType() {
|
||||
ThrowsCountCheck obj = new ThrowsCountCheck();
|
||||
DetailAST ast = new DetailAST();
|
||||
ast.initialize(new CommonHiddenStreamToken(TokenTypes.CLASS_DEF, "class"));
|
||||
try {
|
||||
obj.visitToken(ast);
|
||||
fail();
|
||||
}
|
||||
catch (IllegalStateException e) {
|
||||
assertEquals(ast.toString(), e.getMessage());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue