1 (module json-parser-test mzscheme
3 (require "json-parser.scm"
4 (planet "text-ui.ss" ("schematics" "schemeunit.plt" 2 8))
5 (planet "test.ss" ("schematics" "schemeunit.plt" 2 8)))
7 (define json-object-parse
9 "JSON Parser Object Test"
10 (test-equal? "Empty Object" (json-parse "{}") '())
11 (test-equal? "Simple Types" (json-parse "{\"a\":123, \"b\":\"c\", \"d\":true,\"e\":false,\"f\":null}")
12 `(("a" . 123) ("b" . "c") ("d" . #t) ("e" . #f) ("f" . ,(void))))
13 (test-equal? "Nested object" (json-parse "{\"a\": {\"b\":123}}")
14 (list (cons "a" (list (cons "b" 123)))))))
16 (define json-array-parse
18 "JSON Parser Array Test"
19 (test-equal? "Empty Array" (json-parse "[]") '())
20 (test-equal? "Simple Types" (json-parse "[\"a\",123, true, false, null]")
21 `("a" 123 #t #f ,(void)))))
23 (define json-nested-parse
26 (test-equal? "Nested Object" (json-parse "{\"a\":{\"b\":{\"d\": 123}}}")
27 (list (list "a" (cons "b" (list (cons "d" 123))))))
28 (test-equal? "Nested Array" (json-parse "{\"a\" : [123, \"b\"]}")
29 (list (cons "a" (list 123 "b"))))))
32 (test-suite "JSON Parser Tests"