diff options
Diffstat (limited to 'src/test/scala/spray/json/PrettyPrinterSpec.scala')
-rw-r--r-- | src/test/scala/spray/json/PrettyPrinterSpec.scala | 74 |
1 files changed, 37 insertions, 37 deletions
diff --git a/src/test/scala/spray/json/PrettyPrinterSpec.scala b/src/test/scala/spray/json/PrettyPrinterSpec.scala index 27137a8..6354ef0 100644 --- a/src/test/scala/spray/json/PrettyPrinterSpec.scala +++ b/src/test/scala/spray/json/PrettyPrinterSpec.scala @@ -16,49 +16,49 @@ package spray.json +import scala.collection.immutable.ListMap import org.specs2.mutable._ class PrettyPrinterSpec extends Specification { "The PrettyPrinter" should { "print a more complicated JsObject nicely aligned" in { - PrettyPrinter { - JsonParser { - """|{ - | "simpleKey" : "some value", - | "key with spaces": null, - | "zero": 0, - | "number": -1.2323424E-5, - | "Boolean yes":true, - | "Boolean no": false, - | "Unic\u00f8de" : "Long string with newline\nescape", - | "key with \"quotes\"" : "string", - | "sub object" : { - | "sub key": 26.5, - | "a": "b", - | "array": [1, 2, { "yes":1, "no":0 }, ["a", "b", null], false] - | } - |}""".stripMargin - } - } mustEqual { - """|{ - | "simpleKey": "some value", - | "key with spaces": null, - | "zero": 0, - | "number": -0.000012323424, - | "Boolean yes": true, - | "Boolean no": false, - | "Unic\u00f8de": "Long string with newline\nescape", - | "key with \"quotes\"": "string", - | "sub object": { - | "sub key": 26.5, - | "a": "b", - | "array": [1, 2, { - | "yes": 1, - | "no": 0 - | }, ["a", "b", null], false] - | } - |}""".stripMargin + val JsObject(fields) = JsonParser { + """{ + | "Boolean no": false, + | "Boolean yes":true, + | "Unic\u00f8de" : "Long string with newline\nescape", + | "key with \"quotes\"" : "string", + | "key with spaces": null, + | "number": -1.2323424E-5, + | "simpleKey" : "some value", + | "sub object" : { + | "sub key": 26.5, + | "a": "b", + | "array": [1, 2, { "yes":1, "no":0 }, ["a", "b", null], false] + | }, + | "zero": 0 + |}""".stripMargin + } + PrettyPrinter(JsObject(ListMap(fields.toSeq.sortBy(_._1):_*))) mustEqual { + """{ + | "Boolean no": false, + | "Boolean yes": true, + | "Unic\u00f8de": "Long string with newline\nescape", + | "key with \"quotes\"": "string", + | "key with spaces": null, + | "number": -0.000012323424, + | "simpleKey": "some value", + | "sub object": { + | "sub key": 26.5, + | "a": "b", + | "array": [1, 2, { + | "yes": 1, + | "no": 0 + | }, ["a", "b", null], false] + | }, + | "zero": 0 + |}""".stripMargin } } } |