Skip to content

Commit

Permalink
Some more test cases
Browse files Browse the repository at this point in the history
  • Loading branch information
oscargus committed Dec 5, 2015
1 parent 3e8a2d9 commit 2e9f27b
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 4 deletions.
4 changes: 2 additions & 2 deletions src/main/java/net/sf/jabref/bibtex/DuplicateCheck.java
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,8 @@
*/
public class DuplicateCheck {

private static final Log LOGGER = LogFactory.getLog(DuplicateCheck.class);

/*
* Integer values for indicating result of duplicate check (for entries):
*
Expand All @@ -50,8 +52,6 @@ public class DuplicateCheck {
// Extra weighting of those fields that are most likely to provide correct duplicate detection:
private static final HashMap<String, Double> fieldWeights = new HashMap<>();

private static final Log LOGGER = LogFactory.getLog(DuplicateCheck.class);


static {
DuplicateCheck.fieldWeights.put("author", 2.5);
Expand Down
22 changes: 20 additions & 2 deletions src/test/java/net/sf/jabref/bibtex/DuplicateCheckTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -48,18 +48,36 @@ public void testDuplicateDetection() {
one.setField("title", "A title");
two.setField("title", "A title");
one.setField("journal", "A");
two.setField("journal", "A");
Assert.assertTrue(DuplicateCheck.isDuplicate(one, two));
Assert.assertEquals(1.01, DuplicateCheck.compareEntriesStrictly(one, two), 0.01);

two.setField("journal", "B");
Assert.assertTrue(DuplicateCheck.isDuplicate(one, two));
Assert.assertEquals(0.75, DuplicateCheck.compareEntriesStrictly(one, two), 0.01);

two.setField("journal", "A");
one.setField("number", "1");
two.setField("volume", "21");
one.setField("pages", "334--337");
two.setField("pages", "334--337");
Assert.assertTrue(DuplicateCheck.isDuplicate(one, two));

two.setField("number", "1");
one.setField("volume", "21");
two.setField("volume", "21");
Assert.assertTrue(DuplicateCheck.isDuplicate(one, two));

two.setField("volume", "22");
Assert.assertTrue(DuplicateCheck.isDuplicate(one, two));

two.setField("title", "Another title");
two.setField("journal", "B");
Assert.assertTrue(DuplicateCheck.isDuplicate(one, two));

one.setField("journal", "");
two.setField("journal", "");
Assert.assertTrue(DuplicateCheck.isDuplicate(one, two));

two.setField("title", "Another title");
Assert.assertFalse(DuplicateCheck.isDuplicate(one, two));
}

Expand Down

0 comments on commit 2e9f27b

Please sign in to comment.