-
-
Notifications
You must be signed in to change notification settings - Fork 2.7k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix for entering a backslash in the custom entry preview dialog (#7851)
- Loading branch information
Showing
3 changed files
with
49 additions
and
5 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
39 changes: 39 additions & 0 deletions
39
src/test/java/org/jabref/logic/layout/LayoutHelperTest.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,39 @@ | ||
package org.jabref.logic.layout; | ||
|
||
import java.io.IOException; | ||
import java.io.StringReader; | ||
|
||
import org.junit.jupiter.api.Test; | ||
|
||
import static org.junit.jupiter.api.Assertions.assertNotNull; | ||
import static org.junit.jupiter.api.Assertions.assertThrows; | ||
import static org.mockito.Mockito.mock; | ||
|
||
class LayoutHelperTest { | ||
|
||
@Test | ||
public void backslashDoesNotTriggerException() { | ||
StringReader stringReader = new StringReader("\\"); | ||
LayoutFormatterPreferences layoutFormatterPreferences = mock(LayoutFormatterPreferences.class); | ||
LayoutHelper layoutHelper = new LayoutHelper(stringReader, layoutFormatterPreferences); | ||
assertThrows(IOException.class, () -> layoutHelper.getLayoutFromText()); | ||
} | ||
|
||
@Test | ||
public void unbalancedBeginEndIsParsed() throws Exception { | ||
StringReader stringReader = new StringReader("\\begin{doi}, DOI: \\doi"); | ||
LayoutFormatterPreferences layoutFormatterPreferences = mock(LayoutFormatterPreferences.class); | ||
LayoutHelper layoutHelper = new LayoutHelper(stringReader, layoutFormatterPreferences); | ||
Layout layout = layoutHelper.getLayoutFromText(); | ||
assertNotNull(layout); | ||
} | ||
|
||
@Test | ||
public void minimalExampleWithDoiGetsParsed() throws Exception { | ||
StringReader stringReader = new StringReader("\\begin{doi}, DOI: \\doi\\end{doi}"); | ||
LayoutFormatterPreferences layoutFormatterPreferences = mock(LayoutFormatterPreferences.class); | ||
LayoutHelper layoutHelper = new LayoutHelper(stringReader, layoutFormatterPreferences); | ||
Layout layout = layoutHelper.getLayoutFromText(); | ||
assertNotNull(layout); | ||
} | ||
} |