package org.fxmisc.richtext.model;

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() {
        TextOps<StyledText<Boolean>, Boolean> segOps = StyledText.textOps();
        Paragraph<Void, StyledText<Boolean>, Boolean> p1 = new Paragraph<>(null, segOps, segOps.create("", true));
        Paragraph<Void, StyledText<Boolean>, Boolean> p2 = new Paragraph<>(null, segOps, segOps.create("", false));

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

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

}

@@ -796,10 +796,724 @@
 %0A    %7D%0A%0A
+    // Relates to #345 and #505: calling %60EditableStyledDocument::setStyleSpans%60 when the style spans%0A    //  would style an empty paragraph would throw an exception%0A    @Test%0A    public void restylingEmptyParagraphViaStyleSpansWorks() %7B%0A        TextOps%3CStyledText%3CBoolean%3E, Boolean%3E segOps = StyledText.textOps();%0A        Paragraph%3CVoid, StyledText%3CBoolean%3E, Boolean%3E p = new Paragraph%3C%3E(null, segOps, segOps.createEmpty());%0A%0A        StyleSpansBuilder%3CBoolean%3E builder = new StyleSpansBuilder%3C%3E();%0A        builder.add(true, 2);%0A        StyleSpans%3CBoolean%3E spans = builder.create();%0A        Paragraph%3CVoid, StyledText%3CBoolean%3E, Boolean%3E restyledP = p.restyle(0, spans);%0A%0A        assertEquals(p, restyledP);%0A    %7D%0A%0A
 %7D%0A

Write test: restyling newline char should not throw exception