aboutsummaryrefslogtreecommitdiff
path: root/src/test/java
diff options
context:
space:
mode:
authorMichael Williamson <mike@zwobble.org>2016-01-02 14:07:15 +0000
committerMichael Williamson <mike@zwobble.org>2016-01-02 14:07:15 +0000
commitba3bb715394a03ea2320cc3679881a0f1548ed99 (patch)
tree756ba8f6c1d12e54e473c737723001b30f5141a3 /src/test/java
parent26af8fca2838549a185345458bbdb24db8a62d9b (diff)
Parse w:t elements
Diffstat (limited to 'src/test/java')
-rw-r--r--src/test/java/org/zwobble/mammoth/tests/docx/BodyXmlTests.java28
1 files changed, 28 insertions, 0 deletions
diff --git a/src/test/java/org/zwobble/mammoth/tests/docx/BodyXmlTests.java b/src/test/java/org/zwobble/mammoth/tests/docx/BodyXmlTests.java
new file mode 100644
index 0000000..2b6323e
--- /dev/null
+++ b/src/test/java/org/zwobble/mammoth/tests/docx/BodyXmlTests.java
@@ -0,0 +1,28 @@
+package org.zwobble.mammoth.tests.docx;
+
+import com.google.common.collect.ImmutableList;
+import org.hamcrest.Matcher;
+import org.junit.Test;
+import org.zwobble.mammoth.documents.DocumentElement;
+import org.zwobble.mammoth.documents.TextElement;
+import org.zwobble.mammoth.xml.XmlElement;
+
+import static org.hamcrest.MatcherAssert.assertThat;
+import static org.hamcrest.Matchers.*;
+import static org.zwobble.mammoth.docx.BodyXml.readBodyXmlElement;
+import static org.zwobble.mammoth.xml.XmlNodes.element;
+import static org.zwobble.mammoth.xml.XmlNodes.text;
+
+public class BodyXmlTests {
+ @Test
+ public void textFromTextElementIsRead() {
+ XmlElement element = element("w:t", ImmutableList.of(text("Hello!")));
+ assertThat(readBodyXmlElement(element), isTextElement("Hello!"));
+ }
+
+ private Matcher<DocumentElement> isTextElement(String value) {
+ return allOf(
+ instanceOf(TextElement.class),
+ hasProperty("value", equalTo(value)));
+ }
+}