import PlakCore import Testing @Suite struct JSONFormatterTests { @Test("pretty-printing keeps the key order and the spelling of numbers and strings") func keepsOrder() { let pretty = JSONFormatter.pretty(#"{"z":1.50,"a":[2e3,-0.1],"m":{"q":"a, b: \"c\" {"}}"#) #expect(pretty == """ { "z": 1.50, "a": [ 2e3, -0.1 ], "m": { "q": "a, b: \\"c\\" {" } } """) } @Test("empty objects and arrays stay on one line, and spaces outside strings go") func empty() { #expect(JSONFormatter.pretty(#"[ {}, [ ], "a b" ]"#) == "[\n {},\n [],\n \"a b\"\n]") } }