-
-
Notifications
You must be signed in to change notification settings - Fork 2.6k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
c695230
commit 0b55b34
Showing
3 changed files
with
96 additions
and
20 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
73 changes: 73 additions & 0 deletions
73
src/test/java/org/jabref/logic/integrity/PagesCheckerBibLatexTest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,73 @@ | ||
package org.jabref.logic.integrity; | ||
|
||
import java.util.Optional; | ||
|
||
import org.jabref.model.database.BibDatabaseContext; | ||
import org.jabref.model.database.BibDatabaseMode; | ||
|
||
import org.junit.jupiter.api.BeforeEach; | ||
import org.junit.jupiter.api.Test; | ||
|
||
import static org.junit.jupiter.api.Assertions.assertEquals; | ||
|
||
class PagesCheckerBibLatexTest { | ||
|
||
private PagesChecker checker; | ||
|
||
@BeforeEach | ||
void setUp() { | ||
BibDatabaseContext database = new BibDatabaseContext(); | ||
database.setMode(BibDatabaseMode.BIBLATEX); | ||
checker = new PagesChecker(database); | ||
} | ||
|
||
@Test | ||
void acceptsSinglePage() { | ||
assertEquals(Optional.empty(), checker.checkValue("12")); | ||
} | ||
|
||
@Test | ||
void acceptsSinglePageRange() { | ||
assertEquals(Optional.empty(), checker.checkValue("12-15")); | ||
} | ||
|
||
@Test | ||
void acceptsSinglePageRangeWithDoubleDashes() { | ||
assertEquals(Optional.empty(), checker.checkValue("12--15")); | ||
} | ||
|
||
@Test | ||
void acceptsSinglePageRangeWithEnDashes() { | ||
assertEquals(Optional.empty(), checker.checkValue("12–15")); | ||
} | ||
|
||
@Test | ||
void acceptsSinglePageRangeWithPagePrefix() { | ||
assertEquals(Optional.empty(), checker.checkValue("R795--R804")); | ||
} | ||
|
||
@Test | ||
void acceptsMultiplePageRange() { | ||
assertEquals(Optional.empty(), checker.checkValue("12-15,18-29")); | ||
} | ||
|
||
@Test | ||
void acceptsOpenEndPageRange() { | ||
assertEquals(Optional.empty(), checker.checkValue("-15")); | ||
} | ||
|
||
@Test | ||
void acceptsOpenStartPageRange() { | ||
assertEquals(Optional.empty(), checker.checkValue("12-")); | ||
} | ||
|
||
@Test | ||
void complainsAboutPPrefix() { | ||
assertEquals(Optional.of("should contain a valid page number range"), checker.checkValue("p. 12")); | ||
} | ||
|
||
@Test | ||
void complainsAboutPPPrefix() { | ||
assertEquals(Optional.of("should contain a valid page number range"), checker.checkValue("pp. 12-15")); | ||
} | ||
} |