From 2cbb4869f34563ea686a3275ba7b2afce99efa14 Mon Sep 17 00:00:00 2001 From: Michael Williamson Date: Sat, 30 Apr 2016 16:02:45 +0100 Subject: Use specialised exception type for parse errors --- src/test/java/org/zwobble/mammoth/tests/MammothTests.java | 12 ++++++++++++ 1 file changed, 12 insertions(+) (limited to 'src/test/java/org/zwobble') diff --git a/src/test/java/org/zwobble/mammoth/tests/MammothTests.java b/src/test/java/org/zwobble/mammoth/tests/MammothTests.java index b2661b0..4f4c9fd 100644 --- a/src/test/java/org/zwobble/mammoth/tests/MammothTests.java +++ b/src/test/java/org/zwobble/mammoth/tests/MammothTests.java @@ -3,6 +3,7 @@ package org.zwobble.mammoth.tests; import org.junit.Test; import org.zwobble.mammoth.DocumentConverter; import org.zwobble.mammoth.Result; +import org.zwobble.mammoth.internal.styles.parsing.ParseException; import java.io.File; import java.io.IOException; @@ -15,6 +16,7 @@ import static org.junit.Assert.assertThat; import static org.zwobble.mammoth.internal.util.Lists.list; import static org.zwobble.mammoth.tests.ResultMatchers.isResult; import static org.zwobble.mammoth.tests.ResultMatchers.isSuccess; +import static org.zwobble.mammoth.tests.util.MammothAsserts.assertThrows; public class MammothTests { @Test @@ -189,6 +191,16 @@ public class MammothTests { isSuccess("

The Sunset Tree

")); } + @Test + public void errorIsRaisedIfStyleMapCannotBeParsed() throws IOException { + RuntimeException exception = assertThrows( + ParseException.class, + () -> new DocumentConverter().addStyleMap("p =>\np[style-name=] =>")); + assertThat( + exception.getMessage(), + equalTo("expected token of type STRING but was of type CLOSE_SQUARE_BRACKET")); + } + @Test public void canDisableDefaultStyleMap() throws IOException { assertThat( -- cgit v1.2.3