Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add 0 to allowed package name characters #364

Merged
merged 3 commits into from
Sep 9, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ class SourceJarCreator(
private const val BL = """\p{Blank}*"""
private const val COM_BL = """$BL(?:/\*[^\n]*\*/$BL)*"""
private val PKG_PATTERN: Pattern =
Pattern.compile("""^${COM_BL}package$COM_BL([a-zA-Z1-9._]+)$COM_BL(?:;?.*)$""")
Pattern.compile("""^${COM_BL}package$COM_BL([a-zA-Z0-9._]+)$COM_BL(?:;?.*)$""")

@JvmStatic
fun extractPackage(line: String): String? =
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,4 +49,16 @@ public void testPackageNameRegex() {
subj.that(pkg).isEqualTo(expectedPackage);
});
}

@Test
public void testPackageNameRegexWithZero() {
cases.forEach(
(testCase) -> {
testCase = testCase.replace("some1", "some0");
String pkg = SourceJarCreator.Companion.extractPackage(testCase);
StandardSubjectBuilder subj = assertWithMessage("positive test case: " + testCase);
subj.that(pkg).isNotNull();
subj.that(pkg).isEqualTo("iO.some0.package");
});
}
}