示例#1
0
  @Test
  public void testGetAuthorsLastFirstOxfordComma() {
    // Oxford comma
    AuthorList al;

    al = AuthorList.parse("");
    Assert.assertEquals("", al.getAsLastFirstNames(true, true));
    Assert.assertEquals("", al.getAsLastFirstNames(false, true));

    al = AuthorList.parse("John Smith");
    Assert.assertEquals("Smith, John", al.getAsLastFirstNames(false, true));
    Assert.assertEquals("Smith, J.", al.getAsLastFirstNames(true, true));

    al = AuthorList.parse("John Smith and Black Brown, Peter");
    Assert.assertEquals("Smith, John and Black Brown, Peter", al.getAsLastFirstNames(false, true));
    Assert.assertEquals("Smith, J. and Black Brown, P.", al.getAsLastFirstNames(true, true));

    al = AuthorList.parse("John von Neumann and John Smith and Black Brown, Peter");
    Assert.assertEquals(
        "von Neumann, John, Smith, John, and Black Brown, Peter",
        al.getAsLastFirstNames(false, true));
    Assert.assertEquals(
        "von Neumann, J., Smith, J., and Black Brown, P.", al.getAsLastFirstNames(true, true));

    al = AuthorList.parse("John Peter von Neumann");
    Assert.assertEquals("von Neumann, J. P.", al.getAsLastFirstNames(true, true));
  }
示例#2
0
  @Test
  public void testGetAuthorsLastFirstNoComma() {
    // No commas before and
    AuthorList al;

    al = AuthorList.parse("");
    Assert.assertEquals("", al.getAsLastFirstNames(true, false));
    Assert.assertEquals("", al.getAsLastFirstNames(false, false));

    al = AuthorList.parse("John Smith");
    Assert.assertEquals("Smith, John", al.getAsLastFirstNames(false, false));
    Assert.assertEquals("Smith, J.", al.getAsLastFirstNames(true, false));

    al = AuthorList.parse("John Smith and Black Brown, Peter");
    Assert.assertEquals("Smith, John and Black Brown, Peter", al.getAsLastFirstNames(false, false));
    Assert.assertEquals("Smith, J. and Black Brown, P.", al.getAsLastFirstNames(true, false));

    al = AuthorList.parse("John von Neumann and John Smith and Black Brown, Peter");
    // Method description is different than code -> additional comma
    // there
    Assert.assertEquals(
        "von Neumann, John, Smith, John and Black Brown, Peter",
        al.getAsLastFirstNames(false, false));
    Assert.assertEquals(
        "von Neumann, J., Smith, J. and Black Brown, P.", al.getAsLastFirstNames(true, false));

    al = AuthorList.parse("John Peter von Neumann");
    Assert.assertEquals("von Neumann, J. P.", al.getAsLastFirstNames(true, false));
  }