Software /
code /
prosody
Annotate
tests/test_util_json.lua @ 7240:bf8aa0d1951c
util.xmppstream: Remove namespace tracking, it's broken as implemented
The code fails to handle namespaces on the initial opening tag (when 'stanza' is nil). Fixing this
seems not worth the effort for a feature that is not being used.
author | Matthew Wild <mwild1@gmail.com> |
---|---|
date | Sat, 05 Mar 2016 23:37:56 +0000 |
parent | 7233:71ca252d9f69 |
rev | line source |
---|---|
7233 | 1 |
2 function encode(encode, json) | |
3 local function test(f, j, e) | |
4 if e then | |
5 assert_equal(f(j), e); | |
6 end | |
7 assert_equal(f(j), f(json.decode(f(j)))); | |
8 end | |
9 test(encode, json.null, "null") | |
10 test(encode, {}, "{}") | |
11 test(encode, {a=1}); | |
12 test(encode, {a={1,2,3}}); | |
13 test(encode, {1}, "[1]"); | |
14 end | |
15 | |
16 function decode(decode) | |
17 local empty_array = decode("[]"); | |
18 assert_equal(type(empty_array), "table"); | |
19 assert_equal(#empty_array, 0); | |
20 assert_equal(next(empty_array), nil); | |
21 end |