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 editor pattern test in BracketedPatternTest #9946

Merged
merged 7 commits into from
Jun 2, 2023
Merged
Show file tree
Hide file tree
Changes from 2 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 @@ -421,7 +421,7 @@ public static String getFieldValue(BibEntry entry, String pattern, Character key
String[] nums = pattern.substring(4).split("_");
return authNofMth(editorList,
Integer.parseInt(nums[0]),
Integer.parseInt(nums[1]) - 1);
Integer.parseInt(nums[1]));
} else if (pattern.matches("edtr\\d+")) {
String fa = firstAuthor(editorList);
int num = Integer.parseInt(pattern.substring(4));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -660,4 +660,29 @@ void expandBracketsWithoutProtectiveBracesUsingUnprotectTermsModifier() {
.withField(StandardField.JOURNAL, "{ACS} Medicinal Chemistry Letters");
assertEquals("ACS Medicinal Chemistry Letters", BracketedPattern.expandBrackets("[JOURNAL:unprotect_terms]", null, bibEntry, null));
}


@ParameterizedTest
@CsvSource({
"'Newton', '[edtr]', 'Isaac Newton'",
"'I', '[edtrForeIni]', 'Isaac Newton'",
"'Newton', '[editors]', 'Isaac Newton'",
"'Ne', '[edtrIni2]', 'Isaac Newton'",
"'New', '[edtr3]', 'Isaac Newton'",
"'Newton', '[edtr7]', 'Isaac Newton'",
"'New', '[edtr3_1]', 'Isaac Newton'",
"'Newton.Maxwell', '[edtr.edtr.ea]', 'Isaac Newton and James Maxwell'",
"'Newton', '[edtrshort]', 'Isaac Newton'",
"'Newton', '[editorLast]', 'Isaac Newton'",
"'I', '[editorLastForeIni]', 'Isaac Newton'",

"'Agency', '[editors]', 'European Union Aviation Safety Agency'",
Siedlerchr marked this conversation as resolved.
Show resolved Hide resolved
Siedlerchr marked this conversation as resolved.
Show resolved Hide resolved
"'EUASA', '[editors]', '{European Union Aviation Safety Agency}'"
})
void testEditorFieldMarkers(String expectedCitationKey, String pattern, String editor) {
BibEntry bibEntry = new BibEntry().withField(StandardField.EDITOR, editor);
BracketedPattern bracketedPattern = new BracketedPattern(pattern);
assertEquals(expectedCitationKey, bracketedPattern.expand(bibEntry));
}

}