]> granicus.if.org Git - php/commitdiff
MFB: split test
authorAntony Dovgal <tony2001@php.net>
Sun, 9 Sep 2007 22:47:23 +0000 (22:47 +0000)
committerAntony Dovgal <tony2001@php.net>
Sun, 9 Sep 2007 22:47:23 +0000 (22:47 +0000)
ext/standard/tests/strings/addcslashes_001.phpt [new file with mode: 0644]
ext/standard/tests/strings/addcslashes_002.phpt [new file with mode: 0644]
ext/standard/tests/strings/addcslashes_003.phpt [new file with mode: 0644]
ext/standard/tests/strings/addcslashes_004.phpt [new file with mode: 0644]

diff --git a/ext/standard/tests/strings/addcslashes_001.phpt b/ext/standard/tests/strings/addcslashes_001.phpt
new file mode 100644 (file)
index 0000000..28a30aa
Binary files /dev/null and b/ext/standard/tests/strings/addcslashes_001.phpt differ
diff --git a/ext/standard/tests/strings/addcslashes_002.phpt b/ext/standard/tests/strings/addcslashes_002.phpt
new file mode 100644 (file)
index 0000000..33baa84
--- /dev/null
@@ -0,0 +1,33 @@
+--TEST--
+Test addcslashes() function (variation 2)
+--INI--
+precision=14
+--FILE--
+<?php
+
+$string = b"goodyear12345NULL\0truefalse\a\v\f\b\n\r\t";
+/* charlist "\0..\37" would escape all characters with ASCII code between 0 and 31 */
+echo "\n*** Testing addcslashes() with ASCII code between 0 and 31 ***\n";
+var_dump( addcslashes($string, b"\0..\37") );
+
+/* Checking OBJECTS type */
+echo "\n*** Testing addcslashes() with objects ***\n";
+class string1
+{
+  public function __toString() {
+    return "Object";
+  }
+}
+$obj = new string1;
+var_dump( addcslashes((binary)$obj, b"b") );
+
+echo "Done\n"; 
+
+?>
+--EXPECTF--
+*** Testing addcslashes() with ASCII code between 0 and 31 ***
+string(44) "goodyear12345NULL\000truefalse\a\v\f\b\n\r\t"
+
+*** Testing addcslashes() with objects ***
+string(7) "O\bject"
+Done
diff --git a/ext/standard/tests/strings/addcslashes_003.phpt b/ext/standard/tests/strings/addcslashes_003.phpt
new file mode 100644 (file)
index 0000000..10b1e99
Binary files /dev/null and b/ext/standard/tests/strings/addcslashes_003.phpt differ
diff --git a/ext/standard/tests/strings/addcslashes_004.phpt b/ext/standard/tests/strings/addcslashes_004.phpt
new file mode 100644 (file)
index 0000000..ba553a2
--- /dev/null
@@ -0,0 +1,47 @@
+--TEST--
+Test addcslashes() function (errors)
+--INI--
+precision=14
+--FILE--
+<?php
+
+echo "\n*** Testing error conditions ***\n";
+/* zero argument */
+var_dump( addcslashes() );
+
+/* unexpected arguments */
+var_dump( addcslashes(b"foo[]") );
+var_dump( addcslashes("foo", "foo") );
+var_dump( addcslashes(b'foo[]', b"o", b"foo") );
+
+echo "Done\n"; 
+
+?>
+--EXPECTF--
+*** Testing error conditions ***
+
+Warning: addcslashes() expects exactly 2 parameters, 0 given in %s on line %d
+NULL
+
+Warning: addcslashes() expects exactly 2 parameters, 1 given in %s on line %d
+NULL
+string(6) "\f\o\o"
+
+Warning: addcslashes() expects exactly 2 parameters, 3 given in %s on line %d
+NULL
+Done
+--UEXPECTF--
+*** Testing error conditions ***
+
+Warning: addcslashes() expects exactly 2 parameters, 0 given in %s on line %d
+NULL
+
+Warning: addcslashes() expects exactly 2 parameters, 1 given in %s on line %d
+NULL
+
+Warning: addcslashes() expects parameter 1 to be strictly a binary string, Unicode string given in %s on line %d
+NULL
+
+Warning: addcslashes() expects exactly 2 parameters, 3 given in %s on line %d
+NULL
+Done