Skip to content

Commit

Permalink
Merge pull request #9946 from chiao26168/add-test-editor
Browse files Browse the repository at this point in the history
Add editor pattern test in BracketedPatternTest
  • Loading branch information
Siedlerchr committed Jun 2, 2023
2 parents c7ada34 + 1efb54a commit 6124f04
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 1 deletion.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,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));
}
}

0 comments on commit 6124f04

Please sign in to comment.