diff options
author | Mathias <mathias@spray.io> | 2014-09-19 16:42:58 +0200 |
---|---|---|
committer | Mathias <mathias@spray.io> | 2014-09-19 16:42:58 +0200 |
commit | a6aaf5164ae8b9dda62327c56349de9d97e7721c (patch) | |
tree | 0d400ae00671f6e50fffb1d483488795118fa967 /src/test/scala/spray | |
parent | f33e846b95d8e9b20a8aeb4e2ca74fd2f34206fc (diff) | |
download | spray-json-a6aaf5164ae8b9dda62327c56349de9d97e7721c.tar.gz spray-json-a6aaf5164ae8b9dda62327c56349de9d97e7721c.tar.bz2 spray-json-a6aaf5164ae8b9dda62327c56349de9d97e7721c.zip |
Fix small problem in JsonParser error reporting
Diffstat (limited to 'src/test/scala/spray')
-rw-r--r-- | src/test/scala/spray/json/JsonParserSpec.scala | 18 |
1 files changed, 17 insertions, 1 deletions
diff --git a/src/test/scala/spray/json/JsonParserSpec.scala b/src/test/scala/spray/json/JsonParserSpec.scala index 608898f..4968eee 100644 --- a/src/test/scala/spray/json/JsonParserSpec.scala +++ b/src/test/scala/spray/json/JsonParserSpec.scala @@ -73,6 +73,22 @@ class JsonParserSpec extends Specification { _.asInstanceOf[JsObject].fields("questions").asInstanceOf[JsArray].elements.size } === List.fill(20)(100) } - } + "produce proper error messages" in { + def errorMessage(input: String) = + try JsonParser(input) catch { case e: JsonParser.ParsingException => e.getMessage } + + errorMessage("""[null, 1.23 {"key":true } ]""") === + """Unexpected character '{' at input index 12 (line 1, position 13), expected ']': + |[null, 1.23 {"key":true } ] + | ^ + |""".stripMargin + + errorMessage("""[null, 1.23, { key":true } ]""") === + """Unexpected character 'k' at input index 16 (line 1, position 17), expected '"': + |[null, 1.23, { key":true } ] + | ^ + |""".stripMargin + } + } }
\ No newline at end of file |