Merge branch 'aws-s3'
[rl3.git] / rl3 / json / json-writer-test.sls
blobedef68a570cfea789ef43df417784af5a63572c7
1 (library
2  (rl3 web rpc json test)
3   
4   (require "json-writer.scm"
5            (planet "text-ui.ss" ("schematics" "schemeunit.plt" 2 8))
6            (planet "test.ss" ("schematics" "schemeunit.plt" 2 8)))
7   
8   (define json-object-write
9     (test-suite
10      "JSON Object Writer"
11      (test-equal? "Empty Object" (json-write '()) "{}")
12      (test-equal? "Simple types" (json-write `(("a" . 1) ("b" . "c") ("d" . #t) ("e" . #f) ("g" . ,(void))))
13                   "{\"a\":1,\"b\":\"c\",\"d\":true,\"e\":false,\"g\":null}")
14      (test-equal? "Nested Json" (json-write `(,(cons "a" (list "a" "b" 3)) ,(cons "b" (list (cons "d" "ray")))))
15                   "{\"a\":[\"a\",\"b\",3],\"b\":{\"d\":\"ray\"}}")))
16   
17   (define json-array-write
18     (test-suite
19      "JSON Array Write"
20      (test-equal? "Empty Array" (json-write json-empty-array) "[]")
21      (test-equal? "Simple array types" (json-write `("a" 1 #t #f ,(void)))
22                   "[\"a\",1,true,false,null]")
23      (test-equal? "Nested array" (json-write `("a" ,(list 1 2 3)))
24                   "[\"a\",[1,2,3]]")))
25   
26   (test/text-ui 
27    (test-suite "JSON Writer Tests" 
28                json-object-write
29                json-array-write))
30   
31   )