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 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
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,7 @@ Note that this project **does not** adhere to [Semantic Versioning](http://semve
- We fixed an issue where no preview could be generated for some entry types and led to an exception [#9947](https://github.com/JabRef/jabref/issues/9947)
- We fixed an issue where the Linux terminal working directory argument was malformed and therefore ignored upon opening a terminal [#9953](https://github.com/JabRef/jabref/issues/9953)
- We fixed an issue where an Automatic Keyword Group could not be deleted in the UI. [#9778](https://github.com/JabRef/jabref/issues/9778)
- We fixed an issue where the citation key pattern `[edtrN_M]` returned the wrong editor. [#9946](https://github.com/JabRef/jabref/pull/9946)

### Removed

Expand Down
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,27 @@ 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'",

"'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));
}
}