Skip to content

Commit 246caea

Browse files
Luggas4youkoppor
andauthored
Add tests for code coverage (#10309)
* @test for AuthorListTest.java * @test for FieldComparatorTest.java --------- Co-authored-by: Oliver Kopp <[email protected]>
1 parent 6e3f081 commit 246caea

File tree

2 files changed

+23
-0
lines changed

2 files changed

+23
-0
lines changed

src/test/java/org/jabref/logic/bibtex/comparator/FieldComparatorTest.java

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -250,4 +250,15 @@ private static Stream<Arguments> nullTests() {
250250
Arguments.of(1, "value", null)
251251
);
252252
}
253+
254+
@Test
255+
public void compareAuthorField() throws Exception {
256+
FieldComparator comparator = new FieldComparator(StandardField.AUTHOR);
257+
BibEntry bigger = new BibEntry()
258+
.withField(StandardField.AUTHOR, "Freund, Lucas");
259+
BibEntry smaller = new BibEntry()
260+
.withField(StandardField.AUTHOR, "Gärtner, Lara");
261+
262+
assertEquals(1, comparator.compare(smaller, bigger));
263+
}
253264
}

src/test/java/org/jabref/model/entry/AuthorListTest.java

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1213,4 +1213,16 @@ public void hashCodeNotConstant() {
12131213
AuthorList secondAuthorList = AuthorList.of(new Author("B", null, null, null, null));
12141214
assertNotEquals(firstAuthorList.hashCode(), secondAuthorList.hashCode());
12151215
}
1216+
1217+
@Test
1218+
public void getAsLastFirstFirstLastNamesWithAndEmptyAuthor() {
1219+
assertEquals("",
1220+
EMPTY_AUTHOR.getAsLastFirstFirstLastNamesWithAnd(true));
1221+
}
1222+
1223+
@Test
1224+
public void getAsLastFirstFirstLastNamesWithAndMultipleAuthors() {
1225+
assertEquals("al-Khw{\\={a}}rizm{\\={i}}, M. and C. B{\\\"o}hm and K. G{\\\"{o}}del",
1226+
THREE_AUTHORS_WITH_LATEX.getAsLastFirstFirstLastNamesWithAnd(true));
1227+
}
12161228
}

0 commit comments

Comments
 (0)