diff options
Diffstat (limited to 'ext/json/tests')
| -rw-r--r-- | ext/json/tests/001.phpt | 12 | ||||
| -rw-r--r-- | ext/json/tests/002.phpt | 2 | ||||
| -rw-r--r-- | ext/json/tests/bug40503.phpt | 21 | ||||
| -rw-r--r-- | ext/json/tests/bug41034.phpt | 12 | ||||
| -rw-r--r-- | ext/json/tests/bug41067.phpt | 23 | ||||
| -rw-r--r-- | ext/json/tests/fail001.phpt | 6 | ||||
| -rw-r--r-- | ext/json/tests/pass001.1.phpt | 40 | ||||
| -rw-r--r-- | ext/json/tests/pass001.phpt | 2 |
8 files changed, 89 insertions, 29 deletions
diff --git a/ext/json/tests/001.phpt b/ext/json/tests/001.phpt index 095aedf63..4c9f918b4 100644 --- a/ext/json/tests/001.phpt +++ b/ext/json/tests/001.phpt @@ -31,12 +31,12 @@ NULL NULL NULL NULL -NULL -NULL -NULL -NULL -NULL -NULL +string(1) "." +string(1) "." +string(3) "<?>" +string(1) ";" +string(12) "руссиш" +string(4) "blah" NULL object(stdClass)#1 (1) { ["test"]=> diff --git a/ext/json/tests/002.phpt b/ext/json/tests/002.phpt index 5bc29bc5b..87f57421f 100644 --- a/ext/json/tests/002.phpt +++ b/ext/json/tests/002.phpt @@ -21,7 +21,7 @@ echo "Done\n"; string(2) """" string(4) "null" string(4) "true" -string(2) "{}" +string(7) "{"":""}" string(5) "[[1]]" string(1) "1" string(38) ""\u0440\u0443\u0441\u0441\u0438\u0448"" diff --git a/ext/json/tests/bug40503.phpt b/ext/json/tests/bug40503.phpt new file mode 100644 index 000000000..48f18a4e0 --- /dev/null +++ b/ext/json/tests/bug40503.phpt @@ -0,0 +1,21 @@ +--TEST-- +Bug #40503 (json_encode() value corruption on 32bit systems with overflown values) +--INI-- +precision=14 +--SKIPIF-- +<?php if (!extension_loaded("json")) print "skip"; ?> +--FILE-- +<?php +function show_eq($x,$y) { + echo "$x ". ($x==$y ? "==" : "!=") ." $y\n"; +} + +$value = 0x7FFFFFFF; #2147483647; +show_eq("$value", json_encode($value)); +$value++; +show_eq("$value", json_encode($value)); + +?> +--EXPECT-- +2147483647 == 2147483647 +2147483648 == 2147483648 diff --git a/ext/json/tests/bug41034.phpt b/ext/json/tests/bug41034.phpt new file mode 100644 index 000000000..cc7704122 --- /dev/null +++ b/ext/json/tests/bug41034.phpt @@ -0,0 +1,12 @@ +--TEST-- +Bug #41034 (json_encode() ignores null byte started keys in arrays) +--SKIPIF-- +<?php if (!extension_loaded("json")) print "skip"; ?> +--FILE-- +<?php +echo json_encode(array(0,"\0ab"=>1,"\0null-prefixed value")); +echo "\nDone\n"; +?> +--EXPECT-- +{"0":0,"\u0000ab":1,"1":"\u0000null-prefixed value"} +Done diff --git a/ext/json/tests/bug41067.phpt b/ext/json/tests/bug41067.phpt new file mode 100644 index 000000000..b20e6e1b5 --- /dev/null +++ b/ext/json/tests/bug41067.phpt @@ -0,0 +1,23 @@ +--TEST-- +Bug #41067 (json_encode() problem with UTF-16 input) +--SKIPIF-- +<?php if (!extension_loaded("json")) print "skip"; ?> +--FILE-- +<?php +$single_barline = "\360\235\204\200"; +$array = array($single_barline); +print bin2hex($single_barline) . "\n"; +// print $single_barline . "\n\n"; +$json = json_encode($array); +print $json . "\n\n"; +$json_decoded = json_decode($json, true); +// print $json_decoded[0] . "\n"; +print bin2hex($json_decoded[0]) . "\n"; +print "END\n"; +?> +--EXPECT-- +f09d8480 +["\ud834\udd00"] + +f09d8480 +END diff --git a/ext/json/tests/fail001.phpt b/ext/json/tests/fail001.phpt index f0e0afa38..2f0c41b90 100644 --- a/ext/json/tests/fail001.phpt +++ b/ext/json/tests/fail001.phpt @@ -45,9 +45,9 @@ foreach ($tests as $test) --EXPECT-- Testing: "A JSON payload should be an object or array, not a string." AS OBJECT -NULL +string(58) "A JSON payload should be an object or array, not a string." AS ARRAY -NULL +string(58) "A JSON payload should be an object or array, not a string." Testing: ["Unclosed array" AS OBJECT NULL @@ -162,4 +162,4 @@ Testing: ['single quote'] AS OBJECT NULL AS ARRAY -NULL +NULL
\ No newline at end of file diff --git a/ext/json/tests/pass001.1.phpt b/ext/json/tests/pass001.1.phpt index cdc68ab96..45eb5739a 100644 --- a/ext/json/tests/pass001.1.phpt +++ b/ext/json/tests/pass001.1.phpt @@ -1,5 +1,7 @@ --TEST-- JSON (http://www.crockford.com/JSON/JSON_checker/test/pass1.json) +--INI-- +precision=14 --SKIPIF-- <?php if (!extension_loaded('json')) die('skip: json extension not available'); @@ -101,7 +103,7 @@ $arr = json_decode($arr_enc, true); var_dump($arr); ?> ---EXPECT-- +--EXPECTF-- Testing: [ "JSON Test Pattern pass1", @@ -170,7 +172,7 @@ array(14) { [0]=> string(23) "JSON Test Pattern pass1" [1]=> - object(stdClass)#1 (1) { + object(stdClass)#%d (1) { ["object with 1 member"]=> array(1) { [0]=> @@ -178,7 +180,7 @@ array(14) { } } [2]=> - object(stdClass)#2 (0) { + object(stdClass)#%d (0) { } [3]=> array(0) { @@ -192,7 +194,7 @@ array(14) { [7]=> NULL [8]=> - object(stdClass)#3 (36) { + object(stdClass)#%d (36) { ["integer"]=> int(1234567890) ["real"]=> @@ -204,7 +206,7 @@ array(14) { ["_empty_"]=> float(INF) ["E no ."]=> - float(4.0E+12) + float(4000000000000) ["zero"]=> int(0) ["one"]=> @@ -246,14 +248,14 @@ array(14) { array(0) { } ["object"]=> - object(stdClass)#4 (0) { + object(stdClass)#%d (0) { } ["123"]=> - object(stdClass)#5 (1) { + object(stdClass)#%d (1) { ["456"]=> - object(stdClass)#6 (1) { + object(stdClass)#%d (1) { ["abc"]=> - object(stdClass)#7 (3) { + object(stdClass)#%d (3) { ["789"]=> string(3) "def" ["012"]=> @@ -383,7 +385,7 @@ array(14) { ["_empty_"]=> float(INF) ["E no ."]=> - float(4.0E+12) + float(4000000000000) ["zero"]=> int(0) ["one"]=> @@ -532,7 +534,7 @@ array(14) { [0]=> string(23) "JSON Test Pattern pass1" [1]=> - object(stdClass)#8 (1) { + object(stdClass)#%d (1) { ["object with 1 member"]=> array(1) { [0]=> @@ -540,7 +542,7 @@ array(14) { } } [2]=> - object(stdClass)#9 (0) { + object(stdClass)#%d (0) { } [3]=> array(0) { @@ -554,7 +556,7 @@ array(14) { [7]=> NULL [8]=> - object(stdClass)#10 (36) { + object(stdClass)#%d (36) { ["integer"]=> int(1234567890) ["real"]=> @@ -566,7 +568,7 @@ array(14) { ["_empty_"]=> int(0) ["E no ."]=> - float(4.0E+12) + float(4000000000000) ["zero"]=> int(0) ["one"]=> @@ -608,14 +610,14 @@ array(14) { array(0) { } ["object"]=> - object(stdClass)#11 (0) { + object(stdClass)#%d (0) { } ["123"]=> - object(stdClass)#12 (1) { + object(stdClass)#%d (1) { ["456"]=> - object(stdClass)#13 (1) { + object(stdClass)#%d (1) { ["abc"]=> - object(stdClass)#14 (3) { + object(stdClass)#%d (3) { ["789"]=> string(3) "def" ["012"]=> @@ -745,7 +747,7 @@ array(14) { ["_empty_"]=> int(0) ["E no ."]=> - float(4.0E+12) + float(4000000000000) ["zero"]=> int(0) ["one"]=> diff --git a/ext/json/tests/pass001.phpt b/ext/json/tests/pass001.phpt index 029e2f9ff..1decd546d 100644 --- a/ext/json/tests/pass001.phpt +++ b/ext/json/tests/pass001.phpt @@ -1,5 +1,7 @@ --TEST-- JSON (http://www.crockford.com/JSON/JSON_checker/test/pass1.json) +--INI-- +precision=14 --SKIPIF-- <?php if (!extension_loaded('json')) die('skip: json extension not available'); |
