diff options
author | Mathias <mathias@spray.cc> | 2011-05-06 11:11:37 +0200 |
---|---|---|
committer | Mathias <mathias@spray.cc> | 2011-05-06 11:11:37 +0200 |
commit | 0ce9cf8fce1dc475f3bb2a517e0a7698c9e0a5d9 (patch) | |
tree | 62de608642a30ec478411d27e94179ec64c5bd17 /src/test/scala/cc/spray/json/JsonParserSpec.scala | |
download | spray-json-0ce9cf8fce1dc475f3bb2a517e0a7698c9e0a5d9.tar.gz spray-json-0ce9cf8fce1dc475f3bb2a517e0a7698c9e0a5d9.tar.bz2 spray-json-0ce9cf8fce1dc475f3bb2a517e0a7698c9e0a5d9.zip |
Initial commit (split off from main spray codebase)
Diffstat (limited to 'src/test/scala/cc/spray/json/JsonParserSpec.scala')
-rw-r--r-- | src/test/scala/cc/spray/json/JsonParserSpec.scala | 45 |
1 files changed, 45 insertions, 0 deletions
diff --git a/src/test/scala/cc/spray/json/JsonParserSpec.scala b/src/test/scala/cc/spray/json/JsonParserSpec.scala new file mode 100644 index 0000000..dd61f94 --- /dev/null +++ b/src/test/scala/cc/spray/json/JsonParserSpec.scala @@ -0,0 +1,45 @@ +package cc.spray.json + +import org.specs.Specification + +class JsonParserSpec extends Specification { + + "The JsonParser" should { + "parse 'null' to JsNull" in { + JsonParser("null") mustEqual JsNull + } + "parse 'true' to JsTrue" in { + JsonParser("true") mustEqual JsTrue + } + "parse 'false' to JsFalse" in { + JsonParser("false") mustEqual JsFalse + } + "parse '0' to JsNumber" in { + JsonParser("0") mustEqual JsNumber(0) + } + "parse '1.23' to JsNumber" in { + JsonParser("1.23") mustEqual JsNumber(1.23) + } + "parse '-1E10' to JsNumber" in { + JsonParser("-1E10") mustEqual JsNumber("-1E+10") + } + "parse '12.34e-10' to JsNumber" in { + JsonParser("12.34e-10") mustEqual JsNumber("1.234E-9") + } + "parse \"xyz\" to JsString" in { + JsonParser("\"xyz\"") mustEqual JsString("xyz") + } + "parse escapes in a JsString" in { + JsonParser(""""\"\\/\b\f\n\r\t\u12Ab"""") mustEqual JsString("\"\\/\b\f\n\r\t\u12ab") + } + "properly parse a simple JsObject" in ( + JsonParser(""" { "key" :42, "key2": "value" }""") mustEqual + JsObject(JsField("key", 42), JsField("key2", "value")) + ) + "properly parse a simple JsArray" in ( + JsonParser("""[null, 1.23 ,{"key":true } ] """) mustEqual + JsArray(JsNull, JsNumber(1.23), JsObject(JsField("key", true))) + ) + } + +}
\ No newline at end of file |