diff options
author | Christian Schneider | 2007-10-11 00:39:30 +0000 |
---|---|---|
committer | Christian Schneider | 2007-10-11 00:39:30 +0000 |
commit | 35fe33f7364329dacf415c950bff01b6de9ef88e (patch) | |
tree | b0e6b018b50038ca20266723c53750268f508df5 /tests/itjs.t | |
parent | 1f95711ff3e9697cd85a54545ab42e5fd3611317 (diff) | |
download | itools-35fe33f7364329dacf415c950bff01b6de9ef88e.tar.gz itools-35fe33f7364329dacf415c950bff01b6de9ef88e.tar.bz2 itools-35fe33f7364329dacf415c950bff01b6de9ef88e.zip |
Populated release branch
Diffstat (limited to 'tests/itjs.t')
-rwxr-xr-x | tests/itjs.t | 44 |
1 files changed, 44 insertions, 0 deletions
diff --git a/tests/itjs.t b/tests/itjs.t new file mode 100755 index 0000000..4b4b0c8 --- /dev/null +++ b/tests/itjs.t @@ -0,0 +1,44 @@ +#!/www/server/bin/php -qC +<?php + +# Tests for itjs.class, currently only itjs::serialize() + +require 'searchlib/search_test.class'; + +is( + itjs::serialize(array()), + '[]', + 'empty array' +); + +is( + itjs::serialize(array(0, "0")), + '[0, 0]', + 'number 0' +); + +is( + itjs::serialize(array(null, "", false)), + '["", "", 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\"}", + 'key-value pairs' +); + +is( + itjs::serialize(array('foo' => array('bar' => array("qux", 42)))), + '{foo:{bar:["qux", 42]}}', + 'nested arrays' +); + +?> |