diff options
| author | Michael Williamson <mike@zwobble.org> | 2016-02-23 20:48:50 +0000 |
|---|---|---|
| committer | Michael Williamson <mike@zwobble.org> | 2016-02-23 20:48:50 +0000 |
| commit | ce3d0cb6b5349787d26f4a2d7201b3d04b8e5085 (patch) | |
| tree | ef055c3449b4b8511dbc474b45241fd19b3927e1 /src/test/java/org/zwobble/mammoth/tests/styles/DocumentMatcherParsingTests.java | |
| parent | 14a07f679a1ad1726445f363fee484e3b2d52884 (diff) | |
Add parsing for paragraph matchers
Diffstat (limited to 'src/test/java/org/zwobble/mammoth/tests/styles/DocumentMatcherParsingTests.java')
| -rw-r--r-- | src/test/java/org/zwobble/mammoth/tests/styles/DocumentMatcherParsingTests.java | 53 |
1 files changed, 53 insertions, 0 deletions
diff --git a/src/test/java/org/zwobble/mammoth/tests/styles/DocumentMatcherParsingTests.java b/src/test/java/org/zwobble/mammoth/tests/styles/DocumentMatcherParsingTests.java new file mode 100644 index 0000000..dc87945 --- /dev/null +++ b/src/test/java/org/zwobble/mammoth/tests/styles/DocumentMatcherParsingTests.java @@ -0,0 +1,53 @@ +package org.zwobble.mammoth.tests.styles; + +import org.junit.Test; +import org.parboiled.support.Var; +import org.zwobble.mammoth.styles.ParagraphMatcher; +import org.zwobble.mammoth.styles.parsing.Parsing; +import org.zwobble.mammoth.styles.parsing.StyleMappingParser; + +import static org.hamcrest.MatcherAssert.assertThat; +import static org.zwobble.mammoth.tests.DeepReflectionMatcher.deepEquals; + +public class DocumentMatcherParsingTests { + @Test + public void canReadPlainParagraph() { + assertThat( + parseParagraphMatcher("p"), + deepEquals(ParagraphMatcher.ANY)); + } + + @Test + public void readsParagraphWithStyleId() { + assertThat( + parseParagraphMatcher("p.Heading1"), + deepEquals(ParagraphMatcher.styleId("Heading1"))); + } + + @Test + public void readsParagraphWithStyleName() { + assertThat( + parseParagraphMatcher("p[style-name='Heading 1']"), + deepEquals(ParagraphMatcher.styleName("Heading 1"))); + } + + @Test + public void readsParagraphOrderedList() { + assertThat( + parseParagraphMatcher("p:ordered-list(2)"), + deepEquals(ParagraphMatcher.orderedList("1"))); + } + + @Test + public void readsParagraphUnorderedList() { + assertThat( + parseParagraphMatcher("p:unordered-list(2)"), + deepEquals(ParagraphMatcher.unorderedList("1"))); + } + + private ParagraphMatcher parseParagraphMatcher(String input) { + Var<ParagraphMatcher> matcher = new Var<>(); + Parsing.parse(StyleMappingParser.class, parser -> parser.ParagraphMatcher(matcher), input); + return matcher.get(); + } +} |
