Skip to content

Commit 98fbd71

Browse files
committed
data.test-json : add round-trip tests
1 parent 75e7db7 commit 98fbd71

File tree

1 file changed

+9
-0
lines changed

1 file changed

+9
-0
lines changed

tests/pixie/tests/data/test-json.pxi

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,3 +17,12 @@
1717
:non-empty {:vector [1 2 3], :list '(1 2 3), :seq (take 3 (range))}}
1818
:maps {:empty {}, :non-empty {:this "is covered, right? ;)"}}})
1919
"{ \"strings\": { \"b\": \"b\", \"c\": \"\", \"a\": \"a\", \"d\": \"d\" }, \"maps\": { \"non-empty\": { \"this\": \"is covered, right? ;)\" }, \"empty\": {} }, \"lists\": { \"non-empty\": { \"seq\": [ 0, 1, 2 ], \"list\": [ 1, 2, 3 ], \"vector\": [ 1, 2, 3 ] }, \"empty\": { \"seq\": [], \"list\": [], \"vector\": [] } }, \"numbers\": { \"one\": 1, \"two\": 2.000000, \"three\": 3 } }"))
20+
21+
(deftest test-round-trip
22+
(let [data {"foo" 1, "bar" [2 3]}] ; won't work with keywords because the parser doesn't keywordise them (yet)
23+
(assert= (-> data json/write-string json/read-string)
24+
data))
25+
26+
(let [string "{ \"foo\": [ 1, 2, 3 ] }"]
27+
(assert= (-> string json/read-string json/write-string)
28+
string)))

0 commit comments

Comments
 (0)