com php-src: exclude the platform diff case from the test: ext/standard/tests/strings/basename_invalid_path.phpt e
xt/standard/tests/strings/basename_invalid_path_win.php t ext/standard/tests/strings/basename_variation.phpt
| From: | Anatol Belski | Date: | Sun, 26 Jul 2015 18:54:27 +0000 |
| Subject: | com php-src: exclude the platform diff case from the test: ext/standard/tests/strings/basename_invalid_path.phpt e xt/standard/tests/strings/basename_invalid_path_win.php t ext/standard/tests/strings/basename_variation.phpt |
||
| Groups: | php.cvs | ||
| Request: | Send a blank email to php-cvs+get-88165@lists.php.net to get a copy of this message | ||
Commit: 27c973a954375a3706d4a1685334444713e14af8
Author: Anatol Belski <ab@php.net> Sun, 26 Jul 2015 20:31:32 +0200
Parents: c18f5e1edddf68bd449cb2b8e55d47a7da622cde
Branches: master
Link: http://git.php.net/?p=php-src.git;a=commitdiff;h=27c973a954375a3706d4a1685334444713e14af8
Log:
exclude the platform diff case from the test
Say the string is \377\000, basename will use mbrlen() to check whether
it's a start of a multibyte sequence. While on Linux it'll return -1 for
any char in the extended ASCII, on Windows it's returning 1. From what I
see the reason is that Windows doesn't implement UTF-8 in the CRT lib,
it's rather 16-bit Unicode or DBCS. Since extended ASCII is convertable
to Unicode directly - thus the behavior. On Linux however, it's a true
UTF-8 locale and implementation, for it \377\000 is invalid.
Maybe mbrlen needs an independent implementation for Windows supporting
UTF-8. For now I just split out this case so the most of the big basename
test doesn't fail on this one case.
Changed paths:
A ext/standard/tests/strings/basename_invalid_path.phpt
A ext/standard/tests/strings/basename_invalid_path_win.phpt
M ext/standard/tests/strings/basename_variation.phpt
Diff:
diff --git a/ext/standard/tests/strings/basename_invalid_path.phpt
b/ext/standard/tests/strings/basename_invalid_path.phpt
new file mode 100644
index 0000000..b632efa
--- /dev/null
+++ b/ext/standard/tests/strings/basename_invalid_path.phpt
@@ -0,0 +1,22 @@
+--TEST--
+Test basename() function : usage variations with invalid paths
+--SKIPIF--
+<?php
+if((substr(PHP_OS, 0, 3) == "WIN"))
+ die('skip not for Windows"');
+?>
+--FILE--
+<?php
+/* Prototype: string basename ( string $path [, string $suffix] );
+ Description: Given a string containing a path to a file,
+ this function will return the base name of the file.
+ If the filename ends in suffix this will also be cut off.
+*/
+
+var_dump(basename(chr(-1)));
+
+echo "Done\n";
+
+--EXPECTF--
+string(0) ""
+Done
diff --git a/ext/standard/tests/strings/basename_invalid_path_win.phpt
b/ext/standard/tests/strings/basename_invalid_path_win.phpt
new file mode 100644
index 0000000..587f2b1
--- /dev/null
+++ b/ext/standard/tests/strings/basename_invalid_path_win.phpt
@@ -0,0 +1,22 @@
+--TEST--
+Test basename() function : usage variations with invalid paths
+--SKIPIF--
+<?php
+if((substr(PHP_OS, 0, 3) != "WIN"))
+ die('skip Run only on Windows"');
+?>
+--FILE--
+<?php
+/* Prototype: string basename ( string $path [, string $suffix] );
+ Description: Given a string containing a path to a file,
+ this function will return the base name of the file.
+ If the filename ends in suffix this will also be cut off.
+*/
+
+var_dump(basename("\377"));
+
+echo "Done\n";
+
+--EXPECTF--
+string(1) "%c"
+Done
diff --git a/ext/standard/tests/strings/basename_variation.phpt
b/ext/standard/tests/strings/basename_variation.phpt
index 86b1cd2..1efd8c7 100644
--- a/ext/standard/tests/strings/basename_variation.phpt
+++ b/ext/standard/tests/strings/basename_variation.phpt
@@ -67,9 +67,6 @@ $file_path_variations = array (
array(""),
array(''),
array(NULL),
-
- /* invalid paths */
- array(chr(-1)),
);
function check_basename( $path_arrays ) {
@@ -235,7 +232,4 @@ string(0) ""
--Iteration 48--
string(0) ""
-
---Iteration 49--
-string(0) ""
Done