Skip to content

Commit

Permalink
Add tests for the truncate BibTex key modifier
Browse files Browse the repository at this point in the history
  • Loading branch information
k3KAW8Pnf7mkmdSMPHz27 committed May 5, 2020
1 parent 6ae850a commit 19fbbb3
Showing 1 changed file with 42 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -1026,6 +1026,48 @@ void generateKeyWithTwoModifiers() throws Exception {
assertEquals("theinterestingtitle", BibtexKeyGenerator.generateKey(entry, "title:lower:(_)"));
}

@Test
void generateKeyWithTruncate4Modifier() {
BibEntry entry = new BibEntry();
entry.setField(StandardField.TITLE, "The Interesting Title");
assertEquals("TheI", BibtexKeyGenerator.generateKey(entry, "title:truncate4"));
}

@Test
void generateKeyWithTruncate5Modifier() {
BibEntry entry = new BibEntry();
entry.setField(StandardField.TITLE, "The Interesting Title");
assertEquals("TheIn", BibtexKeyGenerator.generateKey(entry, "title:truncate5"));
}

@Test
void generateKeyWithTruncate6Modifier() {
BibEntry entry = new BibEntry();
entry.setField(StandardField.TITLE, "The Interesting Title");
assertEquals("TheInt", BibtexKeyGenerator.generateKey(entry, "title:truncate6"));
}

@Test
void generateKeyWithShortTruncateModifier() {
BibEntry entry = new BibEntry();
entry.setField(StandardField.TITLE, "The Interesting Title");
assertEquals("", BibtexKeyGenerator.generateKey(entry, "title:truncate0"));
}

@Test
void generateKeyWithLongTruncateModifier() {
BibEntry entry = new BibEntry();
entry.setField(StandardField.TITLE, "The Interesting Title");
assertEquals("TheInterestingTitle", BibtexKeyGenerator.generateKey(entry, "title:truncate99"));
}

@Test
void generateKeyWithTwoTruncateModifiers() {
BibEntry entry = new BibEntry();
entry.setField(StandardField.TITLE, "The Interesting Title");
assertEquals("The", BibtexKeyGenerator.generateKey(entry, "title:truncate5:truncate3"));
}

@Test
void generateKeyWithTitleCapitalizeModifier() throws Exception {
BibEntry entry = new BibEntry();
Expand Down

0 comments on commit 19fbbb3

Please sign in to comment.