1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
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)),
'["", "", ""]',
'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'
);
?>
|