}
}
public void testGetAuthorsLastFirst() {
{ // No commas before and
AuthorList al;
al = AuthorList.getAuthorList("");
assertEquals("", al.getAuthorsLastFirst(true, false));
assertEquals("", al.getAuthorsLastFirst(false, false));
al = AuthorList.getAuthorList("John Smith");
assertEquals("Smith, John", al.getAuthorsLastFirst(false, false));
assertEquals("Smith, J.", al.getAuthorsLastFirst(true, false));
al = AuthorList.getAuthorList("John Smith and Black Brown, Peter");
assertEquals("Smith, John and Black Brown, Peter", al.getAuthorsLastFirst(false, false));
assertEquals("Smith, J. and Black Brown, P.", al.getAuthorsLastFirst(true, false));
al = AuthorList.getAuthorList("John von Neumann and John Smith and Black Brown, Peter");
// Method description is different than code -> additional comma
// there
assertEquals("von Neumann, John, Smith, John and Black Brown, Peter", al
.getAuthorsLastFirst(false, false));
assertEquals("von Neumann, J., Smith, J. and Black Brown, P.", al.getAuthorsLastFirst(
true, false));
al = AuthorList.getAuthorList("John Peter von Neumann");
assertEquals("von Neumann, J. P.", al.getAuthorsLastFirst(true, false));
}
{ // Oxford comma
AuthorList al;
al = AuthorList.getAuthorList("");
assertEquals("", al.getAuthorsLastFirst(true, true));
assertEquals("", al.getAuthorsLastFirst(false, true));
al = AuthorList.getAuthorList("John Smith");
assertEquals("Smith, John", al.getAuthorsLastFirst(false, true));
assertEquals("Smith, J.", al.getAuthorsLastFirst(true, true));
al = AuthorList.getAuthorList("John Smith and Black Brown, Peter");
assertEquals("Smith, John and Black Brown, Peter", al.getAuthorsLastFirst(false, true));
assertEquals("Smith, J. and Black Brown, P.", al.getAuthorsLastFirst(true, true));
al = AuthorList.getAuthorList("John von Neumann and John Smith and Black Brown, Peter");
assertEquals("von Neumann, John, Smith, John, and Black Brown, Peter", al
.getAuthorsLastFirst(false, true));
assertEquals("von Neumann, J., Smith, J., and Black Brown, P.", al.getAuthorsLastFirst(
true, true));
al = AuthorList.getAuthorList("John Peter von Neumann");
assertEquals("von Neumann, J. P.", al.getAuthorsLastFirst(true, true));
}
}