From a6aaf5164ae8b9dda62327c56349de9d97e7721c Mon Sep 17 00:00:00 2001 From: Mathias Date: Fri, 19 Sep 2014 16:42:58 +0200 Subject: Fix small problem in JsonParser error reporting --- src/test/scala/spray/json/JsonParserSpec.scala | 18 +++++++++++++++++- 1 file changed, 17 insertions(+), 1 deletion(-) (limited to 'src/test/scala/spray/json/JsonParserSpec.scala') 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 -- cgit v1.2.3