Split tests.
authorRemi Collet <remi@php.net>
Thu, 5 Mar 2015 13:41:37 +0000 (14:41 +0100)
committerRemi Collet <remi@php.net>
Thu, 5 Mar 2015 13:41:37 +0000 (14:41 +0100)
001: most types, return as array
002: bigint return as float member of an objet (32 bits only)
003: bigint return as string member of an objet (32 bits only)
004: bigint return as integer member of an objet (64 bits only)

The bigint value used is >32bits but <64bits which doesn't exists
in real world (to avoid issue with jsonc used in free distro)

.gitignore
package.xml
tests/001.phpt
tests/002.phpt
tests/003.phpt [new file with mode: 0644]
tests/004.phpt [new file with mode: 0644]

index 811bba1d8654380f5562696c7ec63fd7723b18fe..6c8f7d69ceb8be6d3b38d04053011744eb12f206 100644 (file)
@@ -34,3 +34,5 @@ tests/*/*.exp
 tests/*/*.log
 tests/*/*.sh
 php_json_post.o
+json_post-*.tgz
+tmp-php.ini
index 36e12d79bfb536df9637074cb441f58249c4be57..4b6ed0428847210781e90a304752b7a7d3c1da80 100644 (file)
@@ -49,6 +49,8 @@ This extension does not provide any constants, functions or classes.
    <dir name="tests">
      <file role="test" name="001.phpt"/>
      <file role="test" name="002.phpt"/>
+     <file role="test" name="003.phpt"/>
+     <file role="test" name="004.phpt"/>
    </dir>
   </dir>
  </contents>
index b3e5775c1a5329a3eeed4db7914a5be16c51c680..d4ee29f2472c401c68c3be9be226fb9c9d1713ff 100644 (file)
@@ -1,8 +1,8 @@
 --TEST--
-json_post
+json_post with most common types, as array
 --SKIPIF--
 <?php
-extension_loaded("json_post")) or die("skip need json_post support\n");
+extension_loaded("json_post") or die("skip need json_post support\n");
 ?>
 --POST_RAW--
 Content-type: text/json
@@ -11,7 +11,6 @@ Content-type: text/json
        "null": null,
        "bool": true,
        "int": 123,
-       "bigint": 36893488147419103232,
        "float": 123.123,
        "string": "Hello World",
        "array": [1,2,3],
@@ -22,18 +21,17 @@ Content-type: text/json
 }
 --FILE--
 <?php
-var_dump($_POST, json_last_error_msg());
+var_dump($_POST, json_last_error());
 ?>
+Done
 --EXPECTF--
-array(8) {
+array(7) {
   ["null"]=>
   NULL
   ["bool"]=>
   bool(true)
   ["int"]=>
   int(123)
-  ["bigint"]=>
-  float(3.689%dE+19)
   ["float"]=>
   float(123.123)
   ["string"]=>
@@ -62,4 +60,5 @@ array(8) {
     string(11) "Österreich"
   }
 }
-string(8) "No error"
\ No newline at end of file
+int(0)
+Done
\ No newline at end of file
index 643f56098491b11041169d4ad248cfba7007c54f..18b2ce7b4db8e34021d36a4b9ceb07f83d755005 100644 (file)
@@ -1,67 +1,27 @@
 --TEST--
-json_post
+json_post with > 32bits integer as float on 32bits
 --SKIPIF--
 <?php
-extension_loaded("json_post")) or die("skip need json_post support\n");
+extension_loaded("json_post") or die("skip need json_post support\n");
+if (PHP_INT_SIZE != 4) die("skip this test is for 32bits platform only");
 ?>
 --INI--
-json_post.flags=2;JSON_BIGINT_AS_STRING
+json_post.flags=0
 --POST_RAW--
 Content-type: text/json
 
 {
-       "null": null,
-       "bool": true,
-       "int": 123,
-       "bigint": 36893488147419103232,
-       "float": 123.123,
-       "string": "Hello World",
-       "array": [1,2,3],
-       "object": {
-               "array": [1,2,3],
-               "unicode": "\u00D6sterreich"
-       }
+       "bigint": 12345678901234
 }
 --FILE--
 <?php
-var_dump($_POST, json_last_error_msg());
+var_dump($_POST, json_last_error());
 ?>
+Done
 --EXPECTF--
-object(stdClass)#%d (8) {
-  ["null"]=>
-  NULL
-  ["bool"]=>
-  bool(true)
-  ["int"]=>
-  int(123)
+object(stdClass)#%d (1) {
   ["bigint"]=>
-  string(20) "36893488147419103232"
-  ["float"]=>
-  float(123.123)
-  ["string"]=>
-  string(11) "Hello World"
-  ["array"]=>
-  array(3) {
-    [0]=>
-    int(1)
-    [1]=>
-    int(2)
-    [2]=>
-    int(3)
-  }
-  ["object"]=>
-  object(stdClass)#%d (2) {
-    ["array"]=>
-    array(3) {
-      [0]=>
-      int(1)
-      [1]=>
-      int(2)
-      [2]=>
-      int(3)
-    }
-    ["unicode"]=>
-    string(11) "Österreich"
-  }
+  float(12345678901234)
 }
-string(8) "No error"
\ No newline at end of file
+int(0)
+Done
\ No newline at end of file
diff --git a/tests/003.phpt b/tests/003.phpt
new file mode 100644 (file)
index 0000000..9ee1aa6
--- /dev/null
@@ -0,0 +1,27 @@
+--TEST--
+json_post with > 32bits integer as float on 32bits
+--SKIPIF--
+<?php
+extension_loaded("json_post") or die("skip need json_post support\n");
+if (PHP_INT_SIZE != 4) die("skip this test is for 32bits platform only");
+?>
+--INI--
+json_post.flags=2;JSON_BIGINT_AS_STRING
+--POST_RAW--
+Content-type: text/json
+
+{
+       "bigint": 12345678901234
+}
+--FILE--
+<?php
+var_dump($_POST, json_last_error());
+?>
+Done
+--EXPECTF--
+object(stdClass)#%d (1) {
+  ["bigint"]=>
+  string(14) "12345678901234"
+}
+int(0)
+Done
\ No newline at end of file
diff --git a/tests/004.phpt b/tests/004.phpt
new file mode 100644 (file)
index 0000000..2b69665
--- /dev/null
@@ -0,0 +1,27 @@
+--TEST--
+json_post with > 32bits integer as float on 64bits
+--SKIPIF--
+<?php
+extension_loaded("json_post") or die("skip need json_post support\n");
+if (PHP_INT_SIZE != 8) die("skip this test is for 64bits platform only");
+?>
+--INI--
+json_post.flags=0
+--POST_RAW--
+Content-type: text/json
+
+{
+       "bigint": 12345678901234
+}
+--FILE--
+<?php
+var_dump($_POST, json_last_error());
+?>
+Done
+--EXPECTF--
+object(stdClass)#%d (1) {
+  ["bigint"]=>
+  int(12345678901234)
+}
+int(0)
+Done
\ No newline at end of file