diff options
| author | Michael Williamson <mike@zwobble.org> | 2016-11-19 12:50:00 +0000 |
|---|---|---|
| committer | Michael Williamson <mike@zwobble.org> | 2016-11-19 12:50:00 +0000 |
| commit | 8f06cee544fb14d427075756dec4312199cf59af (patch) | |
| tree | 4e50bdfe123667b262f20f73033b4e459c85aaac /src/test/java | |
| parent | 43fd447875e11c16b228c911f4669eca50d426c2 (diff) | |
Parse startsWith string matcher
Diffstat (limited to 'src/test/java')
| -rw-r--r-- | src/test/java/org/zwobble/mammoth/tests/styles/parsing/DocumentMatcherParsingTests.java | 15 | ||||
| -rw-r--r-- | src/test/java/org/zwobble/mammoth/tests/styles/parsing/StyleMappingTokeniserTests.java | 5 |
2 files changed, 18 insertions, 2 deletions
diff --git a/src/test/java/org/zwobble/mammoth/tests/styles/parsing/DocumentMatcherParsingTests.java b/src/test/java/org/zwobble/mammoth/tests/styles/parsing/DocumentMatcherParsingTests.java index 3c00909..0ee863a 100644 --- a/src/test/java/org/zwobble/mammoth/tests/styles/parsing/DocumentMatcherParsingTests.java +++ b/src/test/java/org/zwobble/mammoth/tests/styles/parsing/DocumentMatcherParsingTests.java @@ -1,8 +1,10 @@ package org.zwobble.mammoth.tests.styles.parsing; import org.junit.Test; +import org.zwobble.mammoth.internal.styles.EqualToStringMatcher; import org.zwobble.mammoth.internal.styles.ParagraphMatcher; import org.zwobble.mammoth.internal.styles.RunMatcher; +import org.zwobble.mammoth.internal.styles.StartsWithStringMatcher; import org.zwobble.mammoth.internal.styles.parsing.DocumentMatcherParser; import org.zwobble.mammoth.internal.styles.parsing.StyleMappingTokeniser; import org.zwobble.mammoth.internal.styles.parsing.TokenIterator; @@ -27,10 +29,19 @@ public class DocumentMatcherParsingTests { } @Test - public void readsParagraphWithStyleName() { + public void readsParagraphWithExactStyleName() { assertThat( parseParagraphMatcher("p[style-name='Heading 1']"), - deepEquals(ParagraphMatcher.styleName("Heading 1"))); + deepEquals(ParagraphMatcher.styleName(new EqualToStringMatcher("Heading 1"))) + ); + } + + @Test + public void readsParagraphWithStyleNamePrefix() { + assertThat( + parseParagraphMatcher("p[style-name^='Heading']"), + deepEquals(ParagraphMatcher.styleName(new StartsWithStringMatcher("Heading"))) + ); } @Test diff --git a/src/test/java/org/zwobble/mammoth/tests/styles/parsing/StyleMappingTokeniserTests.java b/src/test/java/org/zwobble/mammoth/tests/styles/parsing/StyleMappingTokeniserTests.java index e4e1f9b..f3147ba 100644 --- a/src/test/java/org/zwobble/mammoth/tests/styles/parsing/StyleMappingTokeniserTests.java +++ b/src/test/java/org/zwobble/mammoth/tests/styles/parsing/StyleMappingTokeniserTests.java @@ -81,6 +81,11 @@ public class StyleMappingTokeniserTests { } @Test + public void startsWithSymbolsAreTokenised() { + assertTokens("^=^=", isToken(TokenType.SYMBOL, "^="), isToken(TokenType.SYMBOL, "^=")); + } + + @Test public void openParensAreTokenised() { assertTokens("((", isToken(TokenType.SYMBOL, "("), isToken(TokenType.SYMBOL, "(")); } |
