diff options
author | Christian A. Weber | 2019-05-13 17:15:46 +0200 |
---|---|---|
committer | Christian A. Weber | 2019-05-13 17:15:46 +0200 |
commit | 050af2a7605376cdfd7f513e09929299eab7a69c (patch) | |
tree | 3f807bac64a2817e5c9cfa6db665edf955e42c19 /test | |
parent | 89b34c8bdaf06b10268cab19796cd94684442124 (diff) | |
download | itools-050af2a7605376cdfd7f513e09929299eab7a69c.tar.gz itools-050af2a7605376cdfd7f513e09929299eab7a69c.tar.bz2 itools-050af2a7605376cdfd7f513e09929299eab7a69c.zip |
itjs::serialize() preserves data types (string, int, bool, null)
Diffstat (limited to 'test')
-rwxr-xr-x | test/itjs.t | 32 |
1 files changed, 17 insertions, 15 deletions
diff --git a/test/itjs.t b/test/itjs.t index 695ccd8..777b1ec 100755 --- a/test/itjs.t +++ b/test/itjs.t @@ -3,6 +3,8 @@ # Tests for itjs.class, currently only itjs::serialize() +$GLOBALS['ULTRASERVERTYPE'] = "live"; # don't prettyprint json + $_GET['aa'] = 1; is( @@ -19,48 +21,48 @@ is( is( itjs::serialize(array(0, "0")), - '[0, 0]', - 'number 0' + '[0,"0"]', + 'number strings stay strings' ); is( itjs::serialize(array(null, "", false)), - '["", "", false]', + '[null,"",false]', 'null, empty string, false' ); is( - itjs::serialize(array(42, "42", 42.5, "042")), - '[42, 42, "42.5", "042"]', - 'numbers' -); - -is( itjs::serialize(array('foo' => "bar", "qux", 42 => "quux")), - "{foo:\"bar\",\n'0':\"qux\",\n'42':\"quux\"}", + '{"foo":"bar","0":"qux","42":"quux"}', 'key-value pairs' ); is( itjs::serialize(array('foo' => array('bar' => array("qux", 42)))), - '{foo:{bar:["qux", 42]}}', + '{"foo":{"bar":["qux",42]}}', 'nested arrays' ); is( itjs::serialize(array('import' => array('function' => array(true, 42)))), - '{\'import\':{\'function\':[true, 42]}}', + '{"import":{"function":[true,42]}}', 'keywords' ); is( - itjs::serialize(array("foo'foo" => "bar")), - "{'foo\'foo':\"bar\"}", + itjs::serialize(array('foo"foo' => "bar")), + '{"foo\"foo":"bar"}', "quote ' in keys" ); is( + itjs::serialize("</script>"), + '"<\\/script>"', + "quote slashes" +); + +is( itjs::serialize("hellö"), '"hellö"', - "string" + "don't encode utf8" ); |