diff options
Diffstat (limited to 'javaparser-testing/src/test/java/com/github/javaparser/ProblemTest.java')
-rw-r--r-- | javaparser-testing/src/test/java/com/github/javaparser/ProblemTest.java | 32 |
1 files changed, 32 insertions, 0 deletions
diff --git a/javaparser-testing/src/test/java/com/github/javaparser/ProblemTest.java b/javaparser-testing/src/test/java/com/github/javaparser/ProblemTest.java new file mode 100644 index 000000000..0654344ba --- /dev/null +++ b/javaparser-testing/src/test/java/com/github/javaparser/ProblemTest.java @@ -0,0 +1,32 @@ +package com.github.javaparser; + +import org.junit.Test; + +import static com.github.javaparser.Range.range; +import static com.github.javaparser.utils.TestUtils.assertInstanceOf; +import static org.junit.Assert.assertEquals; + +public class ProblemTest { + @Test + public void testSimpleGetters() { + Problem problem = new Problem("Parse error", TokenRange.INVALID, new Exception()); + + assertEquals(TokenRange.INVALID, problem.getLocation().get()); + assertEquals("Parse error", problem.getMessage()); + assertInstanceOf(Exception.class, problem.getCause().get()); + } + + @Test + public void testVerboseMessage() { + Problem problem = new Problem("Parse error", TokenRange.INVALID, null); + + assertEquals("(line ?,col ?) Parse error", problem.getVerboseMessage()); + } + + @Test + public void testVerboseMessageWithoutLocation() { + Problem problem = new Problem("Parse error", null, null); + + assertEquals("Parse error", problem.getVerboseMessage()); + } +}
\ No newline at end of file |