Issue #1288: 'PackageNameCheck' UT coverage improved

This commit is contained in:
Ruslan Diachenko 2015-07-07 23:55:58 +01:00 committed by Roman Ivanov
parent fa8b3ed7e1
commit 66cd03e57e
2 changed files with 16 additions and 4 deletions

View File

@ -876,7 +876,6 @@
<regex><pattern>.*.checks.naming.LocalVariableNameCheck</pattern><branchRate>94</branchRate><lineRate>100</lineRate></regex>
<regex><pattern>.*.checks.naming.MemberNameCheck</pattern><branchRate>91</branchRate><lineRate>85</lineRate></regex>
<regex><pattern>.*.checks.naming.MethodNameCheck</pattern><branchRate>100</branchRate><lineRate>93</lineRate></regex>
<regex><pattern>.*.checks.naming.PackageNameCheck</pattern><branchRate>100</branchRate><lineRate>88</lineRate></regex>
<regex><pattern>.*.checks.regexp.CommentSuppressor</pattern><branchRate>75</branchRate><lineRate>100</lineRate></regex>
<regex><pattern>.*.checks.regexp.DetectorOptions</pattern><branchRate>100</branchRate><lineRate>96</lineRate></regex>

View File

@ -19,12 +19,14 @@
package com.puppycrawl.tools.checkstyle.checks.naming;
import com.puppycrawl.tools.checkstyle.BaseCheckTestSupport;
import com.puppycrawl.tools.checkstyle.DefaultConfiguration;
import static com.puppycrawl.tools.checkstyle.checks.naming.AbstractNameCheck.MSG_INVALID_PATTERN;
import org.junit.Assert;
import org.junit.Test;
import static com.puppycrawl.tools.checkstyle.checks.naming.AbstractNameCheck.MSG_INVALID_PATTERN;
import com.puppycrawl.tools.checkstyle.BaseCheckTestSupport;
import com.puppycrawl.tools.checkstyle.DefaultConfiguration;
import com.puppycrawl.tools.checkstyle.api.TokenTypes;
public class PackageNameCheckTest
extends BaseCheckTestSupport {
@ -52,4 +54,15 @@ public class PackageNameCheckTest
};
verify(checkConfig, getPath("InputSimple.java"), expected);
}
@Test
public void testGetAcceptableTokens() {
PackageNameCheck packageNameCheckObj = new PackageNameCheck();
int[] actual = packageNameCheckObj.getAcceptableTokens();
int[] expected = new int[] {
TokenTypes.PACKAGE_DEF,
};
Assert.assertNotNull(actual);
Assert.assertArrayEquals(expected, actual);
}
}