Skip to content

Commit

Permalink
Add failing tests for #216.
Browse files Browse the repository at this point in the history
  • Loading branch information
TomasMikula committed Jan 25, 2016
1 parent ee9bb60 commit 9878d04
Show file tree
Hide file tree
Showing 2 changed files with 45 additions and 3 deletions.
22 changes: 22 additions & 0 deletions richtextfx/src/test/java/org/fxmisc/richtext/ParagraphTest.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
package org.fxmisc.richtext;

import static org.junit.Assert.*;

import org.junit.Test;

public class ParagraphTest {

// Tests that when concatenating two paragraphs,
// the style of the first one is used for the result.
// This relates to merging text changes and issue #216.
@Test
public void concatEmptyParagraphsTest() {
Paragraph<Boolean, Void> p1 = new Paragraph<>(null, "", true);
Paragraph<Boolean, Void> p2 = new Paragraph<>(null, "", false);

Paragraph<Boolean, Void> p = p1.concat(p2);

assertEquals(Boolean.TRUE, p.getStyleAtPosition(0));
}

}
Original file line number Diff line number Diff line change
@@ -1,13 +1,12 @@
package org.fxmisc.richtext;

import static org.junit.Assert.*;
import javafx.embed.swing.JFXPanel;

import org.junit.Test;

import java.util.Collection;
import java.util.Collections;

import org.junit.Test;

public class StyledTextAreaModelTest {

@Test
Expand All @@ -28,4 +27,25 @@ public void testUndoWithWinNewlines() {
assertEquals("abc\ndef", model.getText());
}

@Test
public void testForBug216() {
// set up area with some styled text content
boolean initialStyle = false;
StyledTextAreaModel<Boolean, String> model = new StyledTextAreaModel<>(
initialStyle, "", new EditableStyledDocument<>(initialStyle, ""), true);
model.replaceText("testtest");
model.setStyle(0, 8, true);

// add a space styled by initialStyle
model.setUseInitialStyleForInsertion(true);
model.insertText(4, " ");

// add another space
model.insertText(5, " ");

// testing that undo/redo don't throw an exception
model.undo();
model.redo();
}

}

0 comments on commit 9878d04

Please sign in to comment.