diff options
author | Konrad `ktoso` Malawski <ktoso@project13.pl> | 2017-10-24 14:04:11 +0900 |
---|---|---|
committer | GitHub <noreply@github.com> | 2017-10-24 14:04:11 +0900 |
commit | 36959ef06fa632945ff01aaa2cc558b6cc8365d7 (patch) | |
tree | a774dc1573e18cbc6205922ac935876b5c7741c7 /src/test/scala | |
parent | 11028dd4b2aa6a35a082531609c72d716f628605 (diff) | |
parent | dd62833aca49ee5aa6a1dbb6b6d274d44c7b52dc (diff) | |
download | spray-json-36959ef06fa632945ff01aaa2cc558b6cc8365d7.tar.gz spray-json-36959ef06fa632945ff01aaa2cc558b6cc8365d7.tar.bz2 spray-json-36959ef06fa632945ff01aaa2cc558b6cc8365d7.zip |
Merge pull request #164 from mattinbits/master
Added method for sorted print
Diffstat (limited to 'src/test/scala')
-rw-r--r-- | src/test/scala/spray/json/SortedPrinterSpec.scala | 50 |
1 files changed, 50 insertions, 0 deletions
diff --git a/src/test/scala/spray/json/SortedPrinterSpec.scala b/src/test/scala/spray/json/SortedPrinterSpec.scala new file mode 100644 index 0000000..0ea1045 --- /dev/null +++ b/src/test/scala/spray/json/SortedPrinterSpec.scala @@ -0,0 +1,50 @@ +package spray.json + +import scala.collection.immutable.ListMap +import org.specs2.mutable._ + +class SortedPrinterSpec extends Specification { + + "The SortedPrinter" should { + "print a more complicated JsObject nicely aligned with fields sorted" in { + val obj = JsonParser { + """{ + | "Unic\u00f8de" : "Long string with newline\nescape", + | "Boolean no": false, + | "number": -1.2323424E-5, + | "key with \"quotes\"" : "string", + | "key with spaces": null, + | "simpleKey" : "some value", + | "zero": 0, + | "sub object" : { + | "sub key": 26.5, + | "a": "b", + | "array": [1, 2, { "yes":1, "no":0 }, ["a", "b", null], false] + | }, + | "Boolean yes":true + |}""".stripMargin + } + SortedPrinter(obj) 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": { + | "a": "b", + | "array": [1, 2, { + | "no": 0, + | "yes": 1 + | }, ["a", "b", null], false], + | "sub key": 26.5 + | }, + | "zero": 0 + |}""".stripMargin + } + } + } + +} |